ESP32 Controls Robot Car
This guide details how to build and control a robot car using the ESP32 microcontroller. It covers open-source code with Arduino IDE and PlatformIO, autonomous driving features like GPS, accelerometer, and gyroscope, and PS3 controller integration.
Cover Description
The cover features a detailed image of a robot car constructed with various electronic components. A prominent ESP32-WROOM-32 module is visible, connected by numerous wires to a breadboard and other parts mounted on the car's chassis. The car itself appears to be made from transparent acrylic and wood, with wheels and sensors. Text on the cover includes the title "ESP32 steuert Roboterauto", key features like "Open-Source-Code mit Arduino IDE und PlatformIO", "Autonomes Fahren: GPS, Accelerometer, Gyroskop", "PS3-Controller", and a call to action "Gesamte Software zum Download". The author "Udo Brandes" and publisher "Elektor" are also indicated. A small PCB with pin labels (GND, 3V3, EN, TXD0, RXD0, etc.) is also visible on the left side.
Table of Contents
- Chapter 1: The ESP32 Microcontroller
- 1.1 Some Terms
- 1.2 Modules and Boards Compared
- 1.2.1 ESP32 Series Modules
- 1.2.2 ESP32 Boards
- 1.3 The ESP32-NodeMCU
- 1.3.1 ESP32 Power Supply
- 1.3.2 The Pinout
- 1.4 First Startup
- Chapter 2: Developing the Software
- 2.1 Arduino IDE Installation
- 2.2 PlatformIO
- 2.2.1 VSC Installation
- 2.2.2 Adding the PlatformIO Extension
- 2.2.3 The VSC Screen with the PlatformIO Extension
- 2.2.4 Including Libraries
- 2.2.5 Importing Arduino Projects
- 2.3 Programming with PlatformIO
- 2.3.1 C / C++ Programming Languages
- 2.3.2 From Source Code to Executable Program
- 2.3.3 Flashing the Microcontroller
- 2.4 Troubleshooting
- 2.5 JTAG Debugging
- 2.5.1 Setting Up Prerequisites for the JTAG Debugger
- 2.5.2 Using the Debugger
- 2.6 Using the ESP-IDF API
- 2.6.1 LED Blink with FreeRTOS Commands
- 2.6.2 Using Both ESP32 Cores
- 2.6.3 Communication Between Tasks
- Chapter 3: Robot Car Power Supply
- 3.1 Battery Operation
- 3.2 A Power Bank
- 3.3 Battery Operation (Rechargeable)
- 3.3.1 Accumulator Types
- 3.3.2 The Charger
- 3.4 Adapting Incompatible Rated Voltages
- Chapter 4: About the Hardware
- 4.1 The Chassis
- 4.1.1 The Acrylic Kit
- 4.1.2 Repurposing a Ready-Made Vehicle
- 4.1.3 A LEGO® Car
- 4.1.4 A Car Made of Cardboard
- 4.2 Workshop
- 4.3 In the Development Phase
- 4.4 The Final Assembly
- 4.5 Soldering Techniques
- 4.1 The Chassis
- Chapter 5: DC Motor and Control
- 5.1 The DC Motor
- 5.2 The H-Bridge Circuit
- 5.3 The L298N Motor Driver
- 5.4 Full Speed for the DC Motor
- 5.5 Regulating Speed
- 5.5.1 Pulse Width Modulation (PWM)
- 5.5.2 PWM on the ESP32
- 5.5.3 The Practical Example
- 5.6 ESP32-MCPWM
- Chapter 6: Wireless Control via WiFi
- 6.1 The Client-Server Architecture
- 6.2 WiFi Basics
- 6.2.1 Station Mode
- 6.2.2 Access Point Mode
- 6.3 Over-The-Air Update (OTA)
- Chapter 7: Control via Infrared Signals
- 7.1 IR Components
- 7.2 Controlling with IR
- Chapter 8: Detecting Obstacles with Sensors
- 8.1 The Sensors
- 8.1.1 The Contact Sensor
- 8.1.2 The HC-SR04 Ultrasonic Sensor
- 8.2 Avoiding Obstacles
- 8.1 The Sensors
- Chapter 9: Control with an App
- 9.1 MIT App Inventor
- 9.2 Creating the App
- 9.3 Voice Command Control
- Chapter 10: Autonomous Driving I
- 10.1 The Servo
- 10.2 The Light Sensor
- 10.3 Autonomous Driving
- 10.4 The Car
- Chapter 11: Using GPS
- Chapter 12: Autonomous Driving II
- 12.1 The TCS230 Color Sensor
- 12.2 Raw Data Output
- 12.3 Line-Following Autonomous Driving
- Chapter 13: Working with Accelerometer and Gyroscope
- 13.1 The LSM6DS3 Sensor
- 13.2 Simple Data Output
- 13.3 Balancing the Robot Car
- 13.4 LSM6DS3 Back Stage
- 13.5 Calibration
- 13.6 Utilizing LSM6DS3 Data Comprehensively
- 13.6.1 Measurement with the Accelerometer
- 13.6.2 Measurement with the Gyroscope
- 13.6.3 Accelerometer and Gyroscope in Electronics
- 13.6.4 "Advanced" Pose Estimation
- 13.6.5 "Advanced" Pose Estimation with the Accelerometer
- 13.6.6 Pose Estimation with the Gyroscope
- 13.6.7 The Complementary Filter
- 13.6.8 The Example – A Self-Stabilizing Platform
- Chapter 14: Controlling with the PS3 Controller
- 14.1 Setting Up Prerequisites
- 14.1.1 Determining the MAC Address
- 14.1.2 Obtaining the Library
- 14.2 Simple Function Check
- 14.3 The PS3 Console Controls the Car
- 14.4 The PS3 Console Controls a Servo
- 14.1 Setting Up Prerequisites
- Chapter 15: Robot Car and Camera
- 15.1 The ESP32-CAM AI-Thinker Board
- 15.2 Photographing with the Camera
- 15.3 Streaming Videos with the Camera
- 15.3.1 ESP32-CAM as a Web Server
- 15.3.2 Building a Trolley System for Inspections
- Appendix
- I. Robot Car – Schematic – Program – Components
- II. Handling LiPo Batteries
- Index
Copyright and Disclaimer
© 2022: Elektor Verlag GmbH, Aachen. 1st Edition 2022. All rights reserved. The contributions published in this book, especially all essays and articles as well as all drafts, plans, drawings, and illustrations are protected by copyright. Their reproduction and distribution, even in excerpts, is generally only permitted with the prior written consent of the publisher. The information in this book is published without regard to any potential patent protection. Software and hardware designations mentioned in this book may be registered trademarks even if not explicitly indicated. They belong to the respective trademark owner and are subject to legal provisions. The compilation of texts and illustrations was carried out with the greatest care. Nevertheless, errors cannot be completely excluded. The publisher, editor, and author cannot assume any legal responsibility or liability for incorrect information and its consequences. Feedback on any errors is appreciated by the publisher and author. Explanation: The author, translator, and publisher have made every effort to ensure the accuracy of the information contained in this book. They assume no liability for losses or damages caused by errors or omissions in this book, regardless of whether these errors or omissions are due to negligence, oversight, or any other cause, and hereby disclaim any liability. Cover Design: Elektor, Aachen Proofreading: Andreas Riedenauer Layout and Composition: D-Vision, Julian van den Berg | Oss (NL) Printing: Ipskamp Printing, Enschede, Netherlands ISBN 978-3-89576-521-6 Ebook 978-3-89576-522-3 Elektor-Verlag GmbH, Aachen www.elektor.de Elektor is part of the Elektor International Media (EIM) group, the world's leading source for technical information and electronics products for engineers and electronics developers, and for companies employing these professionals. The international Elektor team develops high-quality content daily for developers and DIY electronics enthusiasts, distributed through various media (magazines, videos, digital media, and social media) in numerous languages. www.elektor.de