WiFi R/C Car With IP Cam
Posted: January 4, 2013
Since the entire office at work is covered with WiFi, I figured it would be fun to build an R/C car that I could control from my netbook using a standard PC game pad with an FLTK app and a camera mounted on to the top. Since POV R/C car cameras tend to be pretty expensive and have probably a fairly limited range in a building I went searching for a cheapo IP camera that could also use the WiFi of the building. I found this TRENDnet TV-IP551W 802.11g camera for under $50 which I was able to make run on the car's battery.
Update January 13, 2010: Someone logged on my chat server last night to ask what kind of car I used for this project. Sorry dude, I was asleep when you logged on. If you're reading this, the car is a Rising Fighter and I got it from Tower Hobbies. The car comes in pieces and as I was putting together I was quite unhappy thinking to myself that if I had to do this again to make sure the car comes already assembled :). Other than that it's actually a really neat car. My only problem now is on Friday I was driving it around the office again and bent part of the steering system when I crashed :(. Owell :).
Related Projects @mikekohn.net
The R/C car came with a speed controller, so I decided to keep that part, but remove the radio part. This simplifies my circuitry quite a bit since I don't have to make an H-bridge as I did with my previous R/C car. The signalling and code that controls the steering is also now identical to the motor. The code is pretty simple, using the MSP430G2553's timer module I send a pulses out P2.0 and P2.1 between 1ms and 2ms every 20ms. If the signal is at 1.5ms on P2.0, the steering is centered while 1ms and 2ms (and the numbers in between) move the wheels left or right. If the signal on P2.1 is 1.5ms the car is stopped while 1ms and 2ms is full speed forward or reverse. The length of these pulses is changed when it receives commands over the UART. If the UART receives no command for something like 400ms, the car centers the steering and stops the car. For the heck of it I threw a buzzer on P2.2 for a car horn.
The commands over the UART as follows:
For a radio unit I found this Roving Networks WiFi module from SparkFun. This little module is pretty easy to configure. I just connected it to the computer with one of these XBee to R232 converters and used minicom to set the SSID and password. Also, I put the device in UDP mode and set up a port to listen on. At this point any UDP packet I send to the WiFi module's IP/port will be sent over the UART to my MSP430. In other words, if I send a UDP packet with 'A' in it to the module, just the letter 'A' will be sent over the UART to my chip. My firmware doesn't even have to think about the fact that the data being sent to it came from a UDP packet over the network.
For video I found this TRENDnet TV-IP551W IP camera. The camera is a little quirky, for example when requesting a single JPEG from the camera the webserver won't honor the keep alive header so I can't do a "client pull" to get the video without extreme lag. Unfortunately, I couldn't find any TRENDnet documentation on programming the camera, but they did have some GPL compliant download with a binary version of their webserver in the tarball. Running the Unix command "strings" on their web server I found a bunch of hidden URL's for the camera including one that will allow me to pull data MJPEG "server push" style. I wrote some simple code that connects to the camera's web server over a TCP socket, makes a request for the MJPEG stream, and displays the video in my FLTK app. I was actually kind of surprised for being such a cheap camera it does have a pretty decent picture, even in low light. Unfortunately, the videos below make the camera look pretty awful. This is just the way the Nikon camera I used to make video adjusted for the bright screen I guess.
For anyone looking to play around this camera, the URL's I found are:
To be clear (since I'm being asked this question by people already) the camera runs on one IP address and has a TCP connection to the computer which connects to the camera's web server and the Roving Networks WiFi module has a second IP address which I send commands to via UDP. I haven't posted the FLTK app that communicates with these two devices because, well, the code was thrown together really fast and I'm kind of embarrassed at the way it was written :(. The MSP430G2553 firmware is however posted below and can be assembled using my own naken_asm assembler.
The first video here shows the first test of the car from a front view. Unfortunately, the motor is just too powerful and it flips over the back of itself when I pushed forward. I think this is because the car was designed to run on an NiMH battery, but that battery was sagging and resetting my camera and circuit when the car was starting out on the ground, so I replaced it with a LiPO. The LiPO weighs less and probably supplies more current to the motor (considering the NiMH battery was in pretty bad shape). https://youtu.be/0dpS_eVPm74
I adjusted the throttle control (halved it) and was able to move the car across the office. The car is still pretty hard to control. The WiFi in the office seems a bit saturated so my commands to the car and the video sometimes lag a bit. On top of that the steering is quite sensitive. http://youtu.be/G5ctIrHmqE8
This is a top view of the car recorded at the same time as the first video. https://youtu.be/4OOowfdTbUE
And I believe this video is an outside view of the second video. http://youtu.be/H58xGySylSY
A view of the car with the cover removed.
A closer view of the circuit board. The red module on the front is the WiFi module.
Front view of the car with the mounted camera. Yeah, the masking tape is ugly, but it holds pretty well and comes off easily.
Side view of the car with the mounted camera.
And here's the schematic...
Copyright 1997-2016 - Michael Kohn