Today we are going to build a robot car using the popular ESP32CAM module. This is an amusing and educational project for builders of all ages!

Our car will have a web-based control interface, so you can drive it and view the camera from any computer, tablet, or phone.


We have already taken a look at the amazing ESP32CAM module. This little 9-dollar wonder has an ESP32S module with a camera and microSD card, as well as connections to several ESP32 GPIO pins.

We are going to use this module as the basis for a simple robot car. We will make use of the ESP32CAMs built-in WiFi capabilities to program a web-based user interface that will allow us to drive the car and to view the video camera output.

You can use this design as the heart of a more sophisticated robot, taking advantage of the many functions of the ESP32 to add sensors and output devices. 

ESP32CAM Robot Car

This robot would also be an excellent project for students or someone teaching electronics to a beginner, as the resulting product is interesting and fun to use and can be expanded and extended in many different ways. Plus there are a lot of fundamental concepts like assembly, soldering, and programming that are involved in building the robot.

Whatever the reason you have for making it you’ll find it to be a fun and entertaining project. So let’s get started!

ESP32CAM Robot Car Parts

I’m going to show you how I built this car, but you don’t need to follow my assembly techniques, although you are certainly most welcome to do so.  The real beauty of a project like this is that you can use parts you already have and come up with your own assembly technique.  So your robot car won’t necessarily look like my robot car, in fact, it could even be a robot tank, truck, or another vehicle!

However, there are some basic components that all designs will require. Let’s take a look at these essential electronic components.

ESP32CAM Module

Obviously, you will need an ESP32CAM module, as this is the component upon which our design is based.  This is a very inexpensive module available at many distributors, including Amazon and eBay.

ESP32-CAM Pinouts

The module is often shipped with the camera unattached, but it is quite a simple matter to install it.

FTDI Adapter

The FTDI (Future Technology Devices International) adapter is a device that allows you to connect a USB port to a microcontroller. These are common devices, and you should have at least one around in your workshop as several microcontrollers require them.

FTDI Adapters

You don’t need to have the adapter permanently attached to the robot, it is just needed to program the ESP32CAM.

Your FTDI adapter should have either a jumper or solder pads that allow it to be set to either 3.3-volt or 5-volt logic levels. For this project you’ll want to ensure that you use 3.3-volt logic levels.

Motor Driver

Our car will use (at least) two motorized wheels, and those motors will need a motor driver or “H-Bridge” interface to supply ample power and current at the proper polarity.

For this project, we will be using the TB6612FNG H-Bridge controller, which we have worked with before. Unlike the popular L298N H-Bridge, the TB6612FNG uses MOSFETs to allow for greater current handling and less heat dissipation.  The TB6612FNG is also more efficient, providing virtually no voltage drop as opposed to the 1.4-volts you lose when using an L298N.

TB6612FNG Pinout

These modules are inexpensive and available at many electronics vendors. They usually don’t come with the pins soldered, so you’ll need to install them.

Power Supply

Of course, our robot car isn’t going anywhere without a source of power!

You’ll need to supply two voltages for the car:

  • Power for the ESP32CAM – Although the module works on 3.3-volts it also has a 5-volt power input, and many experimenters have discovered that this is more reliable than the 3.3-volt one. So I suggest that you allow for 5-volts, with a decent amount of current capability as the WiFi connection requires occasional bursts of power.
  • Power for the Motors – This voltage level will depend upon your motors of course. The main factors here are that it (a) needs to be independent from the ESP32CAM power supply and (b) needs to have sufficient current to power the motors.

For my robot, I designed a small power supply using an adjustable buck converter and powered by a pair of 18650 batteries. The buck converter supplies the voltage for the ESP32CAM, and the motors are driven right from the batteries (7.4-volts total). 

Power Supply Options

You can also use another supply, or just use a 5-volt power bank for the ESP32CAM supply and a bunch of AA batteries for the motor.


This one is optional, as the ESP32CAM module has an integrated antenna. But for good performance, you are best to use an external antenna.

