SunFounder PiCar-V Smart Car Kit for Raspberry Pi¶
About the PiCar-V¶
The car PiCar-V is equipped with a wide-angle USB webcam, three whole new circuit boards with less but more simple wiring, some acrylic plates with an adjusted structure, and new code suitable for almost all platforms to control the car.
In this book, we will show you how to build the PiCar-V via description, illustrations of physical components, in both hardware and software respects. You will enjoy learning how all this work. You can view the latest PDF user manual or clone the code by click the link: https://github.com/sunfounder/SunFounder_PiCar-V/tree/V3.0.
You are welcomed to post requests and issues on our page on Github.
If you want to learn another projects which we don’t have, please feel free to send Email and we will update to our online tutorials as soon as possible, any suggestions are welcomed.
Here is the Email: cs@sunfounder.com.
Components List¶
Plates¶

Upper Plate x 1
Front Half Plate x 1
Back Half Plate x 1
Pan-and-tilt Plate x 1
Pan-and-tilt Base Plate x 1
Camera Mount Plate x 1
Steering Connector Plate x 2
Bearing Shield x 8
Steering Linkage Plate x 1
Hex Front Wheel Fixing Plate x 8
Gasket Plate x 2
Note
The Bearing Shield is similar to the Gasket Plate, but the aperture of Gasket Plate is large than the Bearing Shield.
Servo x 3¶

Servo
1-arm Rocker Arm
arm Rocker Arm
4-arm Rocker Arm
Rocker Arm Fixing Screw
Rocker Arm Screw
Wires¶

Tools¶

Self-provided Components¶
The following components are not included in this kit.

Note
You are recommend to use 18650 batteries without a protective board. Otherwise, the car may be cut power and stop running because of the overcurrent protection of the protective board.
For unprotected batteries, please purchase those with the anode bulged out (as shown below), so that it can ensure the well connection with the battery holder.

In order to keep the car working for a long time, use large-capacity batteries as much as possible
Introduction¶
The PiCar-V is developed based on the previous Smart Video Car Kit. It’s equipped with the new PCA9685 PWM driver, smaller and better-performing DC motor driver module, a Robot Hat with power and interface integrated, a wider-angle camera with clearer vision, some better wheels and tires, and so on. Later we’ll check more details.
The basic functions of this new version still stay the same, including controlling the PiCar-V remotely and streaming the video data it captures back. Then what’s new? Let’s unveil the mysteries!

Building the Car¶
Are you excited when you open the box and see so many components? Keep your patience and take it easy. Please note that some details in the following steps need careful observation. You should double-check your work based on the figures in the manual after finishing each step. let’s start!
Front Wheels¶
Insert an M4x25 screw through a Steering Connector Plate, 3 Bearing Shields, 3 Hex Front Wheel Fixing Plates, and a front wheel, into an M4 Self-locking Nut as shown below:

You can use the Cross Socket Wrench to secure the M4 Self-locking Nut, then use the screwdriver to tighten the M4x25 screw.

Note
The Self-locking Nut should be screwed tight enough. It would be better to tighten the screw until the wheel and Steering Connector cannot move first, then loosen the screw a little, so that the Steering Plate can just move. Thus, the wheel can turn flexibly when the connection would not be too loose.
Assemble the other front wheel in the same way, but bear in mind the Steering Connector plate on the wheel should be symmetric with the previous one.

Now two front wheels have finished assembly.
Pan-and-Tilt¶
Take out the Cross rocker arm and mount it onto the Pan-and-tilt Base Plate with 2 M1.5x4 screws (into the hole like this). Pay attention to the holes on the round rocker arm to be fastened.

Do the same operation to the Camera Mount Plate.

Assemble the two servos to the Pan-and-tilt Plate with four M2x8 screws and the M2 nuts (The 2 servo shaft are close to the left side ):

