Connect tow boards via I2C problems
Posted: Wed Nov 08, 2017 12:15 am
Hello guys. I have spent some days trying to connect two boards wemos d1 mini via i2c. I cant understand what i'm doing wrong, but it does not work. When i scan on master i dont find any slave. Result code on Wire.endTransmission is always = 2. I connect both of them using USB to my PC, D1 -> D1, D2 -> D2, GND -> GND. Iam so stupid, so I dont understand why to share ground, but I do so, because I saw it in a few examples
And it's not clear for me whether to use pull up resostors or not - I can't understand if my PINS already have it.
Here's some code snippet:
Thank you!
And it's not clear for me whether to use pull up resostors or not - I can't understand if my PINS already have it.
Here's some code snippet:
Code: Select all
// Master
void I2CMaster::setup()
{
Wire.begin();
}
void I2CMaster::loop()
{
Wire.beginTransmission(100);
Wire.write('c');
byte error = Wire.endTransmission();
_logger->println(error); // always 2!
}
Code: Select all
// Slave
void onReceive(int numBytes)
{
// Never called
while(Wire.available() > 0){
int read = Wire.read();
Serial.println(read);
}
}
void setup()
{
Wire.begin(100);
Wire.onReceive(onReceive);
}
Thank you!