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

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:

and enable the following line:

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.

Share this:
FacebookTwitterHacker NewsSlashdotRedditLinkedInPinterestFlipboardMeWeLineEmailShare

Support CNX Software! Donate via cryptocurrencies, become a Patron on Patreon, or purchase goods on Amazon or Aliexpress

ROCK 5 ITX RK3588 mini-ITX motherboard

40 Replies to “How to Use Orange Pi Camera in Linux (with Motion)”

    1. No, cameras for Orange Pi and Raspberry Pi are not compatible. Even ribbon cables are not similar – different number of pins and different width.

      (I know this post few years old but I think it is worth posting here correct answer for those who will read this in the future)

  1. @onebir
    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.

  2. @Richard
    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?

  3. @cnxsoft
    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.

  4. @cnxsoft
    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 🙂


  5. @Richard
    I don’t have exact instructions. But the debian image I’m using is the one made by Loboris @ 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 @

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

  7. 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.

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

  9. 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
    and get os and install OrangePI-PC_Ubuntu_Vivid_Mate.img … and follow cnxsoft and then can use that thing 😀

  10. 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

  11. 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?

  12. 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?

  13. @cnxsoft
    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.

  14. 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:

    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)

  15. 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.

  16. Hi,
    I’ve tried to follow the tutorial and everything worked until the access to localhost – I can’t access to the page.
    Can you please clarify this step? Where I can check the exact address (maybe I missed something and using wrong ip address)?


Leave a Reply

Your email address will not be published. Required fields are marked *

Khadas VIM4 SBC
Khadas VIM4 SBC