The Joy Robot
Home | Content | Services | About
Search Eng Light

Jonathan Pablo Toledo Guides, Microcontrollers 2021-06-07

Remote Control Vehicle Project via Wi-Fi

This project consists of building a remote-controlled vehicle using Wi-Fi. If you decide to do it, you will get an entertaining toy prototype that integrates several branches of technology, including electricity, electronics, microcontroller programming, computing, telecommunications, and Internet services.

This repository includes the source code that will be installed on the microcontroller. In my case, I have used the ESP32-CAM module; however, you can use other models, ideally boards compatible with the Arduino IDE. Most of the code is written in C language, so if you want to use another board, you will need to consider the necessary changes in programming to ensure that it works properly.

Example of the result you could get:

QR Code
Scan with your phone to watch this video
https://youtu.be/02oBJucxMBU

This is an entertaining project that you can do on your own, with your family, or with friends. You will learn a lot about how today's technologies work. It's amazing how such a small project brings together decades of research and technological evolution. The diagram below represents everything I mention:

Prerequisites

Tools needed:

  • Soldering iron or soldering iron.
  • Cutting pliers and wire strippers.
  • Knife or cutter.
  • Precision screwdriver (Phillips).
  • Hot or cold silicone gun to fix the plates to the chassis.
  • Tin for soldering.
  • Insulating tape.
  • Acrylic glue to fix the wheels (or any other high-strength adhesive).

Materials:

  • Double H-bridge. If you don't have one, you can build it yourself using power transistors or relays.
  • ESP32-CAM Microcontroller.
  • Power switch.
  • Active piezo buzzer. You can also use a passive one, but you'll need to modify the GPIO 12 digital output to work using PWM. Another alternative is to add a pulse generator using a charge-discharge circuit or an LM555 circuit.
  • Female cables for pin connections (minimum 20 units).
  • 2 x 18650 batteries of 3.7 V and more than 5000 mAh.
  • Battery holder for 18650.
  • Charger for 18650 batteries.
  • Wi-Fi antenna of at least 3 dBi (optional). The ESP32-CAM module includes an antenna, the signal of which is limited, but it may be sufficient if you do not intend to stray too far from the vehicle or Wi-Fi access point. Personally, I recommend adding an external antenna.

Computer:

  • UART (USB to Serial TTL) adapter.
  • Computer capable of running Arduino IDE.
  • Git software.
  • USB to Serial Adapter Drivers.
  • Tool esptool.py installed.

Circuit assembly

The following electronic diagram shows the connections you need to make between the different components:

Software Installation

1) Clone the project from GitHub

Run the following command in your console:

Terminal
$ git clone https://github.com/jpablotoledom/ESP32-CAM-car-server.git

2) Open the project with the Arduino IDE

Once you open the project in the Arduino IDE, you'll find three main files:

  • ESP32-CAM-car-server.ino: Main project file. Includes the methods that initialize the microcontroller and manage the Wi-Fi hardware.
  • app_httpd.cpp: web server file. It is responsible for launching the website, transmitting real-time camera images and receiving HTTP commands to control the vehicle's movements.
  • web_index.h: A file that contains the HTML code of the website. It is a copy of the frontend.html file, compressed using Gzip and declared in binary format within a hexadecimal header file.

3) Add dependencies

The Espressif dependency adds support for ESP32 modules in the Arduino IDE. This software allows you to properly compile the source code for the microcontroller. If you do not install this dependency, you will not be able to load the program on the hardware.

First, head to the Arduino IDE settings and add the following addresses:

https://dl.espressif.com/dl/package_esp32_index.json: Allows the board manager to access a wide set of ESP32 boards and modules from different manufacturers.

https://resource.heltec.cn/download/package_heltec_esp32_index.json: Allows the board manager to access the ESP32 development models marketed by Heltec.



After adding the addresses, head to the board manager and look for the ESP32 dependency, once you find it, install the dependency:

Deployment

To deploy the project, you must first compile it and verify that the code can be installed correctly on the ESP32-CAM microcontroller. To do this, press the Verify button.

If the console does not show errors, as seen in the image above, you can load the program into the microcontroller. To do this, you need to connect the ESP32-CAM's UART to your computer. Remember to install a jumper between the IO0 and GND pins, as shown in the image below. The most common way to make this connection is by using a USB to Serial adapter.

Once you have connected the USB to Serial adapter to your computer, you will need to configure the communication parameters in the Arduino IDE:

After setting up the communication between the IDE and the ESP32-CAM UART, you can now load the code into the microcontroller. Simply press the Upload using programmer button, and at the same time, press the single button that the ESP32-CAM board possesses. This will enable the programming mode.

Once the program is loaded, you can remove the bridge between IO0 and GND and restart the ESP32-CAM.

Connect to the vehicle

The vehicle will create an open Wi-Fi network called the Remote WIFI Car.

Once you connect to such a network, you will need to enter the following IP address in your device's browser (phone, tablet, or computer): http://192.168.4.1.

The website from which you can control and manage the vehicle will then appear:

Once inside the website, you will be able to control the vehicle directly from there or link it to another Wi-Fi network. If you decide to connect it to an existing Wi-Fi network, you will need to manually locate the IP address that has been assigned to you, either by entering the router's settings or using network commands. This will allow you to access the vehicle from other devices connected to the same network.

The control website includes a Wi-Fi network manager, where you can check the networks detected by the ESP32-CAM and the signal strength of each. Simply perform a scan, select the network you want to connect to, and enter the password if necessary.

You will also be able to switch the control system between buttons and joystick. Try both options and choose the one that is most comfortable for you. Remember that you will need to restart the microcontroller after changing the settings, either by turning it off and on again or by pressing the only button that the board has.


The Joy Robot