Steering Part¶
Connect the Steering Linkage and the 1-arm Rocker Arm with the M1.5x4 Self-tapping Screw.
Note
Insert it into the FIRST hole of the arm (as indicated by the arrow below) which is the farthest from the gears.

And also fasten them as tightly as possible, and then loosen the screw a little so the Steering Linkage can move flexibly.
Upper Plate¶
Mount the M2.5x8 copper standoffs and M2.5 nuts into the upper plate first. Pay attention that the side the protruding prop should face up.

Battery Holder¶
Turn the Upper Plate upside down. Cut the ribbon into two halves. Thread them through the holes on the plate. Pay attention to the direction and leave one end longer out of the plate for each to remove the battery easily later.

Fasten the battery holder with two M3x8 countersunk screws and M3 nuts. Pay attention to the direction of battery holder’s wire.

PCB Assembly¶
Assemble the Raspberry Pi (TF Card inserted) with 8 M2.5x8 single pass copper standoffs, then plug the Robot HATS onto it.
Fix the Robot HATS with 4 M2.5x6 screws.
3) Fix The PCA9685 PWM Driver and the Motor Driver with 8 M2.5x12 screws and M2.5 nuts into the down plate:

Fixing Rear Wheels¶
Assemble the two motors with four M3x25 screws and M3 nuts. Pay attention to place the motors with wires inward, providing convenience for connecting the circuit.

Assemble the rear wheels with 4 M3 nuts.

Align the rear wheels with the motor shaft, and rotate to insert them gently.

Get Started with Raspberry Pi¶
In this chapter, we firstly learn to start up Raspberry Pi. The content includes installing the OS, Raspberry Pi network and how to open terminal.
Note
You can check the complete tutorial on the official website of the Raspberry Pi: https://projects.raspberrypi.org/en/projects/raspberry-pi-setting-up
If your Raspberry Pi is set up, you can skip the part and go into the next chapter.
Installing the OS¶
Required Components
Any Raspberry Pi |
1 * Personal Computer |
1 * Micro SD card |
Step 1
Raspberry Pi have developed a graphical SD card writing tool that works on Mac OS, Ubuntu 18.04 and Windows, and is the easiest option for most users as it will download the image and install it automatically to the SD card.
Visit the download page: https://www.raspberrypi.org/software/. Click on the link for the Raspberry Pi Imager that matches your operating system, when the download finishes, click it to launch the installer.

Step 2
When you launch the installer, your operating system may try to block you from running it. For example, on Windows I receive the following message:
If this pops up, click on More info and then Run anyway, then follow the instructions to install the Raspberry Pi Imager.

Step 3
Insert your SD card into the computer or laptop SD card slot.
Step 4
In the Raspberry Pi Imager, select the OS that you want to install and the SD card you would like to install it on.

Note
You will need to be connected to the internet the first time.
That OS will then be stored for future offline use(lastdownload.cache, C:/Users/yourname/AppData/Local/Raspberry Pi/Imager/cache, ). So the next time you open the software, it will have the display “Released: date, cached on your computer”.
Step 5
Select the SD card you are using.

Step 6
Press Ctrl+Shift+X to open the Advanced options page to enable SSH and configure wifi, these 2 items must be set, the others depend on your choice . You can choose to always use this image customization options.

Then scroll down to complete the wifi configuration and click SAVE.
Note
wifi country should be set the two-letter ISO/IEC alpha2 code for the country in which you are using your Raspberry Pi, please refer to the following link:
https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Officially_assigned_code_elements

Step 7
Click the WRITE button.

Step 8
If your SD card currently has any files on it, you may wish to back up these files first to prevent you from permanently losing them. If there is no file to be backed up, click Yes.

Step 9
After waiting for a period of time, the following window will appear to represent the completion of writing.

