Use this forum to chat about hardware specific topics for the ESP8266 (peripherals, memory, clocks, JTAG, programming)

User avatar
By s60sc
#58121 I'm new to the ESP2866 and have ordered a board, and was looking at boards to extend the io, e.g add extra ADC. These are available cheaply but so are Atmega328 based boards which provide a lot of io for the price. Is it feasible / has it already been done, to program the atmega to act as a gpio extender connected to the esp8266 via i2c/spi/UART whichever is most appropriate.
Thanks
User avatar
By eketjall
#58195 I'm running a Arduino Pro Mini as a I2C slave with a ESP-01 as master, no problem.
I actually use the slave to power down the master, since the ESP-01 don't have the correct wiring to wake the ESP8266ex from deep sleep.
I then put the slave in sleep mode (draws only about 5uA) and when it wakes up it powers up the ESP-01 which polls the sensor data from the Pro Mini's analog inputs over the I2C bus and finally sends a command for power down. And repeat.
User avatar
By s60sc
#58221 Pleased to hear that its feasible so I've ordered a cheap nano clone. So I've read up on I2C and as I want an interrupt driven rather than polling approach a multi master would be most appropriate but people seem to have problems getting this to work. When I get the boards I'll try a master slave setup but use an extra pin for the slave to alert the master to do a poll.
User avatar
By eketjall
#58246 No need for an extra pin. The i2c respons from the slave is of course interrupt driven.
You can even put the Arduino in deep sleep and it will wake on a i2c request on the matching address.

You didn't tell but a guess that you will be using the Arduino IDE for programming both the Arduino and the ESP8266?
In that case just use the "wire" library on both the ESP and the Arduino for the i2c.
I hade som troubles before I fuigered out that my Pro Mini at 8Mhz was a little slow so I had to add this line to the ESP master; Wire.setClockStretchLimit(5000); // in µs
For sleep mode on the Arduino I use Low-Power library from Rocketscream. https://github.com/rocketscream/Low-Power

I haven't used deep sleep on the ESP8266 though so no experience on that.