Orange Pi markets a small 2MP color camera with wide-angle optics that can be used to create a small additional surveillance camera. In this tutorial, we will install the gc2035 and vfe_v4l2 drivers that support the camera. The software part will be entrusted to Motion capable of detecting movements in front of the camera. With the exception of the Orange Pi Zero, all Orange Pi card computers have a camera port in CSI (Camera Serial Interface) format as well as Raspberry Pi (from the second generation).
This camera uses the gc2035 driver. It is compatible with all Orange Pi mini-PCs. Since the gc2035 driver is part of the default Debian distribution, it is very easy to activate it. For this tutorial, you will need the following hardware.
|Orange Pi Lite|
|Power 5V – 3A|
Or USB cable, about €2.50
|Armbian on 8Go SD Card classe 10|
|Orange Pi 2MP camera module|
About €7 (free shipping)
On the system side, I opted for Armbian (presented in this article). It is a lightweight system (a version without desktop is available) whose origins are known. So there is a very low risk of turning your 100% DIY surveillance camera into botnet and finding yourself involved in a new DDoS attack case!
Unpacking the Orange Pi Camera
The camera of Orange Pi is delivered in a simple transparent plastic bag. Low cost complies. The module includes the camera, an adapter (required) and a 15 cm long tape.
Compatible with the Raspberry Pi connector ?
The Raspberry Pi uses a CSI-2 connector that supports cameras up to 5 MPixels. The Orange Pi also has a CSI connector but the similarity stops there. Indeed, it is indeed a CSI connector but it is not the CSI-2 15 pin that equips the Raspberry Pi (2, 3 or Zero).
It is a 24-pin connector with a width of 12mm, while that of the Raspberry Pi measures 16mm. Difficult to know which version it is because nothing is clearly documented, including the technical documents available here.
If you want a better camera, for example a camera with a setting optics, no IR filter for better night vision, or a higher resolution, you will have to fall back to a standard USB webcam. The most classic is the Logitech C270.
Open the connector. Insert the ribbon until you feel the bottom of the connector. There is no indicator of direction, simply turn the ribbon so that the tracks are opposite the pins of the connector. Close the connector.
Do the same with Orange Pi.
The result after assembly
Before you start, it is best to update the system
sudo apt-get update sudo apt-get upgrade
After the upgrade, you will probably have to change your video configuration if the Orange Pi is connected to a DVI monitor (and therefore restart on a TV in HDMI).
Now we add the drivers for the camera
sudo modprobe gc2035 sudo modprobe vfe_v4l2
To get the drivers loaded at boot time, open the /etc/modules file and uncomment the gc2035 and vfe_v4l2 drivers, for example
8189fs #gpio_sunxi #w1-sunxi #w1-gpio #w1-therm gc2035 vfe_v4l2 sunxi-cir g_serial
Installing and configuring Motion
Let’s start by creating a destination directory for images and assigning all permissions. For example /home/pi/motion/
mkdir ~/motion chmod 777 ~/motion
Now we can install Motion
sudo apt-get install motion
When the installation is complete, open the configuration file
sudo nano /etc/motion/motion.conf
Modify the following keys:
- target_dir: Specify the destination path of the images. For example / home / pi / motion (previously created)
- stream_localhost: set the parameter to off so that Motion can be accessed from another computer on the local network
Save with CTRL+X then Y
If Motion does not seem to work, it points to the / etc directory to load the configuration file. In this case, copy the configuration file with the cp command, for example.
sudo cp /etc/motion/motion.conf /etc/motion.conf
Allow the Motion daemon to start at startup
To have Motion start at system startup, you need to modify a last configuration file.
sudo nano /etc/default/motion
Change the start_motion_daemon = yes parameter and save.
Start manually Motion
Now we can start Motion via its service
sudo /etc/init.d/motion start
After a modification of the configuration file, it will be necessary to restart Motion to take account of the new parameters:
sudo /etc/init.d/motion restart
Motion crash after a few seconds
During the development of this article, I encountered some difficulties, and in particular the crash of Motion after a few seconds of operation. Regardless of the problem encountered, it is best to first activate the Motion event log. Open the configuration file
sudo nano /etc/motion/motion.conf
Then look for the line that starts with logfile and removed the semicolon.
# Use a file to save logs messages, if not defined stderr and syslog is used. (default: not defined) logfile /tmp/motion.log
sudo /etc/init.d/motion restart
Now you have a log just open to see what causes Motion to crash
In my case, Motion crashed when an event was detected, especially when the image was saved in the destination folder.
 [NTC] [ALL] [Dec 01 08:39:54] motion_detected: Motion detected - starting event 1  [ERR] [ALL] [Dec 01 08:39:54] myfopen: Error opening file /var/lib/motion/01-20161201083954-01.jpg $  [ERR] [ALL] [Dec 01 08:39:54] put_picture: Can't write picture to file /var/lib/motion/01-201612010$ Thread is going to finish due to this fatal error:  [NTC] [ALL] [Dec 01 08:39:55] motion_loop: Thread exiting  [NTC] [STR] [Dec 01 08:39:55] stream_stop: Closing motion-stream listen socket & active motion-stre$  [NTC] [STR] [Dec 01 08:39:55] stream_stop: Closed motion-stream listen socket & active motion-strea$  [NTC] [VID] [Dec 01 08:39:55] vid_close: Closing video device /dev/video0  [NTC] [ALL] [Dec 01 08:39:55] main: Threads finished  [NTC] [STR] [Dec 01 08:39:55] httpd_run: motion-httpd - Finishing  [NTC] [STR] [Dec 01 08:39:55] httpd_run: motion-httpd Closing  [NTC] [STR] [Dec 01 08:39:55] motion_web_control: motion-httpd thread exit
So we just need to assign permissions to the directory to allow Motion to write into. But it is not a very good idea to touch this folder.
sudo chmod 777 /var/lib/motion
In fact, I simply forgot to change the destination directory of the images in the configuration file.
In the next tutorial, we will see how to make our own IP surveillance camera.
Now you have an IP Motion Detection camera that you simply include in your DIY home automation server.
- Six 3D printing boxes to make a DIY surveillance camera with a Raspberry Pi Zero W
- Raspberry Pi Zero W and Node-RED MQTT Surveillance Camera for Home Assistant
- #Test: unpacking the Panoramic Camera Xiaomi Mijia 1080p 360 °
- Orange Pi (Armbian): driving the camera in Python with OpenCV
- Orange Pi (Armbian): control the camera in Python with OpenCV
- Picamera (version 1.9): control the Raspberry Pi camera in Python