4 solutions to add I/O (ADS1115, MCP23017, PCF8574, PCA9685). Arduino, ESP8266, ESP32, ESP8266, Raspberry Pi Projects

add io esp32 esp8266 arduino project ADS1115 MCP23017 PCF8574 PCA9685
Share on facebook
Share on twitter
Share on linkedin
Share on pinterest
Share on email
Share on whatsapp

The integrated circuits ADS1115, MCP23017, PCF8574 and PCA9685 are 4 solutions to very easily increase the number of digital IO, PWM and analog inputs / outputs via the I2C bus. This will keep the source code of your project and save development time by avoiding having to migrate to another platform such as STM32 or ESP32. This is for example the case of the ESP8266 micro-controller has a single analog input and 8 digital I/O.

 

All of these expansion boards use the I2C bus to communicate. Consequently, they can be used by all compatible platforms including Raspberry Pi, Orange Pi, Odroid nano PCs …

Note, all circuits shown in this article are supported by ESP Easy and ESP Easy Mega firmware. So no need to know how to program to make your first connected object!

ADS1115 (ADSxxxx), add 4x 16-bit A/D inputs

The ADS1115 integrated circuit allows you to add 4 analog inputs

Main technical characteristics

  • Manufacturer: Texas Instrument
  • Power supply:
    • from 2,0V to 5V
    • continuous consumption: 150 μA
  • Analog / digital converter
    • Resolution: 16-bit
    • Sampling rate from 8 to 860 samples / second (SPS)
  • I2C addresses
    • Primary: 0x48
    • Alternative : 0x4B
  • Supported I2C bus speed: 100kHz, 400kHz and 3.4MHz
  • Other references
  • Brooches
    • VDD Power supply (2.7V to 5.5V)
    • GND  electrical ground
  • Bookstores
  • Availability
    • Expansion board
    • HAT for Raspberry PI (any generation)
  • Technical documentation
 

ADS1115 pinout i2c

See more offers

MCP23017, add 16x digital I/O over I2C. MCP23S17 (SPI version)

The MPC23017 integrated circuit allows the addition of 16 additional digital IO via the I2C bus.

The MCP23S17 is a version suitable for the SPI bus up to 10 MHz.

Main technical characteristics

  • Manufacturer: Microchip
  • Power supply:
    • from 2.7V to 5.5V
    • standby current: 1 μA max.
  • Output current: 20mA per output without exceeding 150mA in total on VSS
  • I2C addresses
    • Primary: 0x20
    • Alternative : 0x27
    • Other: use pins A0, A1 and A2 to assign an address
  • Supported I2C bus speed: 100kHz, 400kHz and 1.7MHz
  • Brooches
    • VDD Power supply (2.7V to 5.5V)
    • VSS GND, electrical ground
    • A0, A1, A2: selection of the I2C address
  • Bookstores
  • Availability
    • DIP28 box to be welded at 2.54mm pitch
    • SO28 box to be welded
    • Expansion board
  • Technical documentation
MCP23017 I2C pin identification

MCP23S017 pinout dip28 spi 16 io

Basic connection for integrated circuits

Please note, to be able to use the DIP28 or SO28 package version, you must connect the following pins

  • I2C SDA and SCL pins at 3.3V using a 4.7 KΩ pull-up resistor .
  • Pins A0, A1 and A2 to GND
  • RESET to 3.3V
  • VDD at 3.3V
  • VSS to GND

Circuit with an integrated circuit MCP23017 connected to the i2c esp8266 or esp32 buss

Example code to light an LED

#include <Wire.h>
#include "Adafruit_MCP23017.h"

// Basic pin reading and pullup test for the MCP23017 I/O expander
// public domain!

// Connect pin #12 of the expander to Analog 5 (i2c clock)
// Connect pin #13 of the expander to Analog 4 (i2c data)
// Connect pins #15, 16 and 17 of the expander to ground (address selection)
// Connect pin #9 of the expander to 5V (power)
// Connect pin #10 of the expander to ground (common ground)
// Connect pin #18 through a ~10kohm resistor to 5V (reset pin, active low)

// Input #0 is on pin 21 so connect a button or switch from there to ground

Adafruit_MCP23017 mcp;
  
void setup() {  
  mcp.begin();      // use default address 0

  mcp.pinMode(0, INPUT);
  mcp.pullUp(0, HIGH);  // turn on a 100K pullup internally

  pinMode(13, OUTPUT);  // use the p13 LED as debugging
}

void loop() {
  // The LED will 'echo' the button
  digitalWrite(13, mcp.digitalRead(0));
}

PCF8574, add 8x digital IO

