-->
Page 1 of 1

Connecting ESP8266 12E to Atmega328p via I2C

PostPosted: Wed Apr 19, 2017 12:56 pm
by alguti2000
I found a couple of posts here that suggest that connecting an ESP8266 module to an Atmega328p via I2C is possible. So far, I have only been successful in getting these two to communicate via UART. However, UART is used for debugging and by the programmer I have in both the ESP8266 and the Atmega328p. So, I want to get them to communicate via I2C, instead.

I tried connecting them via a level shifter, to be able to run the Atmega328p at 5V, since it drives a few relays. But, also, for the sake of testing, tried running it at 3.3v, to avoid using the level shifter, in case that was the cause of the issue.

The issue is, the ESP8266 will go crazy in an endless power cycling loop whenever I have the atmega328p connected to the I2C bus in the ESP8266. By the way, I have a OLED LCD in the same bus in the ESP8266.

I also observed the same behavior when connecting both via UART, but I can easily go around it by having the ESP8266 power the atmega up whenever it is ready. I can't do the same when using I2C, because the ESP8266 will go crazy as soon as I plug the SCL and SDA lines. So, it doesn't work if they are already plugged when starting up, or if connected after power on.

I have an option in the board I made to enable a pull-up resistor on SDA and SLC lines. Both, same results whether the pull-up is enabled, or not.

Does anyone have a suggestion on how to wire them via I2C?

Re: Connecting ESP8266 12E to Atmega328p via I2C

PostPosted: Sun May 14, 2017 3:11 pm
by RFZ
Guess you should post your schematics... Are both using the same power source? Any other connections besides GND, SDA and SCL? What pullups do u use?
I had no problem connecting an Atmega328P (running at 5V/16MHz) to an ESP8266 with SDA/SCL pulled up to 3,3V. No level shifting was needed, the Atmega was fine with the 3,3V levels. up to 200KHz clock speed was perfectly fine, 400KHz failed, as far as I can remember...
Also be aware that the Atmega has internal pullups. Make sure they are disabled.

Edit: corrected clock speeds