In our design the ESP32CAM module will act as an “access point”, meaning it will set up its own WiFi network. Your device (phone, tablet, or computer) wil need to connect to the robot’s WiFi signal, so you’ll want it as strong as you can get it.

ESP32CAM Robot Antenna

With the external antenna, I am able to control the robot on the second floor of my house while I am in my basement!  I haven’t had the opportunity to test it outside yet, but I’m sure the range will be good.

Some Design Considerations

I built my robot car using a standard acrylic base, I’ve used these kits before in several designs. They come complete with wheels, motors, a castor and all mounting hardware.

You could use a similar kit, or you could build your car from scratch (which is even more creative). You might also want to modify an existing model car or truck to create your ESP32CAM car.

No matter how you design your robot car there are some design considerations that are common to every build. Let’s look at a few of them now.

ESP32CAM Limitations

One of the major considerations I had when designing this robot was that the ESP32CAM module does have quite a few limitations, at least when compared to a “regular” ESP32.

  • Fewer GPIO Pins – Many of the ESP32 GPIO pins are used for the camera module, so they are not available for use externally.
  • Shared GPIO Pins – Some of the ESP32CAM pins have multiple functions. GPIO pin 0 is grounded when you want to put the ESP32CAM into programming mode, and GPIO pins 1 and 3 are used for receive and transmit and are used with the FTDI adapter.

Now, this doesn’t mean that you can’t use these pins, it just means you will have to be aware of their other uses and make certain you don’t interfere with them. If you use GPIO 1 or 3 then you’ll also have to realize that you won’t be able to use the serial monitor during development.

  • Shared Resources – Like other microcontrollers, the ESP32 has a number of registers and timers that are used for a variety of purposes. Some of these resources are used by the camera and microSD card, so if you use a library that also makes use of the same resource you’ll have a conflict.

In the robot car I built, some of the resources I used for the motor driver conflict with the resources needed for the microSD card. The MicroSD card is not used in this design, so that’s OK.  It’s an example of the tradeoffs you need to make sometimes.

Camera Considerations

Obviously one of the key features of this project is the camera. The ESP32CAM module comes with a 2.1 fixed-focus megapixel camera module, which will allow us to get a “cars-eye-view” of the action, enabling you to actually navigate the car.

A couple of considerations here:

  • Camera Quality – While the picture is certainly acceptable it is by no means HD quality, but for this application it really doesn’t have to be. I have also found a large discrepancy between different ESP32CAM boards, if you have a few you might want to see which one looks best to you.
  • Camera Mounting – The camera is affixed to the microSD card reader on the ESP32CAM, and without a longer cable that’s about the only position you can hold it in.  This makes mounting and orienting the camera a bit more of a challenge than it would be if the camera had a longer cable.

Not much we can do about camera quality except adjust it, the sample ESP32CAM code has a number of video parameter adjustments that we can include in our code. I only exposed the video size and resolution ones, but you could modify the code to add more.

One thing you cannot do, however, is to substitute a higher-resolution camera, like a 5 megapixel one. The way that the ESP32CAM module works prevents this from being done.

As for mounting, I solved that by mounting the ESP32CAM module on a separate board, which plugs into my main board. This keeps the camera oriented correctly. If you’re using solderless breadboards.

Antenna Mounting

While you could use the internal antenna you are really advised to add an external antenna to the ESP32CAM module. I know I’ve already mentioned that, but I felt it needed to be said again!

You will need to mount your external antenna on the robot, in a location close to the ESP32CAM as most of these antennas have relatively short cables.  And you’ll also want to orient it correctly, for best performance.

I mounted my antenna on a separate piece of perfboard, which I mounted above the main board using some tall spacers. I also used the same board to hold the power switch and a power indicator LED.

I used a common dipole antenna, but you can also get stick-on antennas as well. Although I haven’t tried one I suspect the stick-on ones wouldn’t perform as well.

Robot Car Hookup

