Hi guys,
I've been at this for the better part of this week and ran out of resources to find/read online.
My setup is an ESP8266 (nodemcu V3) as master and an Arduino Nano as Slave and what I am trying to accomplish is a standard Master reader Slave sender scenario to transfer 2 byte or uint8_t values.
I know the Arduino Nano is 5V and the esp is 3.3v and I am using a generic Chinese I2C bi-directional logic level converter (3.3V to 5V 2/4/8 Channel Logic Level Converter Module Bi-Directional Arduino | eBay - the 2CH GY type).
Also the same master successfully communicates with 2 other 3.3v slaves - a bh1750 sensor and a VEML6070 sensor on the same Wire bus.
The issue I am dealing with is that I the 2 data bytes that are (supposedly) sent by teh slave are not the same as the 2 data bytes thar are received by the master. The values appear random but consistent. For example if I send (byte)0 and(byte)0 from the slave the master receives (byte)12 and (byte) 127.
The code I am using for the master is
byte buf[2] = {0, 0};
byte bytesRead = _wire->requestFrom((uint8_t)_addr, (byte)2);
if (bytesRead != 2)
{
//log error
}
else
{
_wire->readBytes(buf, 2);
}
and the code for the slave is
void handleI2CRequest()
{
byte buffer[2];buffer[0] = (byte) 50;
buffer[1] = (byte) 50;
Wire.write(buffer,2);
}
The above code is slightly simplified.
I also tried adding 2 4k7 resistors as pullups on the arduino and activating the Nano's internal pull-ups and combination of the two but no luck. And this is on top of the pull-up resistors (~20k?) on the logic level shifter
I do not own an oscilloscope and this might be the last think I can check with - to see if the internal pull-ups are correct and the signal is correct ad until I can get my hands on one - do you have any ideas? Maybe someone banged his/hers head on something similar before?
Any ideas are welcomed - thank you!