- Sat Aug 15, 2015 1:42 pm
#26086
A more flexible approach that I would like to investigate is using AVR chips as i2c slaves. This would allow you have the same mix of digital IO, ADC & PWM that you would have if you were using the chip as your MCU. For example, an attiny45/85 would give only 3 usable pins (its an 8-pin chip itself), but you could choose various combinations of digital inputs, outputs, PWM and ADC. Step up to attiny44/84 and you get another 6 pins to play with. Choose an atmega328, and you have quite a few indeed! Plus you can attach any number of them to the same bus, by programming different slave addresses into each one.
You can program them with the same Arduino IDE you are using to program the ESP. You just need a programmer like USBasp (dirt cheap on eBay)
Another advantage is that the AVR chip could be monitoring sensors attached to it, accumulating or averaging data, running on very little current at a low clock frequency, while the power-hungry esp chip is in deep sleep. Occasionally, the ESP wakes and reads the AVR's collected data over the i2c bus and communicates it to the world.
The down side is having to program them in the first place. I looked around for a general purpose i2c slave sketch an did not really find one.
Last edited by PaulRB on Sat Aug 15, 2015 1:44 pm, edited 1 time in total.