So now that we have all of the components for our ESP32CAM robot car together it’s time to start wiring them up.  Before we get started, however, we need to figure out how you’re going to hook everything up.

Construction methods

You have a few choices when it comes to hooking everything up, ultimately the correct choice will be determined by the answers to a few questions.

  • Is this going to be a permanent project or just an experiment, where you will eventually reuse the components for another project?
  • Do you have experience soldering, as well as equipment to do the job?
  • Does your car body (if you’re not using the robot car chassis I used) have specific space requirements for circuit boards?

Based upon your responses to those questions you can determine the most suitable construction technique for your robot car.


This is the method that I used to construct my robot car, and it’s my preferred method of wiring up any electronics project.

Perfboard (perforated experimenters breadboards) are a great prototyping method, especially if you eventually intend to develop a printed circuit board for your project. You can move components around on a perfboard and get the positioning correct, and perfboard is also easier to modify if you find your original wiring had a design error.

I use two gauges of wire when working with perfboard:

  • Data and Signal Connections – I use 30 gauge “wire-wrap” wire for these connections. Despite its small size it is very easy to work with and solder.
  • Power and Ground Connections – I use 22 gauge “hook-up” wire for these connections.  In this design I also used 22 gauge wire for the connections to the motor terminals. While the thicker wire is a bit harder to work with it has a lower resistance, so I use it for grounds and any current-carrying lines.

When you purchase perfboards look for the better-quality stuff, the boards with plated-thru holes. The cheaper stuff is hard to solder and warps easily. 

Perfboard Wiring

This would be my recommended method of assembling this project.

Solderless Breadboards

If you are only building this robot car as an experiment or proof-of-concept then you might consider using solderless breadboards. Note that I’m using the plural “breadboards” here, as you’ll likely need at least two of them, as the ESP32CAM module will need to be mounted vertically in order to use the camera.

This has the advantage of being a very quick way to get all of the wiring done.

The biggest disadvantage of using a solderless breadboard is reliability. Remember, the robot car is a moving object, subject to crashes and vibrations. All of this rough treatment could easily cause intermittent connections.

Another potential problem is that connecting the external antennal to the ESP32CAM module will be a bit awkward. And, on the subject of the ESP32CAM module, it needs to be mounted so that you can get access to the reset button, which is on the underside of the module, and that’s also a bit tricky with a solderless breadboard.

By the way, if your only reason for choosing a solderless breadboard is to avoid soldering then you’re probably out of luck. Most of those “robot car” chassis kits don’t have the motor wires soldered, so you’ll need to solder them. And the TB6612FNG H-Bridge module is usually sold without the pins soldered, so they will need soldering as well.

“Hybrid” Construction

I used the word “hybrid” for lack of a better term. 

Essentially with this method you will need to solder everything, but you don’t need to use the tiny wire-wrap wire, which some people may find challenging to work with (although I actually find it very easy to use). 

To build the car in a “hybrid” fashion you can use a few pieces of “stripboard” or you can use pre-made circuit boards that replace solderless breadboards. 

A stripboard is a printed circuit board that has strips of copper on it.  You can break these strips using a special tool, or just use the tip of a drill bit. This allows you to make electrical connections through the strips, or to use jumper wires to route signals as well.

The printed circuit boards that look like solderless breadboards are used to create permanent versions of circuits after you breadboard them. Instead of using tiny wire wrap-wires you only need to work with standard size jumper wires, which some people may find a lot easier.

FTDI Hookup

We will begin our robot car hookup by connecting the FTDI adapter to the ESP32CAM module.  You will need this adapter to load the code that you create for the car into the ESP32CAM.

FTDI Adapter Hookup

The FTDI adapter does not need to be permanently attached, as it is only used during the programming phase of the project.  In my design I provided a female socket for the adapter, so that could remove it when not in use.


The wiring is very simple, essentially all we are doing is connecting the transmit and receive pins on the ESP32 to the receive and transmit pins on the FTDI adapter (i.e. ESP32CAM transmit connects to FTDI receive, and vice-versa).

