ESP32 Remote Surveillance Robot

by jasonful in Circuits > Robots

1134 Views, 7 Favorites, 0 Comments

ESP32 Remote Surveillance Robot

20210109_133233.jpg

The ESP32 robot cam is a mobile surveillance robot that can be controlled over the internet. It is built around a standard ESP32-Cam board, plus a motor driver, batteries, power supply board, and motorized platform. It also includes an optional inductive charger so that it can "dock" and recharge itself while remaining connected to the internet and ready to respond to commands without depleting its battery.

UPDATE March 2021: These instructions were written for a breadboard, but since then I designed a PCB. If you're serious about building this and want to use a PCB, private message me.

Supplies

  1. ESP32-Cam (AI-Thinker, or clone)
    1. The one I bought from BangGood was configured to use an external antenna, whereas the one from Amazon used the internal antenna. Both work, and you can switch a board from one to the other, though it requires some delicate desoldering and resoldering. If you need an external antenna, get one with a "U.FL Mini PCI" connector.
  2. AdaFruit PowerBoost 500
  3. DRV883 Motor Driver
  4. LiPoly battery, such as this one.
  5. 4x AA batteries
  6. Half-size breadboard
  7. Robot chassis, such as this one or search for "2WD Motor Smart Robot Car Chassis" on Aliexpress.
  8. Variable potentiometer (optional, for reporting charging status on the web page)
  9. Inductive charger (optional)
  10. Male to male Dupont wires, or other breadboard wires

Tools:

  1. FTDI board, such as this or this or this.
  2. Hot glue gun, or adhesive strips, or adhesive Velcro strips
  3. Soldering iron

Assembly

20210109_115219.jpg
20210109_135317.jpg
20210109_133239.jpg
20210109_133204.jpg
  1. Assemble the robot chassis according to the instructions that come with it. The instructions that came with mine were pretty incomprehensible, but it's not that hard to figure out how to put it together even without instructions.
  2. Solder headers onto the Esp32-Cam, the PowerBoost, and the Motor Driver.
  3. If using an external antenna, (and assuming it is like mine) unscrew the two halves, drill a 1/4" hole in a convenient spot in the chassis, feed the body of the antenna through the top, then screw in the other half from below, and secure with the nut. Attach the wire to the underside of the ESP32-Cam.
  4. Plug the Esp32-Cam, the PowerBoost, and the Motor Driver into the breadboard with the PowerBoost at the top, Motor Driver in the middle, then the variable potentiometer, then the ESP32-Cam at the bottom. On a half-size breadboard, there are just barely enough rows to fit everything. The camera lens will be pointing up at the ceiling so you'll want to flex it 90 degrees so it is pointing forward; I put a cube of poster tack behind it to hold it up.
  5. Attach breadboard to car chassis, towards the front, with camera facing forward, using hot glue or adhesive strips.
  6. Plug the Li-poly battery into the PowerBoost. Important: Make sure the polarity of the battery matches the polarity of the PowerBoost; otherwise, you will destroy both. If you buy your battery from Adafruit, it will match. But if purchased elsewhere, it very well may be reversed. If you need to reverse the polarity, see this video.
  7. Use an adhesive strip to mount the inductive charger (the half with the oval copper coil) to the front of the top of the chassis so that the coil hangs over the front of the chassis like a bumper. See photo.
  8. Tape the other half of the inductive charger to a wall, at a height where it aligns with the half on the chassis. See photo. Attach USB power.
  9. Insert 4 AA batteries into the holder.
  10. Plug a USB cable from your PC to the FTDI board. Connect the FTDI's TX to the ESP32-Cam's RX, and the FTDI's RX to the ESP32-Cam's TX, and Gnd to Gnd. (The FTDI does not need to supply power because that will come from the PowerBoost.)

Wiring

20210109_115452.jpg
20210109_115052.jpg
20210109_133222.jpg
wiring.png

Now wire up everything according to the wiring table in the photo above.

Most of the wiring is just plugging wires into the breadboard, but you'll probably want to solder the wires to the motor terminals. And solder the AA battery pack wires to header pins to make them easier to insert into the breadboard. Same with the inductive charger wires.

I used the breadboard rails for USB and GND. For the 5V I just used the holes next to the PowerBoost 5V.

Optional Wiring

