Raspberry pi camera v2

A project log for InspectorBot

An open source robot to inspect under vehicles, crawl spaces and any other dark dirty space you need to take a look at.

DennisDennis 07/06/2017 at 00:072 Comments

For the time being, I wanted to work with pygame to access and display the cameras. Pygame makes it easy to add a USB camera, but a little more challenging to add the second High definition Raspberry Pi camera v2. Below is a short program to display the cameras attached to the RPI that are detected by pygame. I gave it the original name of “check_for_cameras”. The USB camera is plugged into a USB port and the Raspberry pi v2 camera plugged into the camera port.

Now run the program.

The program shows the problem. With the USB cameras plugged in and the Raspberry pi camera v2 plugged into the camera port, the program only displays the USB camera. To be able to access the Raspberry PI camera with pygame, we need a driver. Open the terminal and enter the command “sudo modprobe bcm2835-v4l2” like the below picture and run the program again.

***I edited this section on Radomir Dopieralski advice and placed bcm2835-v4l2 in /etc/modules instead of /etc/rc.local. Thanks Radomir it works GREAT! ***

It worked! We can see both cameras. The next problem is it will only work until we reboot the Raspberry Pi. To get around this, we will need to run “sudo modprobe bcm2835-v4l2” at start up. To run the command at start up, open terminal and enter “sudo nano /etc/ modules” then add “bcm2835-v4l2” in the following window. Like the two pictures below and save the change.

Finally reboot the Raspberry PI and run the program, and both cameras should be detected.


deʃhipu wrote 07/06/2017 at 11:43 point

Eww, don't edit your rc.local. Just put bcm2835-v412 in your /etc/modules -- that's what it is for!

  Are you sure? yes | no

Dennis wrote 07/07/2017 at 00:36 point

Hi Radomir,

Thanks for the advice. I made the changes and it works

  Are you sure? yes | no