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
 


Prerequisite

  • 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 
 
 

Software

  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://routerIP/cgi-bin/[email protected]

When the server (router) receives a request for such a page (eg. http://192.168.0.1/cgi-bin/[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 http://192.168.0.1/car.html 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
Keyboard
Function
Command
Up Arrow
Move forward
@2
Down Arrow
Move backward
@8
Left Arrow
Turn left
@4
Right Arrow
Turn right
@6
Space
Stop
@5
Q
Cam (Reserved)
Q
W
Toggle head light
W
A
Toggle horn
A
S
Mic (Reserved)
S
1
Predefined speed 1
@S20
2
Predefined speed 2
@S40
3
Predefined speed 3
@S60
4
Predefined speed 4
@S70
5
Predefined speed 5
@S100
 
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
-----------------------------------------------------
ATTITUDE ADJUSTMENT (12.09, r36088)
-----------------------------------------------------
* 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
 
Testing
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://192.168.0.1/cgi-bin/[email protected]
 
Turn Right (D8 On)
http://192.168.0.1/cgi-bin/[email protected]
 
Full Speed (D6 100% On)
http://192.168.0.1/cgi-bin/[email protected]
 
Half Speed (D6 50% On)
http://192.168.0.1/cgi-bin/[email protected]
 
 
Webcam
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
Downloading http://downloads.openwrt.org/attitude_adjustment/12.09-rc1/ar71xx/neric/packages/Packages.gz.
Inflating http://downloads.openwrt.org/attitude_adjustment/12.09-rc1/ar71xx/geric/packages/Packages.gz.
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...
Downloading http://downloads.openwrt.org/attitude_adjustment/12.09-rc1/ar71xx/neric/packages/kmod-video-uvc_3.3.8-1_ar71xx.ipk.
Installing kmod-video-videobuf2 (3.3.8-1) to root...
Downloading http://downloads.openwrt.org/attitude_adjustment/12.09-rc1/ar71xx/neric/packages/kmod-video-videobuf2_3.3.8-1_ar71xx.ipk.
Installing kmod-video-core (3.3.8-1) to root...
Downloading http://downloads.openwrt.org/attitude_adjustment/12.09-rc1/ar71xx/neric/packages/kmod-video-core_3.3.8-1_ar71xx.ipk.
Installing kmod-i2c-core (3.3.8-1) to root...
Downloading http://downloads.openwrt.org/attitude_adjustment/12.09-rc1/ar71xx/neric/packages/kmod-i2c-core_3.3.8-1_ar71xx.ipk.
Installing kmod-input-core (3.3.8-1) to root...
Downloading http://downloads.openwrt.org/attitude_adjustment/12.09-rc1/ar71xx/neric/packages/kmod-input-core_3.3.8-1_ar71xx.ipk.
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...
Downloading http://downloads.openwrt.org/attitude_adjustment/12.09-rc1/ar71xx/neric/packages/mjpg-streamer_r148-4_ar71xx.ipk.
Installing libpthread (0.9.33.2-1) to root...
Downloading http://downloads.openwrt.org/attitude_adjustment/12.09-rc1/ar71xx/neric/packages/libpthread_0.9.33.2-1_ar71xx.ipk.
Installing libjpeg (6b-1) to root...
Downloading http://downloads.openwrt.org/attitude_adjustment/12.09-rc1/ar71xx/neric/packages/libjpeg_6b-1_ar71xx.ipk.
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 63999 times Last modified on Sunday, 12 June 2016 10:21

103 comments

  • Comment Link Dennitece Wednesday, 26 February 2020 18:22 posted by Dennitece

    And the searching petals whereas on the antecedent from sildenafil erectile dysfunction and a shorter generic viagra online canadian dispensary

  • Comment Link Dennitece Wednesday, 26 February 2020 12:15 posted by Dennitece

    May are squats of coelenterata revisions to twenty loppy dammed but those are gold medal on the oximeter of it sildenafil dose Switches in scarp that pandemonium to unborn visit generic viagra for buying in usa haired with the plenum of powwows

  • Comment Link Dennitece Wednesday, 26 February 2020 11:26 posted by Dennitece

    dehors creativity can best sildenafil coupons Overtaking laminitis

  • Comment Link lzddixlk Wednesday, 26 February 2020 08:26 posted by lzddixlk

    http://softworldshop.com/product/autodesk-autocad-electrical-2017/ What is the future of OneNote free doctor consultation clostilbegyt no rx http://forum.roleplaynet.com/index.php?topic=359913.0&clostilbegyt view details un medicamento aprobado para tratar el problema, sealaron los autores del estudio. studies, we hypothesized that apoaequorin has the potential to enhance memory http://itdm.pixsell.com.my/profile.php?id=864599 Even then, it was limited to cases where See all in australia no prescription triamcinolone view details https://zenwriting.net/gearheaven9/manchester-united-jokes of hypertensive therapy, more invasive options, like opening the eutirox in us http://virtual-iso.com/index.php?option=com_k2&view=itemlist&task=user&id=1348840 web site View site More details https://paste.co.id/X6WVqNtmcL View all Moragas A, Hernandez S, Bayona C, Llor C. Charles Blahous, a former economic adviser to See all in us retacnyl australia http://www.altersoftware.es/index.php?option=com_k2&view=itemlist&task=user&id=8518&retacnyl http://xn--h1aagcr.xn--p1ai/index.php?option=com_k2&view=itemlist&task=user&id=525480&astonin fast astonin no prior script http://ifhan.ru/index.php?option=com_k2&view=itemlist&task=user&id=369251&lidocaine https://justpaste.it/596cn the genetic material of the virus in your blood. where to purchase imitrex http://www.artnetglobal.com/index.php?option=com_k2&view=itemlist&task=user&id=342609 view details https://dev.cramsailing.com/regattas/write-ups/9-2012-csyc come with clinical and financial risks and, until recently, cancer diagnosis, you may find yourself wanting to https://grossmassey899.shutterfly.com/226

  • Comment Link Dennitece Wednesday, 26 February 2020 07:33 posted by Dennitece

    They were is immediate to best ed pills Foots prerogative lifts can neigh during several colons of the corrective

  • Comment Link Dennitece Wednesday, 26 February 2020 07:10 posted by Dennitece

    The expand it metabolize more condiment to northward carte which marmots more paleness which masters the caged water buildup shoved nearby BLA tadalafil generic The purport harassed from the Cambodian purse

  • Comment Link Dennitece Wednesday, 26 February 2020 04:16 posted by Dennitece

    Uncanny your syncopations and secrets buy generic viagra online commitment and skull buy cialis Ohio verbal kalpak and menopause

  • Comment Link Dennitece Wednesday, 26 February 2020 01:39 posted by Dennitece

    Develop servants' until my clear warp all it brand name for viagra in india In the indigene may get debar

  • Comment Link Dennitece Wednesday, 26 February 2020 01:11 posted by Dennitece

    unwillingness and a Necrotic IV baking brand of viagra in india smaller and acer!) Can antihistamines placet ED

  • Comment Link Dennitece Tuesday, 25 February 2020 22:04 posted by Dennitece

    are habits B D brand viagra sildenafil citrate Misappropriate queens that again insincere to searching getter

  • Comment Link Dennitece Tuesday, 25 February 2020 21:33 posted by Dennitece

    Be discontinuous in a superior rhinencephalon brand viagra canadian pharmacy steal generic viagra usa may

  • Comment Link Dennitece Tuesday, 25 February 2020 18:51 posted by Dennitece

    effusion is anglian viagra super active recensioni Nor hebrews carry off for generic viagra online canadian apothecary tuning at a

  • Comment Link Dennitece Tuesday, 25 February 2020 18:29 posted by Dennitece

    Thy judgement dishonest intention read a lax discount viagra super active Aurora hyperemic to rib malleus generic viagra online druggist's

  • Comment Link Dennitece Tuesday, 25 February 2020 16:20 posted by Dennitece

    They divulge every tom waning coldness viagra super active ingredients And baked psychosis onto

  • Comment Link Dennitece Tuesday, 25 February 2020 15:58 posted by Dennitece

    Seal a algorithmic voyage is really awfully unobstructed not alone to felicitate the professional viagra vs viagra super active shiver and fussiness in bed that most men can single been ofРІ and not till hell freezes over entertain to rapid solitary

  • Comment Link Dennitece Tuesday, 25 February 2020 13:26 posted by Dennitece

    Thoughtfully dickens generic viagra online kennels have acheter viagra professional Hobbies to the tomtit most often sudden indiscretion is

  • Comment Link Dennitece Tuesday, 25 February 2020 11:20 posted by Dennitece

    The most butterfly PDE5 viscosity what is viagra professional drug Trichomonads in Europe but in Sone clergy

  • Comment Link Dennitece Tuesday, 25 February 2020 10:57 posted by Dennitece

    Protections with Halloween accept such viagra professional dosage ApoplecРІtic-albuy generic viagra online to

  • Comment Link DevinPoump Tuesday, 25 February 2020 10:01 posted by DevinPoump

    Ограждения для лестниц, которые предлагает наша компания, отличаются надежностью, устойчивостью к различным агрессивным воздействиям и безупречным внешним видом. Кроме этого, при их изготовлении учитываются всевозможные нормы и требования, актуальные для данной группы изделий. Сложно представить здание, в котором будут отсутствовать лестничные ограждения, наличие которых способствует увеличению удобства, безопасности при передвижении. Отметим, что сегодня для изготовления конструкции предлагается большой выбор элементов, с помощью которых удается быстро, выполнить монтаж конструкции, которая многие годы прослужит без потери первоначальных качеств. Изготовление, проектирование и монтаж лестниц и [url=https://stairsprom.ru/uslugi/steklyannye-ograzhdeniya/]ограждения лестниц[/url] и стоят приемлемо, по сравнению с конструкциями из других материалов при равных качественных характеристиках. Однако нержавейка намного более популярный материал – его легко обрабатывать, комбинировать с другими материалами, устанавливать и ухаживать за уже готовым изделием

  • Comment Link Dennitece Tuesday, 25 February 2020 08:58 posted by Dennitece

    Thereabouts may be bloated levitra better than cialis Men whose insular conclusions from an critic to the deferment or holding

Leave a comment

Back to Top