Power on the Raspberry Pi¶
Now, the Raspberry Pi OS is configured, you can plug out the USB card reader and then plug the Micro SD card into the Raspberry Pi.
Put two 18650 fully charged batteries in the holder, plug the wires from the battery holder into the development board then toggle the switch from off to on. You are also recommended to use the power adapter of Raspberry Pi to power your car for that the first test will take a long time.
Get the IP Address¶
After the Raspberry Pi is powered on with a power adapter, we need to get the IP address of it. There are many ways to know the IP address, and two of them are listed as follows.
1. Checking via the router
If you have permission to log in the router(such as a home network), you can check the addresses assigned to Raspberry Pi on the admin interface of router.
The default hostname of the system, Raspberry Pi OS is raspberrypi, and you need to find it. (If you are using ArchLinuxARM system, please find alarmpi.)
2. Network Segment Scanning
You can also use network scanning to look up the IP address of Raspberry Pi. You can apply the software, Advanced IP scanner(download from Google).
Click Scan and the name of all connected devices will be displayed. Similarly, the default hostname of the Raspberry Pi OS is raspberrypi, now you need to find the hostname and its IP.

Use the SSH Remote Control¶
We can open the Bash Shell of Raspberry Pi by applying SSH. Bash is the standard default shell of Linux. The Shell itself is a program written in C that is the bridge linking the customers and Unix/Linux. Moreover, it can help to complete most of the work needed.
For Linux or/Mac OS X Users
Step 1
Go to Applications->Utilities, find the Terminal, and open it.
Step 2
Type in ssh pi@ip_address . “pi” is your username and “ip_address” is your IP address. For example:
ssh pi@192.168.18.197
Step 3
Input “yes”.

Step 4
Input the password and the default password is raspberry.

Step 5
We now get the Raspberry Pi connected and are ready to go to the next step.

Note
When you input the password, the characters do not display on window accordingly, which is normal. What you need is to input the correct password.
For Windows Users
If you’re a Windows user, you can use SSH with the application of some software. Here, we recommend PuTTY(You can download from Google).
Step 1
Download PuTTY. Open PuTTY and click Session on the left tree-alike structure. Enter the IP address of the RPi in the text box under Host Name (or IP address) and 22 under Port (by default it is 22).

Step 2
Click Open. Note that when you first log in to the Raspberry Pi with the IP address, there prompts a security reminder. Just click Yes.
Step 3
When the PuTTY window prompts “login as:”, type in pi (the user name of the RPi), and password: “raspberry” (the default one, if you haven’t changed it).

Note
When you input the password, the characters do not display on window accordingly, which is normal. What you need is to input the correct password.
Here, we get the Raspberry Pi connected and it is time to conduct the next steps.
Servo Configuration¶
And since the servos used in this kit are adjusted by software and there’s no such physical sticking point as other servos, here we need to configure the servo via software. First you need to finish some software installation before the configuration.
Note
Please do not forget to put in the battery and slide the power switch to ON in this chapter.
Get Source Code¶
You can find the source code in our Github repositories. Download the source code by git clone:
cd ~/
git clone https://github.com/sunfounder/SunFounder_PiCar-V -b V3.0
Note
Please pay attention to your typing – if you get the prompt of entering your user name and password, you may have typed wrong. If unluckily you did so, press Ctrl + C to exit and try again.
Check by the ls command, then you can see the code directory SunFounder_PiCar-V:

Go to the Code Directory¶
cd ~/SunFounder_PiCar-V
Enter the code directory and you can see the installation script:

Install the Environment via the Script¶
You can get all the required software and configuration done with the install_dependencies script. If you want to do step by step instead, please follow the instructions in the Appendix 1: Function of the Server Installation Scripts.
sudo ./install_dependencies
Note
The installation script will install the required components and configure for the running environment. Make sure your Raspberry is connected to the Internet during the installation, or it would fail.
The Raspberry Pi will prompt you to reboot after the installation. You’re recommended to type in yes to reboot.
Configure the Servo to 90 degrees¶
After reboot, run the picar tool:
cd ~/SunFounder_PiCar-V
picar servo-install
Note
If the “OSError: [Errno 121] Remote I/O error” error message appears, open raspi-config:
sudo raspi-config
Then choose 3 Interfacing Options → P5 I2C → <YES> →OK to enable I2C service. You can use the up, down, left, and right keys on the keyboard to select, and then press Enter to confirm.
After the code is running, insert the rocker arm into the servo. You will see the rocker arm is rotate in clockwise and counterclockwise, then stop at a specific location. It means the servo is good. If the any of the conditions below happened to your servo, your servo is bad:
Noisy, hot.
If unplug the servo line and rotate the rocker arm, it sounds like “ka” “ka” “ka” or there has no sounds of gear driving.
Rotate slowly but continuously.
If you find one of the conditions above, please send e-mail to service@sunfounder.com . We will change a new one to you. If it is broken in the process of using or assembling, you should go to the official website www.sunfounder.com to buy.
Continue to Assemble¶
Warning
Please do forget to put in the battery and slide the power switch to ON, then keep servo-install running in the whole process of assembly.
Assemble the Steering Servo¶
Mount the Steering Servo to the Upper Plate with two M2x8 Screws and M2 nuts (pay attention to the direction of the servo wires):

Front Half Chassis¶
The Rocker Arm is facing straight ahead, and then inserted into the Servo shaft, and then fixed with Rocker Arm Fixing Screw (the shortest).

Mount the wheels onto the Upper Plate carefully.

Assemble the Front Half Chassis with four M3x25 copper standoffs and M3 nuts.

Then put the assembled Front Half Chassis onto the Upper Plate with standoffs aligned with the holes.

Hold them carefully, turn upside down, and fasten the standoffs and Upper Plate with four M3x8 screws.

Assemble the assembled Pan-and-tilt Plate, Gasket Plate and Camera Mount Plate with the Rocker Arm Fixing Screw in a fixed angle as shown below:
Note
Do not rotate the servo by hands in case of breaking the servodown.

Similarly check that the servo shaft has spun to 90 degrees. Then assemble the Pan-and-tilt Base Plate with the Rocker Arm Fixing Screw and the Gasket Plate in the angle as shown below.

Assemble the Pan-and-tilt Plate to the car with two M3x10 screws and the M3 nuts.

Assemble the Camera¶
Take out the camera and nip it to the Camera Mount. Connect its USB cable to the USB port on the Raspberry Pi.
So now, the whole assembly is DONE! Congratulations! You can power off the car now! Don’t forget to charge your batteries.

Getting on the Road!¶
Make sure all the procedures have been finished, and check there is no problem about the mechanical assembly and software installation.
Remote Control¶
Here is what we’re going to do:
Use the Raspberry Pi as the server. Run a web server with an API for controlling the car and transmitting images captured by the camera.
Then take a PC, cell phone, or tablet as the client, and acquire the images from the camera and control the car by calling the API of the web server.
Now, you can power on the car again. You are also recommended to use the power adapter of Raspberry Pi to power your car for that the first test will take a long time.
Run the Server(Operation on Raspberry Pi)¶
Remotely log into the Raspberry Pi. Run the startup script start under the remote_control directory to start the web service.
cd ~/SunFounder_PiCar-V/remote_control
python3 manage.py migrate
sudo ./start
The script will enable the service and the corresponding data will appear. The hardware is initialized at the same time, so the servos connected to the front wheels and the pan-and-tilt will turn, indicating the hardware initialization is done.

If you get the result similar as shown above, the server is ready. Now move on to start the client.
Warning
Keep the server being running all the time until you stop to run the Client.
Run the Client(Operation on PC)¶
Visit the server of the car at http://<RPi_IP_address>:8000/
. You will see a welcome page:

Click LET’S ROCK to go to the operation interface:

On this page, you can press the keys W, A, S, and D on the keyboard to control the car to move forward, backward, turn left, and turn right, press the arrow keys to control the camera’s movement, and number 1~5 to change the speed level.
Calibration
Click FULLSCREEN again to bring back the title bar. And then, tap the setting button at the top-right corner of the page to go to the calibration page:

There are three calibration parts: Camera Calibration, Front Wheels Calibration and Rear Wheels Calibration.
When you enter this page, the car will go forward; if not, click Left and Right in Rear Wheels Calibration to adjust the angle of the wheel.
Note
Every time you press a button, the angle will be changed slightly. For your larger change per time, you need to long press the button.
Click OK to save the result after all the calibration is done.
For Mobile Phones
Also for mobile phones, tap the FULLSCREEN button to have a better view and performance. Then, tap the buttons of 5 speed levels on the page to control the speed, and the arrow buttons to control the direction of the car and the pan-and-tilt. But you can only tab one touch point at one time.

Take this screenshot from an Android phone:

Though the appearance may not be as good as on the PC. Later updates may be released irregularly on Github. You are welcome to fork our repository and submit a Pull request with your changes. If there is no problem after testing, we are more than pleased to merge your request.
ball_tracker¶
In addition to using the keyboard to control the status of the car, we also wrote a ball tracking code.
sudo apt-get install libatlas-base-dev libjasper-dev libqt4-test libwebp6 libtiff5 libopenexr23 libgstreamer1.0-0 libavcodec-dev libavformat-dev libswscale-dev libqtgui4 -y
sudo pip3 install opencv-python==3.4.6.27
cd ~/SunFounder_PiCar-V/ball_track
python3 ball_tracker.py
After the code runs, find a red ball (at least larger than the diameter of the camera) and put it within 10-50cm range in front of the camera to get the car to follow your ball.

If you want to know whether the car has catched your ball, you can do as follows:
Step 1: Enable the VNC on the Raspberry Pi.
sudo raspi-config
Choose 3 Interfacing Options by press the down arrow key on your keyboard, then press the Enter key..

P3 VNC

Press the left arrow key on your keyboard to choose Yes.

Finally select OK->Finish to exit the config.

Step 2: Download the VNC Viewer for your computer and install it.
https://www.realvnc.com/en/connect/download/viewer/
Note
During your installation on your Windows, if you encounter the following prompt, please click Continue to continue your installation.

Step 3: Open VNC Viewer you have installed, type in your Raspberry Pi IP address, and press the Enter button.

Step 4: Enter the username and password of your Raspberry Pi on this page, by default, they are pi and raspberry; then click OK.

When you log in with VNC Viewer, the screen may be black.If your screen is working, skip to Step 5.

Changing the resolution to the highest on the Raspberry Pi.
sudo raspi-config
Choose 2 Display Options.

Choose D1 Resolution.

Change the default to a higher resolution like Mode 16, then click OK.

Reboot the Raspberry Pi, log in again, and it will work.
sudo reboot
Step 5: Now, we enter the Raspberry Pi desktop, click Terminal and type the following commands to open the code ball_tracker.py.
cd ~/SunFounder_PiCar-V/ball_track
sudo nano ball_tracker.py
Then modify the code as follows:
Show_image_enable = True
Draw_circle_enble = True
Press Ctrl+X and Y to save the change.

Note
After you finish doing this step, you must log in the Raspberry Pi via VNC, or you can use a monitor; if not, the warning is as follows:

Step 6: Run the ball_tracker.py.
python3 ball_tracker.py

Step 7: After running the code ball_tracker.py, these four images will appear. If you place a red ball in front of the camera, you can see a green circle which represents that the car has catched your red ball.

File Analysis¶
There are two folders under /home/pi: SunFounder_PiCar for controlling motors and steering and SunFounder_PiCar-V for pan/tilt and wireless control. Here look into the code of PiCar-V.
Since too many contents and instructions are involved in the code, we will not cover every detail. For more knowledge about Python 2, Python 3, Django, HTML, and CSS in the programs, you can visit related websites or buy books to learn by yourself. In the following part, we will go through the overall structure and the process in brief.
First, let’s check the files in the code folder:

.git
is a hidden directory to store all the information of a Git repository; it’s generated automatically after you create the repository.Ball_track
is used to let the car follow the red ball.datasheet
stores the manual of some chips used in the hardware modules.mjpg-streamer
is an open source streaming media library, through which the data of the camera is transferred.Remote_control
is to store the code of the web server; it controls the motor and servo of the car based on the API request..gitignore
records the requests of file types to be ignored when the Github repository is synchronized._init_.py
is automatically generated when you create a project which is a standard necessary document of python package, just leave it there.i2cHelper.py
is a Python script written by Python 2 to configure and detect the I2C connection.install_dependencies
, an executable bash script for simple installation and environment configuration.LICENSE
, as the name suggests, is a text file of GNU V2 license.README.md
andshow
record some information normally for statement and prompts.
Server Code¶
The server code is based on Django 1.10 (adapt to the latest release if needed). If you are interested in this, you can visit the Django website https://www.djangoproject.com/. Here we will just learn how the web server works.
Note
The code may be updated irregularly on Github to fix bugs and release some functions update. So the code here is the initial version. You can view the updates in the Github repository at:
Open the code directory and check the file by ls
:
pi@raspberry:~ $ cd SunFounder_PiCar-V/
pi@raspberry:~/SunFounder_PiCar-V $ ls
datasheet install_dependencies mjpg-streamer remote_control
client i2cHelper.py LICENSE README.md show
remote_control
is the main code directory of the web server. Open the
code directory by cd remote_control
, and check the file by ls:
pi@raspberry:~/SunFounder_PiCar-V $ cd remote_control
pi@raspberry:~/SunFounder_PiCar-V/remote_control $ ls
db.sqlite3 manage.py remote_control start static
db.sqlite3
is generated when you create a Django project.manage.py
is the main program of the Django project and is generated when the project is created. It normally does not need to be modified.remote_control
includes the main code files.start
is a small script written to runsudo python manage.py runserver 0.0.0.0:8000
, and servo installation with attributeinstall
just for convenience.static
is to store some static pictures on the web.
The Django web server normally runs sudo python manage.py runserver
to
start. The address 0.0.0.0:8000 means the listening address covers all
the addresses on the LAN, and the port number is 8000. Here we will just
focus on the code in remote_control
folder. Go to the directory via cd
remote_control
:
pi@raspberry:~/SunFounder_PiCar-V/remote_control $ cd remote_control
pi@raspberry:~/SunFounder_PiCar-V/remote_control/remote_control $ ls
driver \__init__.py settings.py templates urls.py views.py wsgi.py
driver
stores the drivers of the car.__init__.py
is automatically generated when you create a Django project which is a standard necessary document of python package, just leave it there.settings.py
is automatically generated and stores the related settings.templates
is a Django app for storing the webs in the html format.urls.py
is generated automatically to configure the URL to associate with the code.views.py
is the code for page control which is associated by the URL. It calls the templates to show the page and the driver to control the car.wsgi.py
is generated automatically and does not need changes. For more, please visit the official website of Django.
So here is how the code works: Run the main program manage.py
which will
be associated with urls.py
automatically, to respond to the URL. When
you run the web browser like the Chrome to visit
http://<rpi_ip_address>:<port>
or visit the configured API via the
client, the manage.py
will turn to views.py
due to the association of
the urls.py.
Then the views.py
processes this and returns the
templates to the browser. In addition, it will call the driver
package
on the basis of the parameters set in the browser to control the car.
Now open the folder driver
and check:
pi@raspberry:~/SunFounder_PiCar-V/remote_control/remote_control $ cd driver/
pi@raspberry:~/SunFounder_PiCar-V/remote_control/remote_control/driver $ ls
camera.py config \__init__.py stream.py
The driver
folder mainly includes the driver modules for controlling the
pan and tilt and camera streamer.
camera.py
for controlling the pan-and-tilt.
config
stores the calibration data.
__init__.py
is the essential file of the package and you can just leave it alone.
stream.py
is a video streaming service based on the MJPG-streamer.
Exit and open the folder templates
to view:
pi@raspberry:~/SunFounder_PiCar-V/remote_control/remote_control/driver $ cd ../
pi@raspberry:~/SunFounder_PiCar-V/remote_control/remote_control $ cd templates/
admin.py \__init__.py models.py tests.py
apps.py migrations templates views.py
This folder is created by the manage.py startapp
just for calling the
templates conveniently. Therefore, the files have not been changed
except for the templates
. Open the templates
again:
pi@raspberry:~/SunFounder_PiCar-V/remote_control/remote_control/templates $ cd templates
pi@raspberry:~/SunFounder_PiCar-V/remote_control/remote_control/templates/templates $ ls
base.html cali.html run.html
There are three HTML files that also consist of layers. The low level
base.html
stores contents contained on each page such as the <head>
of
HTML, the overall layout, and contents of the home page by default. The
surface layer: cali.html
for calibration and run.html
to control the
car.
Advanced¶
Now the car is running! You may try control it or view the image captured in Windows, Linux, or Mac OS X.
So what to do next?
Yes, sensors! There are 8 digital and 4 analog channels on the Robot HATS, as well as two I2C ports. Plus the 3mm slot on the acrylic plate in the car head, it enables the connection of various sensors, making the car smarter and more intriguing as you want!
And, coding! If you know programming and are capable of compiling code, you may change the code provided for the kit to make the car more fabulous. For instance, you can find the code that controls the front and back wheels in the folder SunFounder_PiCar, downloaded to the directory /home/pi if you’ve installed the program by install-dependences.
You may check what’s in the file:
cd ~/SunFounder_PiCar
ls
After you’ve changed the code, you can go to the page of the Github repository for the car, and fork it to help improve it! Also you’re quite welcome to post issues and request a pull on our Github page:
PiCar-V: https://github.com/sunfounder/SunFounder_PiCar-V/tree/V3.0
PiCar driver: https://github.com/sunfounder/SunFounder_PiCar
And of course, if you have any questions or ideas, please feel free to email us at service@sunfounder.com.
Appendix¶
Appendix 1: Function of the Server Installation Scripts¶
You may have a question: What do the installation scripts do when we install the server on the Raspberry Pi by them? So here let’s check the detailed steps.
Install pip.
sudo apt-get install python-pip
Use pip to install django.
sudo pip install django
Install i2c-tools and python-smbus.
sudo pip3 install smbus2
Install PiCar drivers.
cd ~/
git clone -–recursive https://github.com/sunfounder/SunFounder_PiCar.git
cd SunFounder_PiCar
sudo python setup.py install
Download source code.
cd ~/
git clone https://github.com/sunfounder/SunFounder_PiCar-V -b V3.0
Copy the MJPG-Streamer file to system directory.
cd ~/SunFounder_PiCar-V
sudo cp mjpg-streamer/mjpg_streamer /usr/local/bin
sudo cp mjpg-streamer/output_http.so /usr/local/lib/
sudo cp mjpg-streamer/input_file.so /usr/local/lib/
sudo cp mjpg-streamer/input_uvc.so /usr/local/lib/
sudo cp -R mjpg-streamer/www /usr/local/www
Export paths.
export LD_LIBRARY_PATH=/usr/local/lib/ >> ~/.bashrc
export LD_LIBRARY_PATH=/usr/local/lib/ >> ~/.profile
source ~/.bashrc
Enable I2C1.
Edit the file /boot/config.txt:
sudo nano /boot/config.txt
Add the line in the end:
dtparam=i2c_arm=ons
Reboot.
sudo reboot
Appendix 2: Components¶
Robot HATS¶