You may want to put a pushbutton between the PowerBoost's EN and GND to make resetting easier. Or just have a dangling Dupont wire hanging off EN that you can plug into GND (also useful for turning off the power when robot is not in use). Or both.

You may want to connect the Motor Driver's EEP to GND temporarily. This will disable the motors until you are ready to actually use the robot, thereby preventing the robot from accidentally flying off your desk, or pulling out FTDI wires or whatever.

Software

  1. If you are not already familiar with how to use the Arduino IDE to upload code to an Esp32-Cam, see this tutorial.
  2. The sketch is available on https://github.com/jasonful/esp32cam-car. It is based on this sketch by Hyuk Kang.
  3. Open the sketch in the Arduino IDE. Enter your SSID and password into esp32cam-car.ino. Under the Tools/Board menu choose "AI Thinker ESP32-CAM". Under Tools/Port choose the port corresponding to the FTDI.
  4. Upload the sketch and open the Serial Monitor (115200 baud).
  5. Disconnect Io0 from GND, and reset (by momentarily pulling PowerBoost's EN to GND, or pressing the button if you installed one).

Usage

ESP32 Robot-cam

  1. The ESP32-Cam's LED will blink once when the camera is initialized correctly, and then twice when WiFi is connected. It will blink 3 times if camera initialization fails, and then reboot. (This happened to me sporadically.)
  2. In the Serial monitor, you will see the address of the robot's web page. You may want to go into your router's settings and permanently assign that IP address to your ESP32, so you never have to hook up the serial monitor again.
  3. Disconnect the FTDI from the ESP32.
  4. Is you disabled the motors, connect EEP to 5V now.
  5. Open the robot's web page, and you should see a streaming video and a set of buttons to control the robot. You should be able to now drive your robot from the web page. The go/back/left/right buttons take effect as long as they are held down. The smaller buttons outside those are the "nudge" buttons: They take effect for 100 milliseconds, and are useful for nudging the robot just a little bit.
  6. To recharge the robot, drive it over to the spot on the wall where you mounted the other half of the inductive charger. It might be difficult to get it perfectly aligned. Note you have to manually refresh the web page to see the "Charging" show up. You might want to manually align the two halves, then see what the camera sees, so you can try to duplicate that view in the future. NOTE: While this is an interesting proof of concept for remote charging, I do not recommend actually leaving the robot unattended while charging, because I don't want anyone to burn their house down.

Final Notes

Calibrating the charge level

To detect when the battery is charging, there is a connection from the PowerBoost's USB pin to an input pin on the ESP32. When the input pin reads HIGH, the web page will say "Charging" on the bottom left. I would have expected this pin to be at 0V when not charging, but for some reason there is a small voltage, roughly 1.0 to 1.7V, which is enough to register as HIGH. So the variable potentiometer divides this voltage to a lower level that registers as LOW on the input pin. To calibrate this, rotate the potentiometer to a point where the web page will say "Charging" when a USB power cable is plugged into the PowerBoost, and not say "Charging" when not plugged in.

Accessing from the internet

By default, the robot's web page is only accessible from your local network. To access it from a remote location over the internet, you will need to set up a VPN to tunnel into your local network. Or you can set up port forwarding on your router, but if you don't want any random person on the internet controlling your robot, you will need to add authentication.

Brownouts

If your ESP32-Cam often says "Brownout trigger detected" on boot, it could be caused by any number of power-related problems. For me, it was poor wire connections on the breadboard.

Design variations

The variable potentiometer is optional; it is there just so the web page can tell you when the robot is charging, i.e., when the robot is "docked" correctly to the inductive charger. But if you are not using the inductive charger, or not operating the robot remotely, you probably don't need it.

I used separate batteries for the ESP32 and for the motors. Theoretically, you could use one power source for both, but since the ESP32-Cam is so finicky about its power supply, I didn't risk it. But if you use a different 5V supply, and you don't care about charging it remotely, you could even get rid of the PowerBoost board entirely.

Other models of motor driver should certainly work.

Motors on startup

When the ESP32 boots, the left motor turns on (reverse) for a fraction of a second, which can be bad if the robot is on a desk or nearby something. I tried various solutions but was unable to fix this, so if anyone verifies a solution, let me know...

Charging

As mentioned above, I do not actually recommend leaving the robot unattended while charging, as these are handmade robots, not UL Listed, and I do not want to be responsible for any fires.

Bugs

If you find any bugs in the code, the design, or this documentation, please log an issue on github.