Hello
Error msg = Failed to communicate. Check wiring and address of SX1509.
Thanks in advance
My source code
#include <Wire.h> // I2C library
#include <SparkFunSX1509.h> // http://librarymanager/All#SparkFun_SX1509
#define I2C_SDA 2
#define I2C_SCL 4
TwoWire I2CSX = TwoWire(0);
SX1509 io;
void setup() {
Serial.begin(115200);
Serial.println(“GL1-SX1509”);
I2CSX.begin(I2C_SDA, I2C_SCL);
if (io.begin(0x3E) == false)
{
Serial.println(“Failed to communicate. Check wiring and address of SX1509.”);
while (1);
}
io.pinMode(1,OUTPUT);
}
void loop() {
io.digitalWrite(1,1); delay(2000);
io.digitalWrite(1,0); delay(2000);
}
Can you share a photo of your setup/wiring?
I use 4 wires
Red = 3V3
Gnd = Black
White = SCL
Brown = SDA
1 Like
You need to tell SX-1509 driver that it needs to use the I2CSX instead of the default Wire.
instead of : if (io.begin(0x3E) == false)
do : if (io.begin(0x3E, I2CSX) == false)
1 Like
… but same error
GL1-SX1509
E (7) i2c.master: I2C hardware timeout detected
E (7) i2c.master: s_i2c_synchronous_transaction(924): I2C transaction failed
E (7) i2c.master: i2c_master_multi_buffer_transmit(1186): I2C transaction failed
E (14) i2c.master: I2C hardware timeout detected
E (18) i2c.master: s_i2c_synchronous_transaction(924): I2C transaction failed
E (25) i2c.master: i2c_master_multi_buffer_transmit(1186): I2C transaction failed
E (33) i2c.master: I2C hardware timeout detected
E (37) i2c.master: s_i2c_synchronous_transaction(924): I2C transaction failed
E (44) i2c.master: i2c_master_multi_buffer_transmit(1186): I2C transaction failed
E (51) i2c.master: I2C hardware timeout detected
E (55) i2c.master: s_i2c_synchronous_transaction(924): I2C transaction failed
E (62) i2c.master: i2c_master_receive(1240): I2C transaction failed
Failed to communicate. Check wiring and address of SX1509.
try this:
change TwoWire I2CSX = TwoWire(0);
to TwoWire I2CSX = TwoWire(1);
What happens if you use to the default Wire & connection points?
P.s. be aware the GPIO2 has a special meaning during boot: must be left floating or LOW to enter flashing mode
Same error
This code is running with either Pin 14 & 15 or Pin 21 & 22
#define I2C_SDA 14 // default=21
#define I2C_SCL 15 // 22
SX1509 io; // Create an SX1509 object to be used throughout
void setup() {
Serial.begin(115200);
Serial.println(“GL1-SX1509”);
Wire.begin(I2C_SDA, I2C_SCL);
if (io.begin(0x3E) == false)
{
Serial.println(“Failed to communicate. Check wiring and address of SX1509.”);
while (1);
}
I have no problem to flash
The Wire is using i2C-number(0) and is always defined. What happens if you try Wire.begin(2,4)?
Did using i2C-number (1) made a difference ?
Still concerned about using GPIO2, with the i2C there should always a pull-up resistor on the SDA and SCL line.
Same error with Wire.begin(2,4)
SX1509 has pull-up resistors for SDA & SCL
I don’t understand “Did using i2C-number (1) made a difference ?”
From earlier post:
But if it does not work with Wire.begin(2,4).. I don’t expect that will make a difference.
Somehow the wire does not work on this way/
I wonder… for test try this:
disconnect the I2C line from the pins 2 and 4
Compile and upload your sketch with Wire(2,4)
reconnect the I2C pins, reboot and see what happens
From ESP32 I2C Communication: Set Pins, Multiple Bus Interfaces and Peripherals | Random Nerd Tutorials
this might not work and it might be a bit tricky to select other pins. That happens because those libraries might overwrite your pins if you don’t pass your own Wire instance when initializing the library.
In those cases, you need to take a closer look at the .cpp library files and see how to pass your own TwoWire parameters.
so I try to use Twowire but I don’t have knowledge to understand SparkFunSX1509.cpp
The SparkfunSX1509.cpp does not change pins. It uses the TwoWire interface that was provided and initialized with Wire.begin(x,y);
Try the test that I proposed with disconnecting I2C first
no I don’t have an Sx1509.. I don’t expect that to be the issue here. something to do with Wire. Something basic.
How about trying GPIO5 for SDA : Wire.begin(5,4) ? or another pin for SDA or SCL
1 Like
You have right : Wire.begin(13,14) is OK
Thanks
1 Like