-->
Page 1 of 1

Arduino Project with I2C

PostPosted: Wed Jan 06, 2016 2:38 pm
by John Snow
Hi everyone

I have the ESP8266 from Olimex
https://www.olimex.com/Products/IoT/ESP ... e-hardware

I'd like to use the ESP as a I2C-Master. It's horrible but i spend so many hours today and a did not even get a signal on one of the pins. Ckecked it with an oscilloscop. I would really appreciate if someone could tell me which of these pins on this piece here are SCL and SDA:
https://www.olimex.com/Products/IoT/MOD ... e-hardware
and the shematics:
https://github.com/OLIMEX/ESP8266/blob/ ... ematic.pdf

Another thing I'd like to know is, how to use I2C in the Arduino Code. I'm rly confused about this. Today I read SCL and SDA are either Pin 0 and 2, 2 and 4, 4 and 5 and I even heard that there is only Software I2C possible on the ESP8266.

In fact I already worked with I2C on Arduino, but with an Arduino Mega board only, that seems to be somewhat easier.

I would be super thankful if someone could give me just a little piece of code, how to initialize I2C on the ESP.

Greetings John

Re: Arduino Project with I2C

PostPosted: Wed Jan 06, 2016 5:29 pm
by martinayotte
The Arduino ESP has already the Wire library, so simply use it !
The pins number can be provided to the constructor.
Yes, on ESP, the I2C is software bit-banging.
Personally, I'm using GPIO2 and GPIO0 pins since they have already pullup resistors for the boot mode, so it is a perfect match for using them for I2C bus and leave other GPIOs for something else.
I've used GPIO Expander MCP23017 since almost a year, and recently, I've added an OLED SSD1306 display.

Re: Arduino Project with I2C

PostPosted: Sat Feb 06, 2016 3:28 pm
by jmd13391
Can anyone confirm that an ESP8266-12 running NodeMCU 1.4.0 firmware can only be set as an I2C master?
Thanks in advance... -Joe

Re: Arduino Project with I2C

PostPosted: Sat Feb 06, 2016 5:38 pm
by martinayotte
You're right !
Current implementation of ESP I2C library is Master only.
That should make Slave version undoable, it is simply it is a lot trickier, since Slave needs to receive the SDA/SCL asynchronously using interrupts and since ESP Wifi is also using interrupt, it can become a problem if missing some.