There are also a pair of jumpers, they have the following purpose:

  • PWR – This jumper allows you to power the ESP32CAM module from the FTDI adapter, instead of using the robot car power supply. You might want to do this during programming, especially if you built the ESP32CAM module to be removable as I did. It allows you to avoid connecting the robot car power supply and FTDI adapter supply directly together.
  • PGM – To put the ESP32CAM module into programming mode it is necessary to tie GPIO pin 0 to ground. This jumper accomplishes this. It must be inserted during programming, and removed during normal operation.

Make sure that you set your FTDI adapter for 3.3-volt logic, this is usually accomplished either with a jumper or solder-pad. 

Motor Controller Hookup

The next section we will hook up is the motor controller. Here is the wiring diagram:

Motor Driver Hookup

You’ll notice that the TB6612FNG motor controller has all of its control inputs on one side of the module, and all of the power and motor connections on the other side. This will simplify your wiring task. 

You will also note that both the PWMA and PWMB inputs are connected together and driven by a single GPIO output, on pin GPIO pin 12.  This hookup saves one GPIO pin, at the expense of making it impossible to control the motor speeds independently. I felt this was an adequate trade-off.

Make sure not to forget to connect the STBY input to the VCC, this is the ”standby” input and must be held HIGH for the motor control to be enabled.

Also note the arrangement of the motor outputs, they “mirror” each other” The motor control inputs on the other side of the module are also “mirrored” in a similar fashion.

Power Supply

Finally, we need to build our power supply. If you want to build the one I used then here is the hookup diagram:

Power Supply Hookup

I’m using a pair of 18650 LiPo cells in my supply, each cell provides an output of 3.7-volts for a total of 7.4-volts.  The 7.4-volts is used to power the motors directly.

I also have a DC-DC converter, or buck converter, to supply 5-volts for the ESP32CAM. Although the hESP32CAM is actually a 3.3-volt module it has dual power inputs,m and many experimenters report better results using the 5-volt one.

The DC-DC converter I’m using is a popular one based around the LM2596 regulator. As this is an adjustable converter it must be adjusted for a 5-volt output using the multi-turn potentiometer on the module.

Make sure you set the output for 5-volts BEFORE powering up the ESP32CAM module!

You could also use a different regulator, one that is fixed at a 5-volt output would eliminate the need to perform any adjustments.

Otherwise, the only other components in the power supply I used were an SPST power switch and an LED power indicator. I used a “rainbow LED (Pimoroni COM0625), but any standard LED would suffice. 

Robot Car Assembly

Now that we have our circuit boards (or breadboards) wired up it’s time to put the car together.

Naturally, if you have chosen to build the car using an old toy, or your own unique design, then the assembly process will be different for you.

If you are using a robot car base similar to the one I used then it likely came in a kit with the acrylic base, the two motors, a castor, and some mounting hardware. The motors may or may not have wires soldered to them.

The acrylic base is usually packaged with a brown paper cover, which should be removed before you assemble everything. While this cover is really meant to protect the acrylic during shipping it also is ideal for marking off any of the holes you’ll need to drill to mount your circuit boards.

Here are a few images of the robot car I built, to give you an idea as to how I assembled mine.

ESP32CAM Robot Car Parts


ESP32CAM Robot Main Board

However, once I had mine assembled I noticed that my design was very “front-heavy”, and the car would lift up its back end every time I stopped moving!

I resolved this by adding a second castor assembly at the front of the car. Probably not the only way to fix the issue, moving the battery and circuit boards would probably have been better, but it did work.

ESP32CAM Robot Base Assembly

After you get it all together do a quick double-check of your wiring. Then we can move on to the code.

Robot Car Code

The code for our robot car is in two files:

  • esp32cam-robot.ino – This is the main file, which initializes the ESP32 and sets up the camera.
  • app_httpd.cpp – This is the file that builds the web-based interface.

