How to build a smartphone controlled robot car

Posted by David Husselmann on

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.

Parts

You will need the following parts to complete this project:

Assembly

  1. 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.

  2. Solder wires (approx 12cm in length) to both motors on the chassis, ideally different colours so you can tell them apart.

  3. Connect the motors to the L298N board as follows:


  4. 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.

  5. Using the same GND and +12V terminals, use two jumper leads to connect:
    1. GND on the L298N to GND on the NodeMCU board
    2. +12V on the L298N to VIN on the NodeMCU board

  6. 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).

  7. Double check all the connections, especially the polarity.  RED should always be +12V on the L298N or VIN on the NodeMCU.

  8. 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.

Software

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.

  1. Install Blynk on your phone or tablet.  You'll need to create an account to access the app.
  2. Create a new project, give it a cool name like "Terminator V1".  Blynk will email you an auth token which you will need later.
  3. In the project workspace, tap anywhere to add a control.  Select the Joystick control.
  4. Select the following options:
    1. Split/Merge switch should be set to MERGE
    2. Pin should be set to Virtual - V1

      You should have a screen that looks like this now:



  5. Connect the NodeMCU to your computer with a USB cable.

  6. In the Arduino IDE, open up our starter ino file.
  7. Edit the file to add your auth token, your wifi name and your wifi password.
  8. 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.
  9. Flash the code to your NodeMCU board.
  10. 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.

Troubleshooting

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.

Happy hacking!

 


Share this post



← Older Post