AED 19.95
Description
This module from RobotDyn is based on the PCA8574AD IC and uses the I2C interface. By using the I2C interface, you may supply the extra I/O pins you require in Arduino or other program development platforms.
It includes 8 I/O pins and three jumpers on the board that may be used to choose I2C addresses.
Using two Arduino pins or another programming platform, you may control up to 64 extra I/O pins with eight distinct addresses.
Up to 8 modules can be linked in a row, with the option of using various I2C addresses.
Each linked module's I2C address must be unique.
The reverse of the card has a table that shows which address corresponds to which jumper position.
Arduino and other platforms are supported. The pull-up resistors linked to the SDA and SCL pins are enabled or disabled by the J1 and J2 jumpers on the rear surface of the board.
Specifications
- 5V Operating voltage
- 8-bit I2C interface
- Possibility of successive connection with 8 different addressing (in this case each module must be at a different address)
- 8 I / O pins
- A table indicating which address is located on the back of the card according to the jumper positions
- The J1 and J2 jumpers on the back surface of the card enable or disable the pull-up resistors connected to the SDA and SCL pins.
- Compatible with Arduino and other platforms
Package Included
- 1 x Robot Dyn I2C 8-bit I / O Expander Module, PCA8574AD
How to Connect and program this Module with Arduino:
For Arduino
.VCC to 3.3 volts, GND to GND
To utilize the default 0x20 address, we must additionally connect the three address selection pins A0, A1, and A2 to GND. Then connect the SCL pin to A5 on the Arduino and the SDA pin to A4 on the Arduino.
Finally, we need to utilize 10K resistors to draw up both the SCL and SDA buses.
Connect VCC to 3.3v and GND to GND
for NodeMCU.
Pins A0, A1, and A2 are connected to GND, while SCL is connected to D1, and SDA is connected to D2.
Finally, using 10K resistors, bring both the SDA and SCL buses up to speed.
Once the IC is connected to the microcontroller, all you have to do now is attach the sensors to pins 4/7/12, or pins P0 to P7 of the IC.
then you will need to add this library to Arduino IDE (Download from Here)
to be sure about the Module I2c Address you need to upload this code first after you connect the module then open your serial monitor where it gonna write the address
the code to be uploaded :
/**
* I2CScanner.ino -- I2C bus scanner for Arduino
* 2009,2014, Tod E. Kurt, http://todbot.com/blog/
* Modified by Ashish Adhikari: https://www.youtube.com/user/tarantula3
**/
#include "Wire.h"
extern "C" {
#include "utility/twi.h" // from Wire library, so we can do bus scanning
}
// Scan the I2C bus between addresses from_addr and to_addr.
// On each address, call the callback function with the address and result.
// If result==0, address was found, otherwise, address wasn't found
// (can use result to potentially get other status on the I2C bus, see twi.c)
// Assumes Wire.begin() has already been called
void scanI2CBus(byte from_addr, byte to_addr, void(*callback)(byte address, byte result) )
{
byte rc;
byte data = 0; // not used, just an address to feed to twi_writeTo()
for( byte addr = from_addr; addr <= to_addr; addr++ ) {
rc = twi_writeTo(addr, &data, 0, 1, 0);
callback( addr, rc );
}
}
// Called when address is found in scanI2CBus()
// (like adding I2C comm code to figure out what kind of I2C device is there)
void scanFunc( byte addr, byte result ) {
Serial.print("ADD: ");
Serial.print(addr, HEX);
Serial.print( (result==0) ? " found!":" ");
Serial.print( (addr%4) ? "\t":"\n");
}
byte start_address = 8; // lower addresses are reserved to prevent conflicts with other protocols
byte end_address = 200; // higher addresses unlock other modes, like 10-bit addressing
void setup(){
Wire.begin();
Serial.begin(9600); // Changed from 19200 to 9600 which seems to be default for Arduino serial monitor
Serial.println("\nI2CScanner ready!");
Serial.print("starting scanning of I2C bus from ");
Serial.print(start_address, DEC);
Serial.print(" to ");
Serial.print(end_address, DEC);
Serial.println("...");
// start the scan, will call "scanFunc()" on result from each address
scanI2CBus( start_address, end_address, scanFunc );
Serial.println("\ndone");
}
void loop(){}
Simple code to Blink Pin 0 on the Module:
#include "Arduino.h" #include "PCF8574.h" // Set i2c address you need to be sure about the adress using the I2C scanner code PCF8574 pcf8574(0x39); void setup() { Serial.begin(115200); // Set pinMode to OUTPUT pcf8574.pinMode(P0, OUTPUT); pcf8574.pinMode(P1, INPUT); pcf8574.begin(); } void loop() { pcf8574.digitalWrite(P0, HIGH); delay(1000); pcf8574.digitalWrite(P0, LOW); delay(1000); }