Building a Raspberry Pi Car Robot with WiFi and Video

Dev Tips

Last year I found a company called SunFounder that makes great Raspberry Pi-related kits and stuff. I got their Raspberry Pi 10″ Touchscreen LCD and enjoyed it very much. This month I picked up the SunFounder PiCar 2.0 kit and built it with the kids. The kit includes everything you need except for the Raspberry Pi itself, a mini SD Card (the Pi uses that as  hard drive), and two 18650 rechargeable lithium batteries. Those batteries are enough to power both the Pi itself (so the car isn’t tethered) as well as provide enough voltage to run the 3 servos AND motors to drive and steer the car around. You can also expand the car with other attachments like light sensors, line followers, and more.

The PiCar 2.0 includes the chassis, a nice USB WiFi adapter with antenna (one less thing to think about if you’re using a Raspberry Pi  like me), a USB webcam for computer vision scenarios. It includes a TB6612 Motor Driver, PCA9685 PWM (Pulse Width Modulation) Servo Driver with 16 channels for future expansion. The kit also helpfully includes all the tools, screwdriver, wrenches, and bolts.

Preparing to build the SunFounder Raspberry Pi car

All the code for the SunFounder PiCar-V is on GitHub and while there can be a few hiccups with some of the English instructions, there are a bunch of YouTube videos and folks online doing the same thing so we had no trouble making the robot in a weekend.

Building a SunFounder Raspberry Pi Car

PRO TIP – Boot your new Raspberry Pi up with ssh enabled and already joined to your wifi

You’ll need to use a tool like to burn a copy of the Raspbian operating system on to a mini SD card. I prefer to save time and avoid having to connect a new Raspberry Pi to HDMI and a mouse and keyboard, so I get the Pi onto my wifi network and enable SSH by copying these two files to the root of the file system of the freshly burned mini SD card. This will cause the Pi to automatically join your network when it boots up for the first time. Then I used Ubuntu on Windows 10 to ssh into the Pi and follow the instructions.

  • Make a 0 byte file called “ssh” and copy it to the root of the new PI disk
  • Make a file called “wpa_supplicant.conf” with just linefeeds at the end and make it look like this. Copy it to the root of the new PI disk.
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev


I like to use Notepad2 or Visual Studio Code to change the line endings of a file. You can see the CRLF or the LF in the status car and click it. Unix/Raspbian/Raspberry Pi likes just an LF (line feed) for the lineending, while Windows defaults to using CRLF (Carriage Return/Line Feed, or 0x13 0x10) for text files.

Changing the line endings to Unix

The default Raspberry username is pi and the default password is raspberry. You may want to change that. SunFounder has a decent “install_dependencies” script that you’ll run on the Pi:

Installing the PiCar dependencies

Once you’ve built the PiCar you can ssh in and run their development server that gives you a little WebAPI to control the car. The SunFounder folks are pretty good at web development (less so with mobile apps) and have a nice Django app to control the PiCar.

Here’s the view from the front camera of the PiCar as viewed through local website on port 8000. It’s looking at my computer looking at itself. 😉

Viewing the PiCar camera through the Django website

You’re able to control the PiCar from this web interface with the keyboard. You can move the car and steer with WASD, as well as move the head/camera independently. You will need to enter the settings area (upper right corner) and calibrate the back wheels direction. By default, one wheel may go the opposite direction because they can’t be sure how you mounted them, so you’ll need to reverse one wheel to ensure they both go in the same direction.

They also included a client application, also written in Python. On Windows you’ll need to install Python, and when you run you may get an error:

ImportError: No module named requests

You’ll need to run “pip3 install requests” as that module isn’t installed by default.

Additionally, Python apps aren’t smart about High-DPI displays, so I went to C:UsersscottappdatalocalProgramsPythonPython36 and right click’ed the Python.exe and set the DPI setting to “System (Enhanced)” like this.

Overridding DPI settings to System (Enhanced)

The client app is best for “Zeroing out” the camera and wheels, in case they are favoring one side or the other.


All in all, building the SunFounder “Raspberry Pi Video Car Kit 2.0” with the kids was a great experience. The next step is to see what else we can do with it!

  • Add a speaker so it talks?
  • Add Alexa support so you can talk to it?
  • Make the car drive around and take pictures, then use Azure cognitive services to announce what it sees?
  • Or, as my little boys say, “add weapons and make another bot for it to fight!”

What do you think?

* I use Amazon affiliate links and appreciate it when you use them! It supports this blog and sometimes gives me enough money to buy gadgets like this!

Sponsor: Unleash a faster Python! Supercharge your applications performance on future forward Intel® platforms with The Intel® Distribution for Python. Available for Windows, Linux, and macOS. Get the Intel® Distribution for Python Now!

Source link

Leave a Reply