I certainly can’t take credit for most of the code, as the majority of it has been copied from the sample application that Espressif provides for working with the ESP32CAM module. I have simply used sections of their code and added controls for manipulating the motor and the onboard flash LED.

Instead of examining the code line-for-line, we can just look at the sections that we might want to modify, to create our own unique remote control or top add features to the robot car.


Here is the main file, the esp32cam-robot.ino file:

This file sets up the parameters for the ESP32 “AI_THINKER” module, which is the module used on the ESP32CAM. 

Lines 18 & 19 are the only two bits of code that you might want to change, they set up the WiFi Access Point credentials. As they are the credentials are as follows:

  • SSID (Network Name) – ESP32-CAM Robot
  • Password – 1234567890

Unless you really want different credentials you can leave this file as-is. If you were to build multiple robots you might want to use a different SSID for each one. And if you are concerned about your neighbors hijacking your car you may want to use a more secure password!

Otherwise, you may leave this file alone.


This file contains the HTML, JavaScript and CSS used to create the user interface:

Here are some of the sections of this file you might want to modify:

Lines 348 – 402 – HTML

This is the heart of the HTML that we are sending to our browser.  

The buttons and sliders are arranged inside a couple of tables, which admittedly is not the best way to arrange them. Those of you proficient with CSS could probably create a much better layout, but this simple one gets the job done!

You can see that each button has a couple of distinguishing features:

  • class – This relates to the class entry in the stylesheet, which determines what the button looks like. See further below for information about modifying the stylesheet.
  • id – Each button requires a unique id name. T8his name is used in the return URL, to determine which button was pressed.
  • onclick event – Each button has a JavaScript “onclick” event associated with it. This creates the return URL whenever the button is clicked. Look at the end of this event (ie. “control?var=flash&val=1”) to determine the string sent back when the button is clicked. This relates to “Decode Return URL Values” below.

You can add more buttons or change the function of the existing ones.  The sliders work in a similar fashion.

Lines 488 – 542 – Robot Movement Functions

These are the functions that control the TB6612FNG motor controller module. By sending a pattern of HIGH and LOW signals to the four control lines (2 per motor) we can control the motor direction.

The move_interval variable sets the amount of time the robot will execute the command. You can adjust this value if you want the robot to take shorter or longer movements in response to a button press.

Lines 257 – 315 – Decode Return URL Values

This is a series of if-else statements. It examines the value extracted from the return URL string, and based upon that value it calls a function from the “robot movement functions” above.

If you add more buttons or sliders you will need to modify this section to include the return URL strings that they send back when used.

CSS File Modifications

In the app_httpd.cpp file you’ll find all of the CSS (cascading style sheets) on line 355. But it won’t be easy to edit the CSS here, as it’s minified.

Minification is the process of taking a file like a CSS or JavaScript file and stripping out all of the characters that are not used by your web browser. This includes space characters, carriage returns, and linefeeds.  These characters make the file easier for humans to work with, but are just wasted bytes as far as your web browser is concerned. And, since each byte takes time to transmit and receive, removing these characters will improve performance.

In order to work with this code you’ll need to “unminify” the CSS.  There are several websites that will allow you to do this, including this one.

Once you have edited the CSS you’ll probably want to minify it again, to save space and to (slightly) improve performance. A website like this one can do the job for you.

To make things easier I have also included a substitute version of the app_httpd.cpp file, in the ZIP download of the code (in the Resources section at the end of this article).  It’s called “app_httpd_unminified_css.cpp” , and you’ll find it in the “unminified” folder.

The most likely modification you’ll want to make to this file is the code defining the look and feel of the buttons on the display.

Lines 469 through 488 have the style settings for the buttons. You can modify the existing ones or add new ones. Just make sure to change the “class” setting for your target button in order for the changes to take effect.

Robot Car Demo

Once you have your code ready you can upload it to the ESP32CAM through the FTDI adapter. If you are unsure as to how to do this, or if you haven’t set up your Arduino IDE to include the ESP32, you can see my articles on the ESP32 and the ESP32CAM for details.

