MCP cover image
See in Github
2023-05-15

MCP342X (MCP3421, MCP3422, MCP3423, MCP3424) ADC 18-bits 1-4 canales (s) Arduino Biblioteca

5

Github Watches

6

Github Forks

17

Github Stars

MCP342x Library for Arduino

Repository : https://github.com/battosai30/MCP3424

Author: B@tto

Contact: batto@hotmail.fr

Current version

1.9.4

History

  • 1.9.4 15/05/2023 : fix bad units in examples (microvolt instead of nanovolt)
  • 1.9.3 25/01/2023 : revert back about typedef enum etc ... Caused issues on ESP32
  • 1.92 06/04/2022 : add some constrain in setConfiguration() to avoid out of index crashes, and add a getAddress() function to get i2c computed real address
  • 1.9 27/08/2021 : changed CHANNELS to byte type in setConfiguration()
  • 1.8 26/02/2019 : correction for 16-bit platform (bad bit shifting during 18-bits acquisition)
  • 1.7 25/07/2019 : support on MCP3421 confirmed, changed to MCP342x. Update examples
  • 1.6 19/04/2019 : Bug correction
  • 1.3 26/01/2017 : Multichannel example had a bug (out of index error on Voltage[]) and code was rewritten
  • 1.1 06/12/2012 : issues with detection of a finished conversion has been resolved
  • 1.0 15/07/2012 : initial release

Description

MCP342x (3421/22/23/24) is a I2C 1/2/3/4 channels, 18 bits resolution ADC controlled over I2C.

It has an internal reference of 2.048V and an on-board programmable gain amplifier (PGA).

Supply : 2.7V to 5V

Resolution is programmable (12, 14, 16 or 18 bits).

Download, install and import

  • Download zip
  • Put the MCP3424 folder in "hardware\libraries".
  • In the Arduino IDE, create a new sketch (or open one) and
  • Select from the menubar "Sketch->Import Library->MCP342x".
  • Once the library is imported, an "#include <MCP342x.h>" line will appear at the top of your sketch.

Creation

MCP3424(int address) -> Create instance of MCP342x.Address is A2A1A0 (refer to datasheet). For example, if pins Adr0 and Adr1 are high, the instanciation would be "MCP342x MCP(6)" because A2=1 A1=1 A0=0 so in binary 110 and 6 in decimal.

Methods

void setConfiguration(byte channel,RESOLUTION resolution,MEASURE_MODE mode,PGA pga) -> send the configuration byte to the MCP3424.

Available MEASURE_MODE :

  • ONE_SHOT_MODE
  • CONTINUOUS_MODE

Available RESOLUTION :

  • RESOLUTION_12_BITS
  • RESOLUTION_14_BITS
  • RESOLUTION_16_BITS
  • RESOLUTION_18_BITS

Available CHANNELS :

  • CH1
  • CH2
  • CH3
  • CH4

Available PGA :

  • PGA_X1
  • PGA_X2
  • PGA_X4
  • PGA_X8

getConfiguration() -> return the rax value of the configuration register.

getRawDatas(uint8_t buffer[4]) -> fill the array passed as argument with raw result (means without conversion to mv). Mainly intended for debug.

long measure() -> Return the result of the lastest conversion in nanoVolt. Note that the library waits for a complete conversion.

void newConversion() -> in one-shot mode, initiate a new conversion

int isConversionFinished() -> Returns 1 if conversion is not finished, 0 if it's completed

Examples

One-Shot conversion -> the conversion is initiated by the user

Multichannel -> classic use scanning all the channels

FAQ

How can I use multiple MCP342x object ?

MCP342x is a class, like any class you can drive any numbers of chip you want with only 2 single pin (Adr0 and Adr1) but by setting different address for each.

I can't measure voltage over 2.048V, why ?

Because the internal reference is 2.048V, but if you use it in differential mode, you can use it from -2.048V to +2.048V. Another solution is to use a voltage divider (2 x 1k resistors or example).

I'm not measuring voltage over 2.048V but my MCP342x seems to be saturated, why ?

Maybe you are using the programmable amplifier (PGA). In fact, the limit of 2.O48V is effective after it, so if your voltage multipliates by the PGA is superior to 2.048V, the ADC is saturated.

I get compilation errors, why ?

Check where you get the library : a (very) old version of mine is still given by some chinese manufacturers, and leads to errors. Simply get the last version on github.

相关推荐

  • https://suefel.com
  • Latest advice and best practices for custom GPT development.

  • Yusuf Emre Yeşilyurt
  • I find academic articles and books for research and literature reviews.

  • https://maiplestudio.com
  • Find Exhibitors, Speakers and more

  • Carlos Ferrin
  • Encuentra películas y series en plataformas de streaming.

  • Joshua Armstrong
  • Confidential guide on numerology and astrology, based of GG33 Public information

  • Emmet Halm
  • Converts Figma frames into front-end code for various mobile frameworks.

  • Elijah Ng Shi Yi
  • Advanced software engineer GPT that excels through nailing the basics.

  • lumpenspace
  • Take an adjectivised noun, and create images making it progressively more adjective!

  • Contraband Interactive
  • Emulating Dr. Jordan B. Peterson's style in providing life advice and insights.

  • rustassistant.com
  • Your go-to expert in the Rust ecosystem, specializing in precise code interpretation, up-to-date crate version checking, and in-depth source code analysis. I offer accurate, context-aware insights for all your Rust programming questions.

  • apappascs
  • Descubra la colección más completa y actualizada de servidores MCP en el mercado. Este repositorio sirve como un centro centralizado, que ofrece un extenso catálogo de servidores MCP de código abierto y propietarios, completos con características, enlaces de documentación y colaboradores.

  • ShrimpingIt
  • Manipulación basada en Micrypthon I2C del expansor GPIO de la serie MCP, derivada de AdaFruit_MCP230xx

  • Mintplex-Labs
  • La aplicación AI de escritorio todo en uno y Docker con trapo incorporado, agentes de IA, creador de agentes sin código, compatibilidad de MCP y más.

  • ravitemer
  • Un poderoso complemento Neovim para administrar servidores MCP (protocolo de contexto del modelo)

  • jae-jae
  • Servidor MCP para obtener contenido de la página web con el navegador sin cabeza de dramaturgo.

  • patruff
  • Puente entre los servidores Ollama y MCP, lo que permite a LLM locales utilizar herramientas de protocolo de contexto del modelo

  • n8n-io
  • Plataforma de automatización de flujo de trabajo de código justo con capacidades de IA nativas. Combine el edificio visual con código personalizado, auto-anfitrión o nube, más de 400 integraciones.

  • WangRongsheng
  • 🧑‍🚀 全世界最好的 llM 资料总结(数据处理、模型训练、模型部署、 O1 模型、 MCP 、小语言模型、视觉语言模型) | Resumen de los mejores recursos del mundo.

  • pontusab
  • La comunidad de cursor y windsurf, encontrar reglas y MCP

    Reviews

    5 (1)
    Avatar
    user_1Gf6eXHx
    2025-04-17

    The MCP3424 is a fantastic high-resolution ADC that has been a game-changer for my projects. Easy to use and integrate, it offers precise measurements that are crucial for data accuracy. The support and documentation provided by battosai30 are excellent, and the GitHub repository is well-maintained and helpful. Highly recommended for anyone needing reliable and accurate ADC solutions!