Saturday, 15 February 2014 20:38

Wireless Router Remote Control Car

This is my first RC car control by an Arduino and a wirless router running OpenWRT. There are many OpenWRT supported routers, I'm using a TP-Link TL-MR3020 3G/4G Wireless N Router for this project since it is very slim, low power consumption and it is cheap.


RC car features

  • A webcam, the car can be driven without line of sight
  • A horn so that you can honk at people.
  • LED Headlights attached to the front of the car
  • Two wheel drive motor
  • Windows GUI application or web interface
  • Future Additions: Control by a smartphone (Android & IOS)


Wheel Drive Layout

This project work with the following wheel drive layout.

Wheel drive layout


  • If you do not have SSH client, you need to install one. I'm using PuTTY

  • WinSCP (Windows Secure Copy)

  • A router flashed with OpenWRT, please read here on how to flash the OpenWRT to a TP-Link TL-MR3020 wireless 3G/4G router

  • Make sure the router have Internet connection (see below) as it will download the packages from OpenWRT repository


Setup Internet Connection for Router

Connect your PC to router as shown in figure below. After flasing OpenWRT to the router, make sure you have setup the internet connection.

Wireless router connection diagram 


  1. Arduino sketch runs on Arduino (Arduino_Wifi_Car folder)
  2. Shell script (SH script) runs on the router (www folder)
  3. The Delphi Wifi_car client application (Delphi Wifi Car folder) or the web interface (www folder) run on computer
1. Arduino_Wifi_Car folde: Arduino firmware, upload this sketch to Arduino
2. www folder: Web GUI and Shell Script to control RC car.
Transfer the www folder to router root directory by using WinSCP as shown in figure below
www folder
You don't have enough permission to run the shell script ("car") from /www/cgi-bin folder by default. Please change the permission to 0755 as shown in figure below.
Setting permission
3. Delphi Wifi Car folder: An RC car client application running on Ms Window, contains source code written in Borland Delphi 7.
Delphi files 

Arduino Code

Upload the following sketch to Arduino

The serial data send from router to Arduino must start with a special character such as @ and follow by the command (eg. @2), the router may not work correctly (may cause delay) without the start character.



Shell Script run on Router

The Shell Script is just three lines of code, it act as the interface between router and Arduino. Name this file as "car" and save it to router /www/cgi-bin 

When a request is received by the server (router)  for CGI, the parameters it receives are through QUERY_STRING environment variable. QUERY_STRING retrieves the string that follows the ? delimiter in the URL for a query, an URL containing a query string is as follows:

http:[email protected]

When the server (router) receives a request for such a page (eg. http:[email protected]), it will write the command (@2) to  /dev/ttyUSB0 port (it is COM1 in Ms Windows) 


Lua Script run on Router

Lua is come with OpenWRT. If you know Lua programming, you can use it to replace Shell Script.


GUI Interface

The web interface makes it easy to control the RC car, the program is loaded from the router hence there is not necessary to install an application to your computer. To launch the web interface, enter from browser as shown in figure below.
Web interface
Files structure
car.html: The main program, load the external js & css files and implement image button onClick events. 
car.js: Consists of javascript function
car.css: Layout options such as image postion, colors, and fonts.
images folder: All the images which shows on the web interface
codebase folder: consists of javascript componet to create slider (dhtmlxSlider), more about dhtmlxSlider is available here.
cgi-bin folder: The Shell Script is stored here
Keyboard shortcut
The keyboard event is stored in the car.js file, you can modify it if necessary
Up Arrow
Move forward
Down Arrow
Move backward
Left Arrow
Turn left
Right Arrow
Turn right
Cam (Reserved)
Toggle head light
Toggle horn
Mic (Reserved)
Predefined speed 1
Predefined speed 2
Predefined speed 3
Predefined speed 4
Predefined speed 5
Besides the Web GUI, I wrote another client application which runs on MS Windows computer, you can compile the source code in Borland Delphi 7.
Wireless Router RC car client application