After uploading it’s time to test out our robot car!

You’ll need to connect your controlling device (phone, tablet or computer) to the WiFi access point created by the ESP32CAM module. Here is how to go about doing that:

  • Turn on the robot car.
  • Wait until you see the ESP32CAM LED (the white one) flash, this indicates tha the WiFi access point has been established.
  • Open the WiFi network settings on your controller device. Look for the ESP32-CAM Robot WiFi Network (if you renamed the network SSID in your code then you should, of course, look for that network instead).
  • Connect to the network using the password “1234567890”. If you changed the password then, of course, you’ll need to use the new one you programmed.
  • Once the network connection is established, open a web browser.
  • In the Address Bar type the following IP address –
  • You should now see the web-based interface.

The interface operation is illustrated below:


Click the START button to start the video stream. If all is working you should see the output of the camera on the ESP32CAM.

Now try the motor controls to ensure that (a) they all function and (b) the car moves in the correct direction. If the direction is wrong then you likely have the motor polarity reversed, so fixing that is pretty simple.

Interface Test

You can also test the speed controls, video controls, and light switches to be sure that all is well.

Robot Car Test Drive

And, assuming that everything checks out, you can now give your car a full test drive!


This project, in my opinion, has a lot going for it. It’s educational, it requires you to exercise skills like design and soldering, and when you’re done you’ll have an amusing and unique toy that you can proudly say you built yourself.

I’ve purposely left a few GPIO pins available, so you can experiment by adding more devices to the robot car. In my original design I had done this, I added a couple of servo motors to use as a pan and tilt for the camera, however, I removed them due to mounting considerations (and some strange behavior when the car was in a low-signal area).  You could attempt to recreate that or add a few sensors instead.

How ever you choose to build this robot car I hope that you have as much fun with it as I did. And if you come up with a unique design why not share it with your friends on the DroneBot Workshop Forum?  We’d all love to see what you come up with!



Code for ESP32CAM Car – The code files you’ll need to make this car work, all in one ZIP file.

Getting Started with ESP32 – Learn to use the ESP32 with the Arduino IDE.

Getting Started with the ESP32CAM – Using the inexpensive ESP32CAM Module.

TB6612FNG H-Bridge – Learn how the TB6612FNG H-Bridge works, and how it is better than the L298N.

Build an ESP32CAM Robot Car
Build an ESP32CAM Robot Car
Article Name
Build an ESP32CAM Robot Car
Build a small "robot car" using an ESP32CAM microcontroller and TB6612FNG H-Bridge. The car provides its own WiFi access point, so you can use your phone, tablet, or computer to drive it anywhere!
Publisher Name
DroneBot Workshop
Publisher Logo

If you have a question...

Comments about this article are encouraged and appreciated. However, due to the large volume of comments that I receive, it may not be possible for me to answer you directly here on the website.

You are much more likely to get answers to technical questions by making a post on the DroneBot Workshop Forum. Your post will be seen not only by myself, but by a large group of tech enthusiasts who can quickly answer your question. You may also add code samples, images and videos to your forum posts.

Having said that, please feel free to leave constructive comments here. Your input is always welcome. Please note that all comments may be held for moderation.

Newest Most Voted
Inline Feedbacks
View all comments
22 days ago

hello I was wondering what range you can get with this antenna because I want to make my own.

22 days ago

I love Dronebot Workshop; no one does a better job at producing clear yet detailed videos and articles with excellent production value. I think this video and its accompanying article are a prime example. This is a really nice, clean design based on readily available and inexpensive parts. Also, great minds think alike. I have also created an ESP32cam robot based on that same cheap robot chassis; It also hosts it’s own web application for control. It can be used as a first-person-view rover, but the focus is on autonomy. The robot uses the optical wheel encoders that come with the robot chassis. I’ve written a… Read more »

Would love your thoughts, please comment.x