A couple of months ago we set ourselves a project to create an internet-connected RC track where people from anywhere in the world could drive real 1:43 scale RC cars over the internet in real-time – even when thousands of miles away from our race track here in Helsinki, Finland. See the build video:
One of the biggest challenges we encountered throughout this project was figuring out a way to wirelessly control the RC cars from a remote computer.
For this project, we picked 1:43 scale SIKU Racing RC cars. We decided to go with them because seem to be quite durable, which will be perfect for endless online sessions, where people will test the cars to their full potential.
As we decided to go with the small factor RC cars, we didn’t really want to do any custom modifications to the internal car electronics. For that reason, we initially planned to try to use the car’s original boards and to connect and control the cars using the out-of-the-box controllers.
We therefore dismantled one of the original RC car controllers and analyzed the board inside it. It was a very standard 2.4Ghz RC controller, which would receive analog commands from the players’ input—pressed buttons, rotator wheel, speed trigger—and then send them to the RC car.
To connect the RF controllers to our game engine, we decided to use a Raspberry Pi Model B3+ as our server to receive and send the commands.
We then connected an Arduino board (JOY-iT Mega 2560 R3) to the Raspberry Pi, to be able to send current signals to the RC controllers. We went with this board because it allowed us to send signals to all 12 controllers from a single Arduino board.
As mentioned, these controllers receive and send analog signals, so we added a digital to analog signal converter to the architecture.
We then soldered the corresponding cables to the controller pins and created a simple program that sends the commands with the right values. See the code here.
While this concept worked well when we tested it with just one car, we encountered multiple issues when we ran a set of 6 cars simultaneously.
Sometimes the controllers would lose the connections to the cars, or would somehow send a command signal to a completely different car. We had high hopes for this solution, but as but as we wanted to hook up more than just 1 or 2 cars at a time, it wasn’t the one for us.
We went back to the drawing board and started looking into potentially replacing the car’s original electronics.
When we dismantled the car, the electronics were quite simple. There were DC 2 motors connected to a basic electronics board that would transmit and receive RF commands using an nrf24l01 radio frequency controller. They were attached using a simple JST plug and could be easily disconnected from the electronics board, without any unsoldering or additional tinkering.
Now, as mentioned, the cars that we decided to use were pretty small, and so were the electronics boards inside them. For that reason, our choice for a replacement board was pretty limited—and the board needed:
- a Wi-Fi chip to connect to the local network
- to be able to run a UDP server to receive the steering and rotor motor commands
- to have 2 motor drivers to run the DC motors
- support hardware for 2 PWM outputs of multiple kilohertz
- an analog in port to measure the potentiometer values used for the servo
- flash memory to store cars’ specific parameters
- to fit inside the car based on the physical constraints.
After some quick googling, we found a couple of ESP-8266 based boards that could be potential candidates.
We decided to go with the Wemos D1 mini pro as it had the perfect dimensions to replace the car’s original electronics board. The Wemos D1 mini pro, however, didn’t address the hardware PWM or the motor driver requirements by itself.
To address the missing features, we added a Wemos motor shield that is easily attachable with pins in a hat style manner. This motor shield has an STM32 based microcontroller that controls a Toshiba TB6612 motor driver through its hardware PWM outputs. The communication between the ESP-8266 and the STM32 happens via the I2C bus with a simple protocol to control each motor separately.
Here’s the initial prototype with the Wemos board and motor shield. As you can see, there was a lot of soldering involved,
As we didn’t want to do a lot of soldering to connect the RC car’s motor and sensor cabling to the car, we printed a custom PCB with all of the plug and play connectors.
We ended up having a 3-layered board architecture, that just managed to fit within the car’s internal dimensions.
Now comes the software part…
The interesting thing we found with these cars, is that the car steering motor wasn’t a servo motor, but instead a DC motor that used a potentiometer to define the steering angle.
Technically, a potentiometer and a DC motor are the 2 elements of a servo, so we had to implement a bit of custom coding to make them work together as a single unit.
To be able to communicate with the car, we developed a UDP server on the Wemos ESP8266 board. This allowed us to read signals from the control PC to handle the steering and rotating of the motors, while also reading the status of the car.
While all the cars we used had the exact same hardware setup, each motor would work very differently when sending the same values. So, we hand calibrated each car to identify what values work best, and then stored these parameters within the Wemos board’s flash memory. The UDP server and a simple command-line calibration tool which acts as a UDP client were used to do the calibration by hand.
As we didn’t want to have to dismantle the cars every time we’d want to flash updated values or parameters, we also implemented OTA update support for these ESP boards. This allows us to quickly modify, test, and improve the car controls with just a couple of lines of code.
And that’s the whole setup!
By using the ESP-8266 based Wemos board, we were able to overcome the connectivity issues we had with the RF controllers while gaining much better access to the in-car parameters for easy modifications, giving us full access to the tuning of the car. These Wemos boards are a great pick when size is a serious constraint. They are an off-the-shelf solution that can fit into even the tiny dimensions of a 1:43 scale RC car.
This was definitely a more challenging project than we expected, but it sure was an amazing learning for the team. Stay tuned for more projects to come!
You can test the setup and the final result yourself, by playing the game online.