If you're running into the following error while compiling, refer to the section Notes on the implementation on how to resolve it:
lto1.exe: internal compiler error: in lto_output_varpool_node
This repository contains:
- The source code of the program run on the car, written in the Arduino IDE
- Schematics and reference pictures of the power-regulated WiFi module and the final build of the car
- The schematics are made with fritzing. You can use fritzing to open the .fzz file and edit the schematics or use it to create a proper PCB.
- A list of hardware and accessories used to finish this project
- The base RC car kit.
- An Arduino USB host shield for USB capabilities to enable XBOX controllers.
- An Arduino Sensor shield for better access to pins and easier wiring.
- An XBOX 360 wireless controller and receiver.
- A GPS module.
- An ESP8266 ESP-01 WiFi module
- A 3.3V Step Down Power Supply Voltage Regulator module.
- A roughly 3x7cm prototype board as a base for the power-regulated WiFi module.
- A 400 pin breadboard to fit the extra components neatly above the battry pack in the back of the car.
- A reasonable assortments of electronic parts (resistors: 1k, 2k, 10k; capacitors: 0.22uF, 470uF; jumper cables; male and female pin header connector rows)
- soldering kit
- AA batteries for the car and the XBOX 360 controller
- USB Serial module for the ESP8266
- tape for fixing the breadboard and the wireless controller adapter to the car
- optional: rubber bands (the tires in some car kits do not create enough friction on most surfaces, you can put rubber bands around them to increase traction)
The GPS module is connected as follows:
GPS | - | Arduino |
---|---|---|
VCC | <-> | +5V |
GND | <-> | GND |
TxD | <-> | PIN 18 (A4) |
RxD | <-> | PIN 19 (A5) |
ATTENTION: The ESP8266 operates on 3.3V, while the Arduino operates on 5V! Do not connect the ESP8266 to 5V, use a step down regulator to convert the Voltage. The ESP8266 may not function correctly or even break/brick if operated under 5V. For the same reasons, use a 1k and a 2k resistor to step down the signal coming from the arduino on the ESP8266's RxD line!
The ESP8266 is generally connected as follows:
ESP8266 | - | Arduino |
---|---|---|
VCC | <-> | +3.3V (generated from step down regulator) |
GND | <-> | GND |
TxD | <-> | PIN 4 |
RxD | <-> | PIN 3 (through step down resistors) |
CH_PD | <-> | +3.3V (through 10k pull-up resistor) |
When idle, the ESP8266 draws about 30-50 mA, but during peak load draws of about 300mA are not unseen. I recommend to use stabilizer capacitors of 470uF near the step down regulator and 0.22uF near the ESP8266 to help with sudden spikes. The capacitors should be as near as possible to their respective counterpart parts, since too much resistance on the cables running up to them can negate their intended functionality.
So all-in-all the ESP8266 requires quite a bit of extra work here:
- step down power source voltage from 5V to 3.3V
- add additional step down resistors for incoming signals from Arduino
- a pull up resistor for CH_PD
- stabilizing capacitors for smoother power supply during peak load times
The breadboard can be very restrictive in space and in how to place these components, so I recommend creating this circuit as a separate module on a prototype board. When doing so, please keep these things in mind:
- You can solder a piece of a male connector row to the bottom of the connector board, that way you can put the module into the breadboard vertically.
- Ensure the capacitors are placed close to the step down regulator and the ESP8266 respectively.
- You can use 2 4-pieces of female connector rows as a base for the ESP8266 to sit in. That way you can easily remove it for programming purposes or replace it when broken.
Most ESP8266 come pre-programmed to a baud rate of 115200. Arduinos regularly struggle to communicate at such a baud rate over Serial buses and it is recommended to user a lower baud rate. Use a USB interface to manually set the baud rate of the ESP8266 to 9600. (All source code distributed in this repo assumes a baud rate of 9600.)
A power supply of 6 AA-batteries should mostly be sufficient to operate the ESP8266 in addition to all other components on the car. That being said, I have experienced situation where the ESP8266 was suddenly becoming unresponsive. I suspect this is due to the power supply not being able to supply high enough current during peak workload, so I recommend not spamming the module with HTTP requests and limiting the use to 1 request every few seconds to minimize the need for resets.
Use the USB shield to connect the USB adapter to the Arduino. You can run the cable underneath the base plate of the car and use tape to fix the cable and the receiver to the bottom of the plate.
Use the Arduino IDE to upload the program onto the Arduino and to read the output on the Serial connection via the IDE's Serial Monitor.
This project is using:
- the USB Host Shield Library 2.0 to connect to the XBOX Controller via the wireless adapter.
- the ESP8266_Simple library to operate the ESP8266 module.
The program consists of 3 basic modules that can be enabled and disabled before uploading the program to the Arduino:
- Controller: for remote controlling the car using an XBOX 360 controller
- GPS: for reading the car's GPS location
- WiFi: for spinning up a HTTP server on the car to interact with it over WiFi
You can enable and disable these modules on top of the program file. When enabling the WiFi module, you must also specify the SSID and password of the WiFi network to connect to.
- Both the USB Host Shield library and the ESP8266_Simple library are using the SoftwareSerial library to communicate with their respective modules. Unfortunately, while SoftwareSerial allows for specifying several Serial connections on different pins, as of now this library only allows for only one Serial port to be operated at a time. Especially the ESP8266_Simple library seems to struggle to maintain its internal state when a different SoftwareSerial port is being operated. Enabling this functionality would require a complete overhaul of the used libraries. To work around this, for now the GPS data is only read from the GPS module once before the ESP8266_Simple Serial connection is established.
- At the time of writing this, some of the used libraries are incompatible with the latest version of the Arduino AVR Boards board libraries used by the Arduino IDE. When running into issues while compiling or uploading the program, try downgrading the library version to version 1.6.20 in the IDE's board manager (Tools -> Board: "" -> Board Manager...).
- The controller module allows for remote controlling the cars movement using the D-Pad. The current implementation is very basic and might occasionally drop an input, but should be sufficient for demo purposes.
- The program is writing quite some information to the default Serial connection. You can use the Arduino IDE's Serial Monitor to debug the program if the car shows unexpected behavior. Note that the demo software used to display the car's IP address after establishing WiFi connection on the serial port, but due to some incompatibilities between the latest ESP8266 firmware and the latest Arduino libraries, we cannot easily do that right now. I recommend setting up the demo using a phone hotspot and reading the IP address from your phone as a fast way to get a connection and knowing the car's IP address.