Home > Allwinner H-Series, Debian, Hardware, Linux, Testing > How to Use Orange Pi Camera in Linux (with Motion)

How to Use Orange Pi Camera in Linux (with Motion)

September 26th, 2015 Leave a comment Go to comments

Earlier this month, I wrote a Quick Start Guide for Orange Pi Allwinner H3 boards such as Orange Pi PC, and showed how to install and configure Debian on the boards. I’ve also received the $5.90 Orange Pi camera, which when combined an Orange Pi PC, costs around $27 including shipping. So today, I’ve attached the CSI camera to my Orange Pi 2 mini board, and used it with motion to transform for the board into an IP camera.

Orange_Pi_2_mini_CameraFirst, you’ll need to insert the camera into CON1 connector with the camera facing the ceiling, and close the black clip to keep it in place.

Now connect all cable and power on your board. First, I studied the steps described on that forum thread, and modified Allwinner configuration files, but after one or two hours, I found out some work at been done since May, and it was now much easier to use the camera since gc2035 drivers was part of the Debian image, and the script.bin file (allwinner config file) was already setup to be used with Orange pi camera.

Open a terminal window in the board to load drivers:

and then mostly followed the instructions for USB webcams on Orange Pi website to install and configure motion:


This will make sure the web server started by motion will be accessible from other network devices.

I’ve also changed target_dir to /home/orangepi/motion, as motion would crash each time it would create a file when detection motion.

You’ll also need to change the startup script

and change the only line in the file as follows:

Finally, we are ready to give it a try:

You can launch your favorite browser, or access localhost:8081 if you are using your board, or <orange_ip_address>:8081 from another machine on the network, and you should the the picture camera updated into your web browser about twice per second.


Click to Enlarge

If the system detects motion will save pictures and videos in target_dir directory, which I set to /home/orangepi/motion earlier. The image resolution is set to 800×600, and it ignored width and height settings (320×240) set in motion.conf.

Motion will start automatically, but you still need to load the modules automatically at boot time for this to work. Simply edit /etc/modules, and add the two required modules at the end of the file.

