Raspberry Pico Robot with 2 ESP32 cam and distance sensor — WIFI and AP

Stefano Tuveri
4 min readJun 17, 2023

--

RoboPico

My first Robot…

The idea behind this project was to be able to create a remote controllable robot for dyi “survillance” purposes.

I previously tried this same project with a Rapsberry Pi 4 but then despite the lack of on board camera (the pose an interesting challenge) but as i was not planning to do face recognition a smaller controller worked as well. So i moved to the much cheaper pico. the supply chain shortage made the RPI4 very expensive (8GB model easily north 180 GBP on ebay).

There are projects that use the ESP32 / arduino alone as it has a model with a camera already on board and it is possible to scream the video and control the setting with an app or web interface.

ESP32 Cam with dev board

However I needed to use python and hence the Raspberry Pico was the first choice as you can use mycroptyhon easily. The problem however was that i needed another set of ip cameras for the robot. Here the ESP32 cam were obvious choices. So the choice went to 2 ESP32 cam to be connected over wifi with a Raspberry Pico W (the model with the Wifi and since recently Bluetooth connectivity)

Raspberry Pico W

I had quite a journey as once decided the hardware components the main challenge was to create a webserver to implement the video streaming + the robot controls. I have to say that i have not found any project like this as such i have combined various parts i found online.

One major game changer was the discovery of the library Phew! here: https://github.com/pimoroni/phew. With this library you basically have the flask framework to build a webserver very easily. It is possible to approach using other way but this library packages everything and it is super easy to use.

Another big help was this team who created a WIFI / AP web server that can make the pico act as an Access Point and to change the settings through a web interface https://github.com/simonprickett/phewap. I extend this model and it is just brilliant what these guys did

So what it does this Robot?

Once it starts (i still use Thonny https://thonny.org/ ) if it is in a new network you connect to the AP with the credentials shown on the screen ,after the AP is set up, (means that it has to fail to connect first) then you can access the settings page from a webserver and give the right wifi credentials. now you restart (or relaunch the script) as the credentials are now stored in a local file on the pico. After the restart the robot will connect to the selected WiFi and you can connect to the webserver on the pico and use the robot though the main cockpit.

A view of the main dashboard to control the Robot

The cockpit has two controls, one for the pan/tilt servos that move the front camera (it is possible also to configure for the back camera) and the other to control the motors to move the car.

At center, there is a streaming feed from the ESP32 cam that can be toggled for front or back

Finally I added a distance sensor to the front camera that send the distance to the cockpit (in reality it is a ajax-javascript function that call the webserver where a python view respond after checking the distance from the sensor)

I am planning to add resources to this blog with a hardware and a software focus articles. A few more videos are also coming soon

I am going to upload all codes including schematic and pictures to github

A lot more to come … including remote connectivity from anywhere

here the repository https://github.com/Stefanotuv/PicoRobotProject

here a short video https://youtu.be/YOc-HlPYpqk

--

--