-->
Page 1 of 2

Advice needed on interfacing ESP8266 with other modules

PostPosted: Sat Mar 23, 2019 7:07 am
by laukejas
Hi,

Posting this in Newbie Corner, since I'm not entirely sure which section would be best for this :)

I am developing a small Li-Po (10,000 mAh) powered robot (about 12x7cm large). This robot is intended to be autonomous, with an option for me to take over the controls remotely. The sensor array will include a ultrasonic sensor, several infrared proximity sensors, single pixel thermal imaging, PIR sensor, light-sensitive resistor, a compass/accelerometer, etc, as well as a FPV camera for manual control. Up until now, I tested this successfully with Atmega328P (on Arduino Nano), using Bluetooth for communications with a smartphone for manual control, and TX-02 radio FPV camera to display video on my computer. Unfortunately, the range of Bluetooth module (HC-05) and this TX-02 camera is very limited, so I decided to switch to WiFi for communications. And since using ESP8266 as a module for Arduino doesn't make much sense (ESP being much more powerful), I decided to remake the whole project using ESP8266 as the microcontroller for this robot.

Basically what I need is for ESP8266 to control all the modules of this robot, receive instructions and feed back video and various information back to my computer over WiFi.

Problem is, ESP8266 has fewer GPIO pins than Atmega328P, and only one analog pin (I need two). Additionally, all the cameras I found that could interface with ESP8266 and allow it to feed video over Wi-Fi to my computer, require A LOT of pins... Nearly all of what ESP8266 has. My target is OV7670, as I've seen several tutorials of people making it work with ESP8266 and feed video over Wi-Fi real-time with decent FPS.

Thing is, since I need so many other modules to control (sensors I mentioned, motor controls, LEDs, buzzer, etc.), there aren't nearly enough pins on ESP8266. Therefore, I'm thinking of using i2c port expanders like PCF8575 to be able to interface with all these modules on the few pins that ESP8266 has. However, I haven't seen anyone use OV7670 or similar cameras with ESP8266 using port expanders, and I am wondering if this is at all possible. Additionally, I remember reading that if I use a camera via i2c via SDA and SCL pins on ESP8266, I won't be able to use any other i2c devices (compass, infrared imaging and some other devices need i2c) on these pins, including other port expanders. To solve this, I am thinking of including software-i2c libraries to to use other pins as SDA/SCL for other i2c devices and port expanders.

My question is, would this work? Can I use OV7670 with ESP8266 over port expanders? Can I use other i2c devices on the same SDA/SCL pins, or will I need to use software i2c libraries? Is this whole setup at all possible? Are there any possible issues or considerations that I haven't addressed?

I was considering to use ESP32 instead... But it seems like an overkill just for these extra GPIO pins. Battery life is a consideration here (I will have multiple MOSFETs switching various modules on and off to save battery power, so even more pins needed).

I would really appreciate your input. I know I could test these theories on a breadboard, but as you can see from my links, I am shipping all my electronics from China (most of that stuff is not available locally, or expensive as hell), and I have to wait up to 2 months for shipping, so I want to make sure I'm ordering the right stuff that will actually make it possible for me to make this project real :)

I hope I didn't forget to include some important details about this project. If I did, let me know. Thank you.

Re: Advice needed on interfacing ESP8266 with other modules

PostPosted: Sat Mar 23, 2019 12:28 pm
by schufti
of course it is possible to use several i2c devices on one bus - as long as all of them have different address
sure it would be possible to solve all/most of your requirements with a single esp8266
BUT some of them would require realtime reaction for optimal implementation, which is almost impossible on esp8266 (controlling motorspeed on left/right wheel for straight forward course).
So just split tasks according on demand on esp8266 / atmega328

Re: Advice needed on interfacing ESP8266 with other modules

PostPosted: Sat Mar 23, 2019 12:34 pm
by laukejas
Thank you for replying, schufti. I know that I can use several i2c devices on one bus, but I read that cameras like OV7670 are a special case, and they don't really allow to use any other devices on that same bus... But I may be mistaken.

As for motor control, I will be using a TB6612FNG motor driver - I assume that with it, it should be possible to control two motors at the same time, right? I would very much like to avoid having both esp8266 AND atmega328 on this robot - trying to keep it as simple as possible.

Re: Advice needed on interfacing ESP8266 with other modules

PostPosted: Sat Mar 23, 2019 8:17 pm
by davydnorris
You could definitely do this - I would run all the I2C sensors off one set of I2C pins, and the camera off a second set, or I would find a camera that can use I2S or SPI.

If you have multiple proximity sensors of the same type then I would use an I2C multiplexor for those, but the rest should all be able to hang off the same bus if their addresses don't conflict. I have 11 sensors on my I2C bus.

I would also look at using an I2C ADC chip for the analog inputs if you need more than one - the internal ADC messes with the wifi when you use it so I would leave it alone if you need fast streaming wifi.

The other thing you may want to consider is the ESP32 - same family but double the number of busses, both Wifi and BLE, and it's a faster chip