Now motion will run automatically, and the camera work properly each time the board starts.

  1. onebir
    September 26th, 2015 at 19:34 | #1

    Is the Orange Pi camera comaptible with Raspi?

  2. September 26th, 2015 at 19:48 | #2

    Since CSI is a standard, I assume it should be, but the software needs to be adapted since it’s a different sensor.
    Quality is likely to be lower though, as Orange Pi camera is 2MP, while Raspberry Pi camera is 5MP, and people have made a lot of effort to improve and tune R-Pi camera module.

  3. Richard
    September 29th, 2015 at 06:06 | #3

    Which Debian image are you using?

  4. Richard
    September 29th, 2015 at 07:08 | #4

    Scratch that – I figured it out. I still can’t seem to get motion to work though.

    Is there any program like raspistill out there that would let me take still frames on a command line call that will work with the gc2035 driver?

  5. September 29th, 2015 at 09:14 | #5

    I first had problem with motion due to permissions issue. You can enabled logging to /tmp/motion.log in the config file.

    I understand the driver uses Video4Linux2 framework, so programs that work with V4L2 may also work with Orange Pi camera. See http://askubuntu.com/questions/122899/is-there-a-cli-webcam-image-grabber-that-works-with-a-video4linux2-device

  6. September 29th, 2015 at 09:16 | #6

    I forgot to say mplayer, which is supposed to work, is not working because some IOCTL commands are not implemented in the driver. So you may have to try a few programs before it works, or implement the missing parts in the driver.

  7. Richard
    September 30th, 2015 at 08:32 | #7

    Just got it working – it was a permissions issue.

    That said, I played around with mplayer and found the IOCTL errors, and I also played around with the v4l-utils package (using v4l2-ctl) to see if I could change some of the parameters (shutter speed, white balance, etc), but it looks like the driver doesn’t have any of that implemented either.

    Do you know if any instructions exist for compiling the driver on the Orange Pi 2 for Debian 8 exist? I’d be very grateful if you could link me to them 🙂


  8. September 30th, 2015 at 09:09 | #8

    I don’t have exact instructions. But the debian image I’m using is the one made by Loboris @ http://www.orangepi.org/orangepibbsen/forum.php?mod=viewthread&tid=342 and he’s also released the Linux kernel source code (kernel_3.4.9.tar.xz) on mega which should have gc2035 driver in drivers/media/video.

    Compiling gc2035 drivers should just be as compiling any Linux drivers.

    You may also want to check out with people who’ve built (and modified) the driver @ http://www.orangepi.org/orangepibbsen/forum.php?mod=viewthread&tid=70&extra=&highlight=camera&page=3

  9. Wim
    October 7th, 2015 at 03:22 | #9


    Can you explane how jou solve the premission issue?

  10. birky
    November 7th, 2015 at 19:35 | #10

    Please how can I vertically flip the camera image?

  11. December 15th, 2015 at 20:04 | #12

    According to http://forum.armbian.com/index.php/topic/504-quick-review-of-orange-pi-pc/, Orange Pi PC requires an extra board to use the camera above.

  12. January 6th, 2016 at 09:58 | #13

    Anybody noticed that the gc2035 image is mirrored?
    Things on the right side of the picture is on the left.
    Any easy fix?

  13. January 6th, 2016 at 11:22 | #14

    Motion should have an option just like the rotate option mentioned above to mirror the image.

  14. January 11th, 2016 at 03:33 | #15

    Motion alone does not fix that problem. I had to convert the script.bin to a fex file and edit the fex file item hflip to 0 and then convert back to a script,bin file and then rotate via motion to 180.

    That fixed it. convert programs bin2fex and fex2bin
    Only the linux version worked, the windows version gave a error.

  15. alpha le ciel
    February 4th, 2016 at 22:47 | #16

    hello , how to know my camera module of orange pi work or not … i try follow you but it’s not work at all

  16. February 5th, 2016 at 09:57 | #17

    @alpha le ciel
    First, make sure you have connected it the right way. If that’s OK, then check whether you see any error messages when you type the commands.

  17. alpha le ciel
    February 5th, 2016 at 20:42 | #18

    now i can fix it easily … before i use orangepi-debian-jessie-xfce , but it does’nt work …. now i install news os OrangePI-PC_Ubuntu_Vivid_Mate.img to my orange-Pi.. and then it’s work properly .. download it https://drive.google.com/folderview?id=0B1hyW7T0dqn6fndnZTRhRm5BaW4zVDVyTGlGMWJES3Z1eXVDQzI5R1lnV21oRHFsWnVwSEU&usp=sharing
    and get os and install OrangePI-PC_Ubuntu_Vivid_Mate.img … and follow cnxsoft and then can use that thing 😀

  18. Nachiket
    February 22nd, 2016 at 20:26 | #19

    Hi, Can anybody post a tutorial on how to get opencv working with orange pi pc ? In debian or Linux.

  19. April 1st, 2016 at 14:14 | #20

    I tried according step by step, but unfortunately the camera “unable to open video device” in browser. I used Firefox Browser and url : http://localhost:8081
    can you help me to solve it?


  20. April 6th, 2016 at 09:15 | #21

    One person did some improvements, to the frame rate notably, and others -> http://www.sistemasembarcados.org/2016/04/orange-pi-camera-with-v4l2loopback-vidcopy.html

  21. April 6th, 2016 at 09:23 | #22

    I know this guy. He’s a expert in OpenCV (computational vision) and lives in Rio de Janeiro – Brazil. Their name is Leonardo Lontra.

  22. Clive Pengelly
    July 9th, 2016 at 15:50 | #23

    Please can you give me a step by step instruction of how you solved this problem. I have tried for 5 days now with all different OS and I cant get it to work. I get no video at all. The only OS that sees the camera is the Android version which is installed on the OP Plus

  23. Lutz Fechner
    July 31st, 2016 at 05:53 | #24

    Steps described work fine with the OPI Lite. Image quality is ok. I’d say quality of the RPI Cam is a bit better. But good enough for my purpose and OPI+Cam is cheaper than RPI Camera alone.

    Only thing I noticed is that CPU consumption is quite high. Even if no client is connected. I disabled motion detection already to lower power consumption.

    Is there a way to stream using uv4l like you can on Raspbian?

  24. July 31st, 2016 at 10:14 | #25

    @Lutz Fechner
    It’s not something I’ve tried. Orange Pi camera is relying on V4L2 here, and uv4l appears to be a different driver implementation. Why not just use motion to stream the video?

  25. August 17th, 2016 at 04:16 | #26

    Thank you for publishing this guide – it really helped me setup motion on my Orange Pi Lite.

    Question: What prevents the motion folder’s files from growing until it consumes all space?

  26. August 17th, 2016 at 09:20 | #27

    Your might want to create a cron job to delete older files.

  27. August 17th, 2016 at 21:33 | #28

    Setting output_normal=off in motion.conf stopped the jpg photos from being created but it still creates .swf files, which will still fill up the folder. I haven’t figured out how to stop their creation. I just want video via the 8081 web portal.

  28. August 17th, 2016 at 21:45 | #29

    Solved it! In motion.conf, setting the following stops creation of both .jpg and .swf files:


  29. tkaiser
    August 18th, 2016 at 02:16 | #30

    BTW: We now have the ability on H3 boards to use ffmpeg with GC2035 (and most probably also OV5640) cameras to record video using Allwinner’s HW h.264 encoder freeing up the CPU cores completely: http://forum.armbian.com/index.php/topic/1842-ffmpeg-with-cedrus-h264-hw-encoder-h3-cmos-camera/#entry14157

    I hope a few more video enthusiasts join the party since these are really great news to get rid of Raspberries (still my only use case for these devices: using raspivid to record HW accelerated h.264)

  30. Sancho
    August 19th, 2016 at 14:15 | #31

    I managed to get mjpg_streamer running with the camera!

  31. Ivalion
    October 20th, 2016 at 19:41 | #32

    You have to edit the “stream_maxrate 4” parameter in order to change the framerate.

  32. Ben
    December 2nd, 2016 at 06:17 | #33

    Please write a mor concise tut that I can follow to! Thanx in advance

  33. Ferri
    February 11th, 2017 at 06:40 | #34

    Hi, on a OPI Lite + gc2035 (+ expansion board) and Debian Jessi (Linux orangepilite 3.4.113-sun8i) I failed to get the camera working.
    Both gc2035 and vfe_v4l2 modules are loaded and live. but I have these on my syslog, while camera connected:

    [ 13.398284] [CSI_ERR][GC2035]sensor_read err at sensor_detect!
    [ 13.398297] [CSI_ERR][GC2035]chip found is not an target chip.

    and no /dev/videoX at all. i2cdetect doesn’t show any device.

  1. No trackbacks yet.