Notifications
Clear all

Communication between esp32 and esp32cam

18 Posts
3 Users
2 Likes
1,096 Views
Metronus Prime
(@metronus-prime)
Member
Joined: 4 months ago
Posts: 8
Topic starter  

I've been trying to understand how to make an esp32 based rover with a robotic arm using an esp32 cam and an esp32. I was thinking about using both the modules simultaneously for different uses. The esp32 cam would get sensor data and what not from the esp32 and display it along with the camera stream in a server you can connect your phone, computer or tablet to via wifi. The esp 32 would be used to connect to a ps5 controller throught Bluetooth. Is something like this feasible? If so I was thinking about using an ultrasonic sensor, a gyroscope( mpu6050), the MLX 90614 although I've realised using it is going to be a pain due to the individual emissivity of materials,  a BMP 280 and AHT 20 sensor module, an MQ 2 sensor which I'll need to maybe modify as in the DBW video on the subject . The sheer nuber of sensors will probably use almost all of the pins of esp32 cam and some of them might be connected even to the esp32 and will have to be sent sent to the esp32 cam for streaming. Is something like this possible with serial communication via the 11500 boud rate that esp32s use?

I decided I'd use 2 Tb6612fng.s to drive the mechanum wheels and have a 6-axis robotic arm using either  mg90 or sg90 servos. This will be controlled by the esp-32 with the ps5 controller.

Is such a project do-able? Will the esp32 be able to handle such a load?


   
Quote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6974
 

@metronus-prime That is all very do-able. The only challenge is what you have already pointed out, the limited number of pins on the esp32-cam. Make sure you get MB modules as they are very much easier to work with. I think you meant 115,200.

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote
Metronus Prime
(@metronus-prime)
Member
Joined: 4 months ago
Posts: 8
Topic starter  

I did mean 115,200.

thanks for the help:)


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6974
 

@metronus-prime No problem. If you use the Reply button on the bottom right of the post you want to reply to, then the posters id is automatically inserted. You can CC others by using the format @name.

I will give you a leg up.

If you plan on storing data on the SD card, then you lose an extra 6 of the 10 GPIO pins. Of the remaining 4, one is totally free while one is used for booting and flashing and the remaining two are the serial pins.

