Cover image
Try Now
2019-08-12

An Arduino Library supporting the MCP3XXX series of ADC SPI chips, including MCP3002, MCP3004, MCP3008 and others.

3 years

Works with Finder

2

Github Watches

4

Github Forks

20

Github Stars

MCP3XXX

Build Status

Description

An Arduino Library supporting the MCP3XXX series of ADC SPI chips, including MCP3002, MCP3004, MCP3008 and others.

Features

MCP3XXX is a simple library enabling access to the MCP3XXX series of ADC SPI chips. Support for differential and psuedo-differential reads. Supports MCP3002, MCP3004 and MCP3008. Support for 12 and 13 bit chips such as MCP3202, MCP3204, MCP3208 and MCP3304 will be added when they can officially tested. When not reading data, the chip goes into standby / low power mode. On the MCP3004/3008, for example the standby current is only 5 nA.

Background

Why do I need this? You need additional analog inputs.

Setup

Basic

To read from analog input 0 on an MCP3002 using the default hardware SPI pins, you might use:

#include <MCP3XXX.h>

// Create an instance of the MCP3002 ADC.
MCP3002 adc;

void setup()
{
  Serial.begin(9600);

  // Use the default SPI hardware interface.
  adc.begin();
}

void loop()
{
  // Read from channel 0 and print.
  Serial.print(adc.analogRead(0));
  delay(10);
}

Documentation

See API Documentation.

Troubleshooting

If you encounter connection issues, confirm that the maximum sampling frequency you are using is supported by voltage of your board. For example, the aliases MCP3002, MCP3004, MCP3008 are defined as:

// A typedef for the MCP3002.
// Max clock frequency for 2.7V: 1200000 Hz
// Max clock frequency for 5.0V: 3200000 Hz
typedef MCP3XXX_<10, 2, 1200000, 2> MCP3002;

// A typedef for the MCP3004.
// Max clock frequency for 2.7V: 1350000 Hz
// Max clock frequency for 5.0V: 3600000 Hz
typedef MCP3XXX_<10, 4, 1350000> MCP3004;

// A typedef for the MCP3008.
// Max clock frequency for 2.7V: 1350000 Hz
// Max clock frequency for 5.0V: 3600000 Hz
typedef MCP3XXX_<10, 8, 1350000> MCP3008;

Thus, higher voltage boards allow a higher sampling rate.

Examples

See the included examples for further usage options.

Developer Notes

Currently the library has been tested with MCP3002 and MCP3008. MCP3004 support is also included because it uses the same SPI command structure as the MCP3008.

Datasheets

Changelog

See CHANGELOG.md.

License

See LICENSE.md.

相关推荐

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

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

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

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

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

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

  • https://zenepic.net
  • Embark on a thrilling diplomatic quest across a galaxy on the brink of war. Navigate complex politics and alien cultures to forge peace and avert catastrophe in this immersive interstellar adventure.

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

  • https://reddgr.com
  • Delivers concise Python code and interprets non-English comments

  • 林乔安妮
  • A fashion stylist GPT offering outfit suggestions for various scenarios.

  • 田中 楓太
  • A virtual science instructor for engaging and informative lessons.

  • 1Panel-dev
  • 💬 MaxKB is an open-source AI assistant for enterprise. It seamlessly integrates RAG pipelines, supports robust workflows, and provides MCP tool-use capabilities.

  • Mintplex-Labs
  • The all-in-one Desktop & Docker AI application with built-in RAG, AI agents, No-code agent builder, MCP compatibility, and more.

  • GeyserMC
  • A library for communication with a Minecraft client/server.

  • ShrimpingIt
  • Micropython I2C-based manipulation of the MCP series GPIO expander, derived from Adafruit_MCP230xx

  • GLips
  • MCP server to provide Figma layout information to AI coding agents like Cursor

  • open-webui
  • User-friendly AI Interface (Supports Ollama, OpenAI API, ...)

  • Dhravya
  • Collection of apple-native tools for the model context protocol.

    Reviews

    3 (1)
    Avatar
    user_eHxE1aeX
    2025-04-18

    I've been using the MCP3XXX series by bakercp and it has tremendously streamlined my embedded projects. The library is robust, well-documented, and integrates seamlessly with various microcontroller platforms. It's evident that a lot of thought and care went into its development. Highly recommend for anyone looking to enhance their projects with reliable ADC functionality. Check it out on GitHub!