Index>Robot Kit>Mars Rover PiCar-B Smart Robot Car Kit for RPi>Lesson 10 How to Take a Photo with Raspberry Pi

Lesson 10 How to Take a Photo with Raspberry Pi


Lesson 10 How to Take a Photo with Raspberry Pi


In this tutorial we will learn the photography function of the Raspberry Pi.

For more details, refer to the Raspberry Pi official website:

10.1 Components & Parts





Raspberry Pi



Motor HAT



Camera Module



Camera Cable(black)




10.2 Introducing the Camera Module


The Raspberry Pi camera module is capable of taking full HD 1080p photos and videos and can be controlled programmatically.

10.3 Schematic Diagram


The flex cable inserts into the connector situated between the Ethernet and HDMI ports, with the silver connectors facing the HDMI port. The flex cable connector should be opened by pulling the tabs on the top of the connector upwards then towards the Ethernet port. The flex cable should be inserted firmly into the connector, with care taken not to bend the flex at too acute an angle. The top part of the connector should then be pushed towards the HDMI connector and down, while the flex cable is held in place. (Pay attention that the metal of the connector should be in contact with that of the cable)


Install the Motor HAT. Insert the cable through the hole of the  Motor HAT.




10.4 Programming the Raspberry Pi to Take Photos

Run the code

1. Log into the Raspberry Pi remotely.


2. When the Raspberry Pi is configured with the robot software, the Raspberry Pi will automatically run the program. If you need to use the camera in other programs, you need to terminate this program. Termination command:

sudo killall python3

3. View the files of the current directory:



4. Type in commands, press Enter to run the program. If there are errors, please see the F&A in this tutorial.

raspistill -t 1000 -o image.jpg


5. 1s after the successful run, the camera will take a photo image.jpg.

1000: delay time of photo shooting

image.jpg: name of the photo

6. Type in "ls" to view the file.




10.5 Q&A


Error occurs when the command "raspistill -t 1000 -o image.jpg" is typed in the command line.


1. Run  sudo killall python3.

2. Check whether the camera connector of the Raspberry Pi, flex cable, and camera module are well connected.

Metals of the flex cable and camera module should be in contact with each other

Metals of the camera module's flex cable and camera connector of the Raspberry Pi should be in contact with each other

Check whether the flex cable and camera are good or damaged.



If you run "sudo killall python3" remotely, the remote login software is stuck. (cannot enter characters in the interface)

A small number of Raspberry Pi will have this situation. When you need to manually run our product program, please close the program that the Raspberry Pi automatically runs. For details, please refer to the penultimate lesson "Configuring Auto-run Program". When you want the Raspberry Pi to boot to be able to control, then start the Raspberry Pi auto-start program.