Introduction: WiFi Stunt Car
Welcome to my fourth instructable (since a looong time) !
This one is about modifying a Stunt (or reversible/rugged) RC car to be able to be controlled by an Android device via wi-fi.
The RC car that will be used in this instructable is a chinese rugged reversible ''stunt'' car.
It is radio controlled via FM modulation (49 or 27MHz depending on version).
After the tutorial, the car WILL NOT work with the original remote, but only with an Android device (phone/tablet).
The RC car WILL be modified (i.e. control board ripped out) so please read the instructable ENTIRELY and then decide if you are willing (or have the skill) to modify your RC toy.
Although we will be using this specific model, this instructable can be applied to any RC car with ''tank-style'' control.
Also, if you are building it and are stuck or have any questions, feel free to put it in the comments below !
And now, let's proceed to the very first step: Required stuff
Step 1: Required Stuff
- Soldering iron w/ solder wire
- (Optional) hot glue gun
- Cutting pliers and/or hobby knife
- Phillips screwdriver (medium)
- ESP8266 w/ programming board: I'm using this one (WeMos D1 Mini)
- L298N H-bridge module
- RC Stunt Car: http://goo.gl/ZhGWfm
- Female-to-female wire jumpers
- Micro-usb cable (standard phone charging cable)
- Android phone or tablet (Android 4 or newer)
Total cost of parts should be under (or around) 50$
- Arduino IDE (a recent enough version to have ''board manager'')
Step 2: Removing Existing Electronics
In this step we are going to remove the original control and drive electronics (FM) of the car.
Plug in your soldering iron, allowing it to heat up during this step
First, before doing any modifications, we have to disconnect and remove the battery (bonus: you can charge it while following the tutorial and you'll be able to play right away):
- Put the car on its back and twist the two black ''knobs'' or ''bars'' (see picture 1).
- The cover should pop out and reveal the battery compartment
- Disconnect the battery and put it in charge (with the supplied charger of course)
Then, remove the four screws (picture 1) on the bottom, flip the car, and lift carefully the grey cover (car's body)
You should now see the inside of the car (picture 2) with RC/drive electronics on the back, the two motors in the middle and the antenna going to the front.
- Remove the antenna by removing the first screw (center of the antenna), then the second one (see picture 3)
- Using your soldering iron, very carefully desolder the motor wires (the thick wires) from the control board (pic. 3)
- (You can apply a tiny bit of your solder (from the spool) to help melt the contacts faster)
- The thin wires are just connected to the leds, so you can just cut them from the board if you don't feel like desoldering them
- Once you have desoldered the wires from the board, remove the last screw (pic. 3) and remove the board
- Now, using your cutting pliers, cut the plastic antenna pole to make room for the WiFi module in the front (pic. 4)
Step 3: Preparing the New Electronics
In this step we're going to connect the new electronics to the motors and battery.
First, we have to cut and tin the GND wire going to the WiFi module:
- Take a (preferably black) female jumper cable, and cut it right behind the connector (only one side): pic. 1
- Using the hobby knife, carefully remove the plastic coating and gently twist the wire on itself
- Using a ''third hand'' tool or a vice, tin the wire by melting a little bit of solder on it (pic. 2)
- Now, do the same thing with a Red female jumper cable
- You can now switch off your soldering iron
Power and motor wiring (using the screwdriver to tighten the ports):
(The h-bridge's port labels are on the back)
- Connect the +12V from the H-bridge to the Red wire coming from the car's power switch
- Put the black cable you just tinned AND the Black wire from the car (not the one from the motor) in the H-bridge's GND port, tighten well with the screwdriver so they don't slip out
- Connect the red cable you just prepared in the H-bridge's +5V port
- Connect the Red wire from the first motor to OUT4 on the h-bridge
- Black wire from first motor to OUT3
- Yellow wire from second motor to OUT1
- Blue wire from second motor to OUT2
WiFi module wiring (using the jumper cables):
- IN1 (h-bridge) --- D1 (WiFi module)
- IN2 --- D2
- IN3 --- D3
- IN4 --- D4
- Connect the red jumper cable coming from the h-bridge (+5V) to 5V on the WiFi module
- Connect the black jumper cable coming from the h-bridge (GND) to G on the WiFi module
Now, before connecting either the battery, or the usb cable to the wifi module, CHECK your connections! You can use the pictures 3, 4 and 6 for reference.
Step 4: Flashing the WiFi Module
Now is the time, if you haven't already, to download and install the Arduino IDE
- Once installed, open preferences File > Preferences, and paste the following url in the Additional Boards Manager URLs box:
- Click OK to close the preferences window
- Go to the boards manager: Tools > Board > Boards manager
- Search for ESP8266 and install the latest version of ESP8266 Community (the install will take some time)
- Once installed, select the correct WiFi module: Tools > Boards > WeMos D1 R2 & Mini
- Close the Arduino IDE and extract the WifiStunt.zip file included on this page in the Arduino folder located in My Documents, Documents, (or your home directory if you're on linux) on your computer
- Open Arduino IDE, select the WifiStunt sketch File > Sketchbook > WifiStunt
- Connect the Wifi module to your computer via the microusb cable
- Flash the module with the code Sketch > Upload
- Check if the upload worked by searching for Wifi networks (with your PC or phone/tablet): a new wifi network named WifiStunt should have appeared
If you're having problems installing the ESP8266 addon for Arduino, there is a tutorial from SparkFun here with pictures
Step 5: Final Step
The RC car now works via WiFi with a very simple UDP protocol (only two bytes).
I have ''coded'' (more like cobbled together) an Android app that is able to control the car with the phone's accelerometer (e.g. tilt the phone in a direction to make the car go that way), and launch three different ''stunts'' or sequences of motor movement (defined in the Arduino code) with three large buttons.
To control the car:
- Unplug the WiFi module from your computer, connect the Battery to the car (and close the battery door)
- Install the WifiStunt_install.apk on your phone
- Disable mobile data (3G/4G)
- Connect to the WifiStunt wifi network: password is stuntman
- Launch the app
- Hold the phone level and switch on the car (I would suggest holding the car in your hand for testing first)
- Tilt the phone in the direction where you want the car to go
- Press the 1, 2 or 3 buttons to launch the corresponding stunts/sequences defined in the Arduino code
Once the car works, you can secure the WiFi module like in the picture, put back the car's body on and put the screws back in place.
Have fun !
Step 6: UDP Protocol
For those interested, I have included the Android studio project/source code (in tar.gz, you can unzip it with 7-zip on windows). The relevant methods are included in the methods.java file
The protocol is comprised of two bytes:
- The left byte controls the steering direction: left is '1', right is '2', still is '3'
- The right byte controls the direction (forward/backward): forward is '1', backward is '2', still is '3'
- For the three stunts, send '44', '55' or '66' for stunts 1, 2 and 3
- The car automatically stops 220ms after the last packet is received (the absence of data means 'stop' to the car)
- The port is 42042, IP is 192.168.4.1
We have a be nice policy.
Please be positive and constructive.