Interface between Arduino and Router

The router needs to install USB-SERIAL driver to work with Arduino, please select the correct serial driver for your Arduino.

  • Run PuTTY and SSH ro router as shown in figure below

SSH ro router


  • Enter root as login and enter your router password as shown in figure below

login as: root
This email address is being protected from spambots. You need JavaScript enabled to view it.. 0.1;s password:

BusyBox v1.19.4 (2013-03-14 11:28:31 UTC) built-in shell (ash)
Enter 'help' for a list of built-in commands.

_______ ________ __
| |.-----.-----.-----.| | | |.----.| |_
| - || _ | -__| || | | || _|| _|
|_______|| __|_____|__|__||________||__| |____|
|__| W I R E L E S S F R E E D O M
* 1/4 oz Vodka Pour all ingredients into mixing
* 1/4 oz Gin tin with ice, strain into glass.
* 1/4 oz Amaretto
* 1/4 oz Triple sec
* 1/4 oz Peach schnapps
* 1/4 oz Sour mix
* 1 splash Cranberry juice
[email protected]:~#

    • Update list of available packages and stores it on your router RAM partion (make sure your have internet connection
      opkg update

  • If you are using Arduino Demilanove or FTDI usb-serial
    opkg install kmod-usb-serial-ftdi

  • If you are using Teensy / Arduino Uno / Arduino Mega
    opkg install kmod-usb-acm

  • If you are using PL2303 based USB/serial adapters
    opkg install kmod-usb-serial-pl2303

  • If you are using CP201x based USB/serial adapters
    opkg install kmod-usb-serial-cp210x

Verify router is able to communicate with Arduino

Plug in Arduino to the router USB port and restart the router, wait until the router is ready then enter command below

dmesg | grep -i usb

It should similar to this: 
[email protected]:~# dmesg | grep -i usb
[ 9.040000] usbcore: registered new interface driver usbfs
[ 9.040000] usbcore: registered new interface driver hub
[ 9.050000] usbcore: registered new device driver usb
[ 10.240000] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
[ 10.250000] ehci-platform ehci-platform: new USB bus registered, assigned bus number 1
[ 10.310000] ehci-platform ehci-platform: USB 2.0 started, EHCI 1.00
[ 10.310000] hub 1-0:1.0: USB hub found
[ 10.590000] ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
[ 10.740000] usbcore: registered new interface driver usbserial
[ 10.740000] USB Serial support registered for generic
[ 10.740000] usbcore: registered new interface driver usbserial_generic
[ 10.750000] usbserial: USB Serial Driver core
[ 10.900000] USB Serial support registered for FTDI USB Serial Device
[ 10.900000] usbcore: registered new interface driver ftdi_sio
[ 10.910000] ftdi_sio: v1.6.0:USB FTDI Serial Converters Driver
[ 11.040000] usbcore: registered new interface driver uvcvideo
[ 11.050000] USB Video Class driver (1.1.1)
[25677.400000] usb 1-1: new full-speed USB device number 2 using ehci-platform
[25677.560000] ftdi_sio 1-1:1.0: FTDI USB Serial Device converter detected
[25677.570000] usb 1-1: Detected FT232RL
[25677.570000] usb 1-1: Number of endpoints 2
[25677.580000] usb 1-1: Endpoint 1 MaxPacketSize 16384
[25677.580000] usb 1-1: Endpoint 2 MaxPacketSize 16384
[25677.590000] usb 1-1: Setting MaxPacketSize 64
[25677.600000] usb 1-1: FTDI USB Serial Device converter now attached to ttyUSB0
The first thing is to disable auto reset, otherwise the Arduino will be reset automatically each time data is sent from router to Arduino USB-SERIAL port. Here listed two simple way to disable the auto reset:
Method 1: Connect a 120ohm resistor between +5V and Reset
Method 2: Connect a 1uF capactior between Gnd and Reset, negative to Gnd and positive to Reset

Disable auto reset

Plug in the Arduino to the router via USB and use the HTTP GET method to control Arduino from browser.

Syntax: http://routerIP + /cgi-bin/car? + command 

Connect three LED to Arduino, first LED to D9, second LED to D10 and third LED to D6. Launch a browser and enter the URL as below:

Turn Left (D10 On)
http:[email protected]
Turn Right (D8 On)
http:[email protected]
Full Speed (D6 100% On)
http:[email protected]
Half Speed (D6 50% On)
http:[email protected]
You must install webcam driver before you can use it with the router.
  • Make sure you have Internet connection as it will download the packages from OpenWRT repository
  • SSH to the router
  • Install the following packages

opkg update
opkg install kmod-video-uvc 
opkg install mjpg-streamer

It should look like this

[email protected]:~# opkg update
Updated list of available packages in /var/opkg-lists/attitude_adjustment.
[email protected]:~# opkg install kmod-video-uvc
Installing kmod-video-uvc (3.3.8-1) to root...
Installing kmod-video-videobuf2 (3.3.8-1) to root...
Installing kmod-video-core (3.3.8-1) to root...
Installing kmod-i2c-core (3.3.8-1) to root...
Installing kmod-input-core (3.3.8-1) to root...
Configuring kmod-i2c-core.
Configuring kmod-video-core.
Configuring kmod-input-core.
Configuring kmod-video-videobuf2.
Configuring kmod-video-uvc.
[email protected]:~# opkg install mjpg-streamer
Installing mjpg-streamer (r148-4) to root...
Installing libpthread ( to root...
Installing libjpeg (6b-1) to root...
Configuring libjpeg.
Configuring libpthread.
Configuring mjpg-streamer.
[email protected]:~#

Enable video streaming
Video streaming is diabled by default. To enable video streaming, edit /etc/config/mjpg-streamer and change option enabled "0" to option enabled "1" 

config mjpg-streamer core
         option enabled "1"
         option device "/dev/video0"
         option resolution "640x480"
         option fps "5"
         option www "/www/webcam"
         option port "8080"

Restart the router, you are ready to stream the video. Please read here for more information.

Arduino PCB

I'm using a SN754410NE H-bridge to control two DC motors, Arduino D6 (ATMega328 pin 12)  is a PWM pin, it is connect to the H-bridge enable pin in order to control the motor speed. Please note that the Arduino D11 (ATMega328 pin 17) is not solder, pleaase leave it no connection unless you want to use two different motor speed.
Arduino PCB 
The Arduino is running  8MHz internal clock (without 16MHz crystal), read here for more about 8MHz Arduino
Schematic: Arduino H-Bridge
With this Arduino board, you must connect it to USB-Serial adapter and then plug in to the router via USB. It is not neccessary to disable auto reset since there is no auto reset designed in the board.
USB-Serial adapter 
As shown in figure above is a Prolific PL2303 USB-Serial adapter,  please run opkg install kmod-usb-serial-pl2303 to install the driver.
To be continue.......
Read 30375 times Last modified on Sunday, 12 June 2016 10:21


  • Comment Link admin Monday, 12 December 2016 20:41 posted by admin

    The horn is just an ordinary buzzer and there is no Audio signal processing for this project.

  • Comment Link Jmpv Sunday, 11 December 2016 12:03 posted by Jmpv

    Great project. How to get two way audio?

  • Comment Link admin Wednesday, 24 August 2016 20:50 posted by admin

    It causing delay when getting status from Lua. I would suggest to use Shell Script, please refer to "Shell Script run on Router" on this article.

  • Comment Link telyadi Wednesday, 24 August 2016 17:12 posted by telyadi

    OK, and how the lua script for serialin in car.lua (combine with existing serialout) ?

  • Comment Link admin Wednesday, 24 August 2016 09:34 posted by admin

    You need to use Ajax (xmlhttpPost), please refer to the source code (car.js).

  • Comment Link telyadi Monday, 22 August 2016 09:22 posted by telyadi

    how to add some status (serial in) in the web GUI ?

Leave a comment