Pan and Tilt Camera With ESP32-CAM L0Cost Robot Controller
by tekyinblack in Circuits > Robots
1987 Views, 15 Favorites, 0 Comments
Pan and Tilt Camera With ESP32-CAM L0Cost Robot Controller
There are lots of Pan and Tilt projects published online and this one has been written to demonstrate the L0Cost robot project which aims to provide robot designs which can be built for $20. The L0Cost robot controller has a basic inbuilt interface for common implementations and this is the basic two pin servo setup being used for a pan and tilt mechanism for the whole ESP32-CAM.
It's shown with the basic lipo power supply module published as another instructable.
Supplies
ESP32-CAM with psram
Micro SDcard (4Gb or less)
3D printed mechanism though an off the shelf mechanism could be used.
Solderable Dupont compatible PCB pins and sockets
Stripboard
Female-Female Dupont jumper wires
ESP32-CAM-MB to make programming easier
USB cable with microUSB connector suitable for your PC or laptop
Access to a 3D printer to make bracket, though a blob of blue tack might work equally as well.
L0Cost Robot power supply, or other similar 5V supply
Install the L0Cost Robot Controller Software
Download the latest L0Cost Robot Controller software from Github and load it onto your ESP32-CAM board.
The code should only require one piece of customisation and that is to select the type of ESP32-CAM being used. In the picture shown, the AI-Thinker model is chosen.
It's possible to use an FTDI card to program the ESP32-CAM and there are many instructables describing how to do this. The easiest way is to have an ESP32-CAM-MB USB card just for programming these boards as it makes the task much easier.
Insert the ESP32-CAM board into the ESP32-CAM-MB board as shown in the picture, and while pressing the IO0 button, connect the board to a USB cable already connected to your powered on computer.
To load the software, the Arduino IDE needs to be installed along with the ESP32 customisation. If this is not already available on your PC, again there are many instructables available giving instructions on how to install this. Other means of loading the software are available but not covered here.
Using the Arduino IDE, open the L0Cost Robot Controller software and select the ESP32 board version being used from the board manager. Select the port to be used, and then compile and load the software. If it doesn't load because the board isn't ready, press and hold the IO0 button again briefly press the reset button on the ESP32-CAM board before trying again.
The board will operate with default settings but these are unlikely to be compatible with your environment, the next step provides the necessary customisation via the SDcard.
Customise the SDcard Contents - Config.txt
The L0Cost Robot Controller is customised from the configuration held on the inserted SDcard.
Download the example SDcard contents from Github and copy them to a MicroSD card formatted with the FAT32 filesystem.
Edit the following files on the SDcard for use in your environment
Config.txt
This file contains the definitions for the initial setup of the environment and an outline configuration is shown in the pictures.
The line SERVOSTA indicates that the implementation is to use the servo interfaces with a Wi-Fi client, the parameters for which are in the Wi-Fi file listed.
The next line is the name for this system on the network, in this case 'Camera01'. Give it the name you want.
The next line lists the name of the file on the SDcard containing the Wi-Fi credentials. This is described later. This entry must exist but it can be a dummy entry, in which case the defaults will be used.
Line 4 is the entry for the script to be run during start-up of the controller and in this case contains defaults for the camera and servos. If it is not required but the main script file is, then a dummy file name must be present here.
Line 5 is the entry for the script to be run after the controller has started, it doesn't have to be present.
Downloads
Customise the SDcard Contents - WiFi
The name of this file is the same as specified in the Config.txt file
The contents of this file list the properties of the wifi connectivity for the controller.
Line 1 contains the SSID of the wifi network to be used
Line 2 contains the password of the wifi network to be used
Line 3 contains the name of the file containing the html code of the web page to be used as the home or index page of the controller on the wifi network. If it isn't present or fails to load then a default page is loaded.
The following two lines only need to be present or changed if access to the controller over the internet through a firewall is required.
Line 4 contains the port number of the home or index page
Line 5 contains the port number of the video stream
Downloads
Customise the SDcard Contents - Startup.txt
This file has to be the same name as listed in the config.txt file and if it fails to load will be ignored. It is intended to load default commands for the controller. A selection of commands are listed and can be uncommented for use.
Downloads
Customise the SDcard Contents - Main.txt
This file has to be the same name as listed in the config.txt file and if it fails to load will be ignored. It is intended to load commands for the controller. It currently doesn't hold anything other than comments describing the commands available.
Downloads
Testing the Controller
In this configuration, the controller can be rebooted and operated, though as not connected to the Pan and Tilt servos will not operate that part. In the Arduino IDE, start up the serial console and reset the controller. Messages from the controller will then display on the console. This will also display any errors in the configuration and the operational parameters.
Start a web browser and connect to the name given to the controller in the config file. The picture gives an example view. Use the buttons on the web page to test operation, they should be listed in the serial console.
Warning: the light on the camera is particularly bright so if using it do not look directly at it.
Build the Pan and Tilt Mechanism
The picture shows the components used to build the pan and tilt mechanism. Three components have been 3D printed and their .stl files are attached here. It was design in TinkerCAD here.
Stripboard Assembly
These are simple assemblies of Dupont pcb pins and sockets on stripboard to attach the controller,
Assembly 1
The base has been attached to an offcut of Perspex with Blu Tack but could be attached to any convenient base. One SG90 servo, the pan servo, is attached to the base with two screws, making sure that the servo is positioned so that the pivot and the axle are in line. Before starting, ensure the servos are positioned at 90 degrees, attaching them to the ESP32-CAM and powering them up without a script will do this for you.
Once the bottom servo is in position, fit the tilt servo carrier over the pivot and attach it to the pan servo with the rotor and a screw.
Assembly 2
Attach the stripboard circuit to the holder with two bolts, ready for attachment. Slide the holder onto the tilt axle all the way so there is plenty of room to insert the tilt servo.
Assembly 3
The tilt servo is added and secured with two screws. Once in place, attach the camera holder to the servo axle using a rotor and a screw.
Assembly 4
Connect up the power supply and servos to the stripboard. The pan servo is connected on the right, the tilt servo connected on the left with the brown lead uppermost. The power supply is connected with negative at the top.
Assembly Completed
The ESP32-CAM is now added to complete the setup. A picture is also shown using a commercial pan and tilt mechanism which could also be used. To power it the lipo battery holder referred to earlier is being used.
Conclusion
This is a useful demonstration project of the L0Cost robot controller, the ready made software quickly customised to the task through the use of the SDcard configuration files. The web page published by the controller can be customised to add additional commands. The link below shows the completed article running a basic pan script from the SD card.