Robot HATS is a specially-designed HAT for a 40-pin Raspberry Pi and can work with Raspberry Pi model B+, 2 model B, 3 model B, 3 model B+, and 4 model B. It supplies power to the Raspberry Pi from the GPIO ports. Thanks to the design of the ideal diode based on the rules of HATS, it can supply the Raspberry Pi via both the USB cable and the DC port thus protecting it from damaging the TF card caused by batteries running out of power. The PCF8591 is used as the ADC chip, with I2C communication, and the address 0x48.

Digital ports: 3-wire digital sensor ports, signal voltage: 3.3V, VCC voltage: 3.3V.
Analog ports: 3-wire 4-channel 8-bit ADC sensor port, reference voltage: 3.3V, VCC voltage: 3.3V.
I2C ports: 3.3V I2C bus ports
5V power output: 5V power output to PWM driver.
UART port: 4-wire UART port, 5V VCC, perfectly working with SunFounder FTDI Serial to USB.
Motor control ports: 5V for motors, direction control of motors MA and MB and a floating pin NC ; working with SunFounder motor driver module.
Switch: power switch
Power indicators: indicating the voltage – 2 indicators on: >7.9V; 1 indicator on: 7.9V~7.4V; no indicator on: <7.4V. To protect the batteries, you’re recommended to take them out for charge when there is no indicator on. The power indicators depend on the voltage measured by the simple comparator circuit; the detected voltage may be lower than normal depending on loads, so it is just for reference.
Power port: 5.5/2.1mm standard DC port, input voltage: 8.4~7.4V (limited operating voltage: 12V~6V).
PCA9865¶

