[Solved] ESP8266 to Nano I2C Problems.

Thanks to everyone who contributed in this thread. I could not have figured it out without you guys.
It did however take me a bit before I figured out which parts to use and which parts not to use. For me the delay(1) do not seem to be necessary. What did the trick for me is put this line straight after Wire.begin()

Wire.setClockStretchLimit(15000);

If someone is interested, I wrote a post on the Arduino I2C Slave and on the ESP as an I2C Master for that slave where I have shared the full code if someone is interested.

Again, THX!

A lot of head scratching until I found this thread.

Had problems using a Pro Mini 8Mhz as slave to a ESP-01 master.
Adding Wire.setClockStretchLimit(1500) did the trick!

Thanks!

The Nano VCC/VDD is 5V DC. Therefore, the I2C signals are 5V.
The ESP VCC/VDD is 3.3V DC. Therefore, the I2C signals are 3.3V.

You must use level converter 5V to 3.3V.
See the level converter link below:

https://www.aliexpress.com/item/JY-MCU-5V-3V-IIC-UART-SPI-Level-4-Way-Converter-Module-Adapter/32706458220.html?spm=2114.01020208.8.19.uAAJGi

I am going to try it today. I will post another relay soon.

Thanks,
Erez

mde110:
For everybody else who have problems with ESP8266 as I2C master requesting values from Arduino slave.
Set the stretchlimit if ESp is impatient:

Wire.setClockStretchLimit(1500);    // in µs

Outstanding. Without this setting my ESP8622-01's just wont talk I2C.
This setting needs to be promoted more aggressively.

Hi OP!

Is it possible for you to publish the wiring diagram btw Nano and ESP?

TIA

vazquezjm:
Hi OP!

Is it possible for you to publish the wiring diagram btw Nano and ESP?

TIA

I2C uses SCL, SDA, VCC and Ground.

If you use an Nano with 5V supply, you need two 4,7k pullup resistors for data and clock to Vcc 5V!

SCL is GPIO5 (D1) on ESP connected to A5 on Nano/Uno/Mini (328p)
SDA is GPIO4 (D2) on ESP connected to A4 on Nano/Uno/Mini (328p)

If you want, you can make a diagram an publish it :wink: .
vazquezjm, feel free to draw, im looking forward...

I believe the best solution is here:

http://www.digole.com/forum.php?topicID=777

mde110:
For everybody else who have problems with ESP8266 as I2C master requesting values from Arduino slave.
Set the stretchlimit if ESp is impatient:

Wire.setClockStretchLimit(1500);    // in µs

Many thanks!

Hello, I'm trying to connect using i2c an Arduino UNO to a ESP-01. I think that I tried everything.

I'm using a voltage converter with a 2n7000 transistor for the SDA and SCL. (Don't know if I needed to do that since I can see that people here are connecting directly the pins)

I wanted to send 3 bytes from UNO to ESP, I can see that arduino goes to the RequestEvent but it halts there. Also you can see that buffer [] are calling each one a function.

void espWifiRequestEvent()
{
uint8_t buffer[3];

buffer[0] = SensorMov();
buffer[1] = Temp_inteiro();
buffer[2] = Temp_fracao();

Wire.write(buffer, 3);

Wire.endTransmission();

}

at the ESP side, I'm using at the setup

Wire.begin(0,2);
Wire.setClockStretchLimit(40000);

but when I request the data from ARDUINO, the ESP works displaying data, as it has received the data from Arduino.

Any comments on how should I proceed?

Thank you.