Texas Instrument’s PCF8574 integrated circuit allows you to add 8 additional digital IO. Operation is very similar to Microchip’s MCP23017 seen previously

Main technical characteristics

  • Manufacturer: Texas Instrument
  • Power supply:
    • from 2.5V to 6V
    • standby current: 10 μA max
  • Output current: 25mA per output
  • I2C addresses
    • Primary: 0x38
    • Alternative : 0x3F
    • Other: use pins A0, A1 and A2 to assign an address
  • Supported I2C bus speed: 100kHz, 400kHz and 1MHz
  • Brooches
    • VCC Power supply (2.5V to 6V)
    • GNG electrical ground
    • A0, A1, A2: I2C address selector. No need to connect to GND or VCC if default address
  • Bookstores
  • Availability
    • DIP16 box to be welded at 2.54mm pitch
    • Expansion board
  • Technical documentation

 

pcf8574 pinout pin i2s output

PCA9685, add 16x 12-bit PWM channels for LED or servo motors

The PCA9685 integrated circuit allows you to add 16 12-bit PWM channels that will drive LEDs or low power servo motors. The PCA9685 is perfectly suited to control robotic arms.

Main technical characteristics

  • Manufacturer: NXP
  • Power supply:
    • from 2.3V to 5.5V
    • over-voltage protection
    • standby current: 1 μA max.
  • Output current: 20mA per output without exceeding 150mA in total on VSS
  • PWM outputs
    • 16 12-bit outputs (4096 levels) for LEDs
    • Frequency from 24 Hz to 1526 Hz
  • I2C addresses
    • Primary: 0x40 
    • Alternative : 0x7F
    • Other: use pins A0 to A5 to assign an address manually. 64 possible addresses
  • Supported I2C bus speed: 1MHz
  • Brooches
    • VDD Power supply (2.3V to 5.5V)
    • VSS GND, electrical ground
    • A0 to A5: up to 62 I2C addresses to drive up to 992 LEDs by combining several PCA9685
  • Bookstores
  • Availability
    • Expansion board
  • Technical documentation
PCA9685 16 channel pwm led servo pinout

PCA9685 pin identification

The complete test of the Geekcreit expansion board with Arduino or MicroPython code

Other projects

Example of Arduino code to drive a servo motor

A small example which varies the position of a servo motor over 180 ° developed using the Sumotoy library.

/*
  Test PCA9685 driver Doit.am 16 servos I2C shield
  Compatible Arduino Uno / Espduino / ESP8266
*/

#include <Wire.h>
#include <servo_PCA9685.h>

#define MAX_SERVOS 16

/*
 * ESP8266 I2C - pins
 * SDA: 4 - D2
 * SCL: 5 - D1
 */

servo_PCA9685 servo = servo_PCA9685();

uint8_t servonum = 0;

void setup() {
#if defined(ESP8266)
  Serial.begin(115200);
#else
  Serial.begin(38400);
#endif
  Serial.println("\nservo start");
  servo.begin();
}
int angle = 0;

void loop() {
  if ( angle == 180 ) {
    angle = 0;
  }  
  servo.moveServo(0,angle);
  Serial.println("Move to "+angle);
  angle++;
  delay(200);
}

I2C addresses of ADS1115, MCP23017, PCF8574, PCA9685 breakouts

If you have difficulty initializing the equipment you can use the I2C scanner offered in this tutorial.

Each device has an alternative I2C address. Depending on the manufacturer of the expansion board, the selection of the alternative address will be made via a jumper, a solder bridge or directly by programming. Consult the manufacturer’s technical documentation for how to choose the I2C address.

EquipmentApplicationI2C addressAlternative address
ADS1115

4 io i2c ads1115 arduino esp32 esp8266 raspberry pi

4 additional 16-bit A/D inputs

Technical documentation

0x480x4B
MCP23017

mcp23017

16 additional digital IO, DIP28 box

Bus speed: 100kHz, 400kHz, 1.7MHz

Technical documentation

0x200x27
PCF8574

mcp23017

8 additional digital IOPWM

Bus speed: 100kHz, 400kHz, 1MHz

Technical documentation

0x380x3F
PCA9685

pca9685

16 12-bit PWM channels

Technical documentation

0x400x7F

Updates

28/10/2020 Publication of the article

Version Française

Click to rate this post!
[Total: 2 Average: 4.5]

Are you having a problem with this topic?

Maybe someone has already found the solution, visit the forum before asking your question
Ask your question

Share on facebook
Share on twitter
Share on linkedin
Share on pinterest
Share on email
Share on whatsapp

Did you like this project ? Don't miss any more projects by subscribing to our weekly newsletter!

We will be happy to hear your thoughts

      Leave a Reply

      DIY Projects