PCA9685 16-channel 12-bit I2C Bus PWM driver. It supports independent PWM output power and is easy to use 4-wire I2C port for connection in parallel, distinguished 3-color ports for PWM output.

PWM output ports: 3-color ports, independent power PWM output port, connect to the servo directly.
2 and 3. I2C port: 4-wire I2C port, can be used in parallel. Compatible with 3.3V/5.5V.
PWM power input: 12V max.
LED: power indicator for the chip and for the PWM power input.
Motor Driver Module¶
The motor driver module is a low heat generation one and small packaged motor drive.

Power and motor control port: includes pins for supplying the chip and the motors and controlling the motors’ direction.
PWM input for the motors: PWM signal input for adjusting the speed of the two motors.
Motor output port: output port for two motors.
USB Webcam¶

This camera supports a wide angle of 120°, which provides a wide and clear vision, thus giving better experience when you’re using it on the PiCar-V.
SunFounder SF006C Servo¶

Clutch gear digital servo with a DC core motor inside, After a certain load, the steering gear reducer will automatically clutch and protect the product from damage and normal load.
Function of the Performance:
Item |
V = 4.8V |
V = 6.0V |
Consumption Current* (No Load) |
≦50mA |
≦60mA |
Stall Current |
≦550mA |
≦650mA |
Rated Torque |
≥0.6 kgf·cm |
≥0.7 kgf·cm |
Max. Torque |
≥1.4 kgf.cm |
≥1.6 kgf.cm |
No Load Speed |
≦0.14sec/60° |
≦0.12sec/60° |
Thank You¶
Thanks to the evaluators who evaluated our products, the veterans who provided suggestions for the tutorial, and the users who have been following and supporting us. Your valuable suggestions to us are our motivation to provide better products!
Particular Thanks
Len Davisson
Kalen Daniel
Juan Delacosta
Now, could you spare a little time to fill out this questionnaire?
Note
After submitting the questionnaire, please go back to the top to view the results.
Copyright Notice¶
All contents including but not limited to texts, images, and code in this manual are owned by the SunFounder Company. You should only use it for personal study,investigation, enjoyment, or other non-commercial or nonprofit purposes, under therelated regulations and copyrights laws, without infringing the legal rights of the author and relevant right holders. For any individual or organization that uses these for commercial profit without permission, the Company reserves the right to take legal action.