Sounds impossible? There is a solution. Use the library that supports both serial (you can't use) and MQTT.  

Once you select what camera sketch you will use (I strongly recommend the AI-Thinker ESP32-CAM example sketch called Camera Web Server. This will allow you to use the camera via a web page.

The problem is the sketch comments say to do nothing in the main loop as the Web Server does everything so it remains to be seen if BlueTooth and MQTT can work. You may need to implement those functions in a second esp32 and figure out how to communicate between the two modules in some very small time frame like (my guesstimate) 10 microsecs. I would start with a dummy loop of 10 mikes, then slowly increase it until you see camera failures. Now add the serial communication code to both esp32's. I would add a time stamp to the 2nd esp32 to determine it's cost. If it is less than the worst case you measured, all is good otherwise it's back to the drawing board.

You will also need to add several seconds of delay at the end of each setup so you can remove the USB cables and add in the TX/RX wiring. Maybe 30secs? Use the Reset switch to re-start the 30s timer.

Use another computer like a Pi or PC/Mac or even a phone for the MQTT monitor, I use a Pi4B 4GB.

IF you have no plans for SD card data storage (unlikely) then you can probably use software serial on 2 of those pins (I am not sure).

If all that sounds a little daunting, look into ARDUCAM and pair one of their cameras with a regular ESP32 or RP2040 (PICOW) or even a RaspberryPi Zero 2W, or any of a few other boards, just make sure it is supported under the Arduino IDE. A Teensy 4.1 is a powerful board but I have yet to play with one.

Good luck.

EDIT Forgot pic

Screenshot 2024 01 06 at 08.42.03

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote
WhitneyDesignLabs
(@whitneydesignlabs)
Member
Joined: 3 years ago
Posts: 99
 

@metronus-prime I was running into similar issue on how to multiple ESP32s on a robot. I settled on a solution using a tiny travel router, Raspberry Pi, and MQTT. Basically the ESP32s all have static IP addresses. The pi does as well, and it runs the MQTT server.  ESP32s all communicate with the MQTT server on the Pi.  I have used the AI Thinker C++ sketch on ESP32 CAM and streamed the images to the Pi. My plan is to use the ESP32 CAMs for initial vision processing, then let the Pi handle more intense AI vision tasks (tracking, identification etc with opencv).  Any number of other ESP32s can be used for sensors, and simply send their sensor data over MQTT.

I looked at heap of options to create all this inter-communication. I2c? Nope, could not configure an ESP32 as a client, host only. Same problem I found with SPI.  Direct serial?  I explored that, too, but didn't work for some other reason I can't recall. Settled on robot's own wifi network and MQTT. Add NodeRed onto the Pi and managing the MQTT data is a breeze and all visual.

Don't know if adding a Pi and/or wifi router is in the cards for you. You could also just have all your devices join your home network. But in my case I wanted the robot to be its own network, independent of any local wifi. ANd ESP32s are easy to get onto a wifi network. SO you can add as many as you want to the robot. Very future proof and expandable.

Imagine by thought, create, don't wait, Scott.


   
ReplyQuote
Metronus Prime
(@metronus-prime)
Member
Joined: 4 months ago
Posts: 8
Topic starter  

@zander I don't plan on using the micro SD card on the esp32 cam since I find the number of pins used wayy to high. Another reason I wouldn't add a micro SD card is if I added one it would have to be less than 2gb( I think that's the limit) and that's way too little to record videos. I thought I'd just screen record the video stream on the client device for the time being and find a proper way to do it locally on the client in the future. I did something similar in a pan and tilt rover I made a few months back but for some reason the forum says I can't add any attachments to this replay ...


   
ReplyQuote
Metronus Prime
(@metronus-prime)
Member
Joined: 4 months ago
Posts: 8
Topic starter  

@whitneydesignlabs at the time being adding a router on the rover sounds a little tedious but I think I would go with it if serial communication doesn't work. I may or may not use this rover inside my house and maybe even use it at my friend's houses on occasion. If I use it in station mode I may run into lags at dead zones I'm my house network although it's range would dramatically improve as compared to AP mode. But if I use it in station mode the range is still going to be limited by the range of the Bluetooth connection between the esp32 and the ps5 controller. So there isn't a major improvement as such. 

 


   
ReplyQuote
WhitneyDesignLabs
(@whitneydesignlabs)
Member
Joined: 3 years ago
Posts: 99
 

Understandable. I spent a couple weeks exploring options and settled on the little travel router and MQTT. Works for me, but might not be best for your project.

The onboard router has other benefits for me. I use it to bridge any local wifi to the robot's internal wifi. So if I bring the robot (or the network module of the robot) with me when I travel, I always have my own little network with me, with all my static IPs, and I can just connect it to whatever wifi is available for Internet.

My larger plan is to integrate all of this into smart home functions, Home Assistant etc. So the network is somewhat at the core of it all.

Imagine by thought, create, don't wait, Scott.


   
ReplyQuote
Metronus Prime
(@metronus-prime)
Member
Joined: 4 months ago
Posts: 8
Topic starter  

@whitneydesignlabs sounds awesome! The things you can do if you managed to make it work with home assistant 🤯🤯..


   
ReplyQuote
WhitneyDesignLabs
(@whitneydesignlabs)
Member
Joined: 3 years ago
Posts: 99
 

@metronus-prime Exactly. I have been watching home robots on Youtube. There are some that are extremely nimble and dexterous. But it got me thinking, what if the robot didn't have to turn dials, or push buttons to turn on a dishwasher, microwave etc.  What if it could just control the appliances and home devices directly, while still leaving the knobs and buttons in tact for human use.  An entire robot/smart home concept comes into my imagination, where Home Assistant and robot(s) all interact.

Imagine by thought, create, don't wait, Scott.


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6974
 

@metronus-prime You have to have 10 posts before allowed to PM and post pics. As far as recording video and jpegs, that is already built into the esp32cam webserver software.

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6974
 

@metronus-prime AP mode IS a software router. Also, an esp32 can be in both AP and Station Mode at the same time. Is that a big enough hint?

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote
Metronus Prime
(@metronus-prime)
Member
Joined: 4 months ago
Posts: 8
Topic starter  

@zander you mean simultaneously or it can run in AP mode and station mode in the same sketch? I know they can run in the same sketch because I used the wifi manager library but I didn't know it could be used in AP mode and station mode at the same time because I thought it's single antenna let it do only one at a time


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6974
 

@metronus-prime There are 3 modes of operation, STATION, AP_MODE, and STATION_AP_MODE. Has nothing to do with the antenna. See pics

Screenshot 2024 01 07 at 07.53.16
Screenshot 2024 01 07 at 07.57.41

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote
Metronus Prime
(@metronus-prime)
Member
Joined: 4 months ago
Posts: 8
Topic starter  

@zander did not know that😅


   
ReplyQuote
Page 1 / 2