38

I just got my Camera Board and a Model A Raspberry Pi to use as a security camera for my house. I had been using Motion with a Logitech C170 USB camera on my Model B board and it worked great except for the quality. I was expecting the Raspberry Pi Camera Board to show up as /dev/video0 but when I run Motion I get an error:

Failed to open video device /dev/video0: No such file or directory

The camera works fine with raspistill -d. This has to work with Motion as it has to take videos/pictures when movement is detected and I have to be able to access it from work.

This question was no good for me as it never answered my question and I'm not using python.

8 Answers 8

57

You can access the camera board on /dev/video0 by running the command:

sudo modprobe bcm2835-v4l2

This will have to be run on every boot of the device. Or you can put modprobe bcm2835-v4l2 in /etc/rc.local to make it run on every boot automatically.

4
  • 10
    You can add the line to /etc/modules to get the kernel to insert the module on boot automatically. <code> echo "bcm2835-v4l2" | tee -a /etc/modules </code> Ensure you can run the command first <code> sudo modprobe bcm2835-v4l2 </code> Commented Feb 3, 2015 at 22:16
  • Note: it is an "L" not a "1" for bcm2835-v4l2. Commented Jan 28, 2018 at 23:47
  • 1
    why does this work ? what's the magic behind it.
    – AK_
    Commented Feb 12, 2018 at 2:06
  • 1
    is there any rationale behind it not being enabled automatically on every boot? Any clue why raspi-config doesn't do that when you enable the cam?
    – dethSwatch
    Commented Sep 9, 2018 at 4:20
11

to load the model after each reboot, use this setting

  1. sudo nano /etc/modules
  2. enter bcm2835-v4l2
  3. exist and save the fle
  4. sudo reboot
5

The standard motion dosn't work with the RPI camera. There is a variant called motion-mmal in development which works with the RPI camera

http://www.raspberrypi.org/phpBB3/viewtopic.php?t=44966&p=379561#p374790 is a forum chat on setting it up

http://www.codeproject.com/Articles/665518/Raspberry-Pi-as-low-cost-HD-surveillance-camera this is a guide on using motion mmal to set up a security camera.

1
  • 2
    The standard motion works fine through v4l2 after loading module bcm2835-v4l2. Though probably not as good as with MMAL.
    – scai
    Commented Feb 15, 2017 at 18:41
2

to get motion to work(out of the box) you can install the Userspace Video4Linux2

It will create the /dev/video0 device node correctly on the Raspberry Pi.

I have just followed the install instructions and not only does motion just work, the example(optional) motion.conf sets up the Pi as a streaming server so that you can access it remotely in a browser.

the developer is asking for donations, I am definitely going to contribute.

1
  • 1
    Some dead links.
    – nu everest
    Commented May 18, 2017 at 3:08
2

(from https://raspberrypi.stackexchange.com/a/18214/12486)

You will be able to access to the raspi camera like other V4L2 device using :

sudo modprobe bcm2835-v4l2

uv4l --driver raspicam --auto-video_nr

0
1

I had the same problem. I tried this, it set up /dev/video0 OK but it did not work with motion: http://www.linux-projects.org/modules/sections/index.php?op=viewarticle&artid=16

But then found this blog which seems to work: http://rbnrpi.wordpress.com/project-list/setting-up-wireless-motion-detect-cam/

Note that the motion-mmal apparently only supports 3 resolutions right now: 352x288; 640x480 and 1024*576

Hope this helps.

0

I had a similar problem.

Today it was working, the next day it died.

tried a couple of the stuff here and other procedures found on google.

I eventually fixed it by activating the I2C protocol in raspi confing.(didn't think that was the problem since from what i know the camera uses the CSI-2 protocol and I never tweaked with it)

-1

I used motionpie https://github.com/ccrisan/motionPie to turn it into a IP cam.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.