Here are some step-by-step instructions for building a two-wheeled robot car that can be steered by your smartphone via Wifi.
Note: Some soldering is required to join the battery boxes together and also to connect the drive motors.
You will need the following parts to complete this project:
- Robot car chassis
- Battery box for 4x AA batteries - TWO of our 2x AA battery boxes
- An ESP8266 board like the NodeMCU.
- An L298N motor driver board.
- Jumper leads (female to male and female to female).
- Short pieces of hookup wire to connect the motors.
- Double sided tape, cable ties or other method of fixing boards and wires to the robot car chassis.
- First assemble the robot chassis; the kit we ship only requires a few screws to be tightened and the wheels to be put on; this should be fairly self explanatory. Do not fit the top acrylic panel as this makes it difficult to mount boards and the battery box later.
- Solder wires (approx 12cm in length) to both motors on the chassis, ideally different colours so you can tell them apart.
- Connect the motors to the L298N board as follows:
- If you're using our 2xAA battery boxes, first connect them in series by connecting the black wire from one to the red wire of the other. Make sure this connection is covered up with insulation tape or heat shrink tubing so that it does not short. Then connect the remaining black and red wires to the GND and +12V terminals of the L298N board, respectively.
- Using the same GND and +12V terminals, use two jumper leads to connect:
- GND on the L298N to GND on the NodeMCU board
- +12V on the L298N to VIN on the NodeMCU board
- Finally, use a set of 4 female to female jumper leads to connect D1, D2, D3 and D4 on the NodeMCU to IN4, IN3, IN2 and IN1 (in that order - so D1 goes to IN4, D2 to IN3 etc).
- Double check all the connections, especially the polarity. RED should always be +12V on the L298N or VIN on the NodeMCU.
- Insert batteries (4x AA) and check that there is a red light on the L298N. Depending on your NodeMCU board it may not have any LEDs that light up at this stage. Feel the various boards to ensure they do not get warm to the touch. If they do - power off immediately and check your connections.
Any robot needs some code to drive it; in this case we'll be riding on the coat-tails of a brilliant smartphone app called Blynk. This app lets you design a custom user interface on your phone that can then be used to interface with all sorts of IoT devices such as the ESP8266/NodeMCU board we're using.
- Install Blynk on your phone or tablet. You'll need to create an account to access the app.
- Create a new project, give it a cool name like "Terminator V1". Blynk will email you an auth token which you will need later.
- In the project workspace, tap anywhere to add a control. Select the Joystick control.
- Select the following options:
- Split/Merge switch should be set to MERGE
- Pin should be set to Virtual - V1
You should have a screen that looks like this now:
- Connect the NodeMCU to your computer with a USB cable.
- In the Arduino IDE, open up our starter ino file.
- Edit the file to add your auth token, your wifi name and your wifi password.
- Search for and install the Blynk library. Do this via the Sketch menu > Include Library > Manage Libraries. Search for Blynk and install it. If you haven't got the ESP8266 libraries installed, you'll need to set up your development environment first.
- Flash the code to your NodeMCU board.
- Open Blynk and hit the Play button (top right).
You should now be able to move your car around using the joystick on the screen.
Well, sometimes things go wrong. Here are a few things you can try to troubleshoot:
- Check the Blynk debug output. While the NodeMCU is connected to your PC, click Tools > Serial Monitor in the Arduino IDE. You should see some status messages from Blynk.
- Putting 5V on the L298 IN1, IN2, IN3 and IN4 pins (each in turn) should make your motors spin in each direction. If this does not work, check your motors and polarity of the power connections.