IDCT Bartosz Pachołek

Cookies Warning

This website uses cookies: We inform you that this site uses own, technical and third parties cookies to make sure our web page is user-friendly and to guarantee a high functionality of the webpage and for statistics tracking. In order to use some (contact form) parts of the website you need to accept the use of cookies.

IDCT EYE Alpha: Raspberry Pi Camera

Published 2020-01-16

Some time ago I have published a short post on a Polish digg-like (reddit-like) website called about my little pet-project, a small hobby to make a night camera with *raspberry pi. You can read the original post in Polish by following this link:

The camera has reached a state in which in can be used experimentally therefore I am sharing some information about the camera which may encourage or help you to start a similar project on your own!


  • It is just a hobby project, meant only for education, curiosity and not to develop a commercial product.
  • Battery operation: at least for few hours.
  • Night-vision support: recording of IR light.
  • Price: meant to be relatively cheap.
  • Size: small enough to allow easy movement.

Parts (elements)

Most of the parts were bought in a Polish shop "botland". Some on aliexpress. You should be able to get them online in any similar shop closer to your location or also on aliexpress. Prices are in Polish złoty PLN which usually stays at a conversion rate of 1 EUR ~ 4 PLN, 1 USD ~ 3.5 PLN. Pasting links to botland as specs and photos should make your findings of similar parts in your local shops easier.

Excluding the costs of soldering, hot-gluing and cables the cost is below 200 PLN.

I have also bought a mini tripod:

Early notes

Already at this point we could make some things potentially better: for example we could use different IR LEDs than the ones coming from the camera set. We could use one relay module or single board with two relays. Switching could be done using a transistor and resistors valid for particular IR LEDs which should reduce the size and price of the package. Usage of different leds or better converter should reduce the need of using two, like I did.

Charging and powering could be replaced with a 2S model where we would connect these two li-ions serially in contrast to current parallel connection. There are cheap 2S (7,4) Li-ion chargers available on aliexpress. Such change would reduce powering problems to a good one or two 5V stabilizers. Another approach would be a mixed model where LEDs would be powered from a parallel connection and rpi by a step-down converter or stabilizer.


Camera: front Camera: back

Some of you could be picky about the quality of the fittings in the final product here, yet like I mentioned: for me it is just a hobby so I made everything at home, in front of my desk. I lacked some proper tools to make the carvings for leds, camera, switches etc. so I have used a knife here. Additionally my manual skills are quite limited.

The size of the device is the size of the Z4 chassis (129x149x50mm) with additional 0.5cm for the camera lens in the front and about 1cm coming from the lever switch in the back.

Inside, my limited manual skills are noticeable even more: Camera inside: front Camera inside: back

Connections' diagram



  • Red LED should be connected thru a respective (to the specs) resistor, due to the fact I lacked a required one in my inventory I have dummy-wired the LED here.
  • Step-up chargers use a bit of power even if device is turned off.


This is the most unfinished part of my camera project as so far I am using mostly software made by other people. Using Raspbian OS. Camera and preview web interface are provided by RaspiMJPEG and RPi Cam Web inferface ( The interface itself is quite functional, yet quite dirty in terms of the code and looks so I plan to make my own, from scratch. Still, many thanks for it's developers as it saves a lot of time during initial dev phases!

Interface Recorded media

In version 0.2 I plan to add support for switching IR filter and IR LEDs using software buttons in the existing interface and option to start youtube live streaming.


A tip: streaming from raspberry pi to youtube is very easy! You just need to install and run ffmpeg:

raspivid -o - -t 0 -fps 25 -b 2000000 | ffmpeg -re -ar 22050 -ac 1 -acodec pcm_s16le -f s16le -ac 1 -i /dev/zero -f h264 -i - -vcodec copy -acodec aac -ab 128k -g 50 -strict experimental -f flv rtmp://[identifier]

Where [identifier] is your unique id from youtube's live streaming page in your user's panel. Bitrate and resolution can be changed in the first part of the bash command, those are settings for the raspivid application. For example:

raspivid -o -o -t 0 --fps 50 -b 1000000 -w 1280 -h 720

Although we do not send sound it is needed for youtube so add /dev/zero dummy string like I did above.

buttons support

I have added two physical buttons (tact switches) to allow:

  • night-mode switching: turning on/off the IR LEDs and IR filter of the camera.
  • starting / stopping video recording.

To use them I utilize a small microframework called Loopi (

warning: this application is provisional/temporary

include "vendor/autoload.php";

$config = [
    'output' => [
            'ir' => 24,
            'ir2' => 23,
            'ircut' => 13,
            'red' => 5
    'input' => [
        'record' => 26,
        'setter' => 19

class Buttoner extends IDCT\Loopi
    protected $recording = false;
    protected $nightMode = false;

    protected $ledTime = 0;
    protected $ledState;

    protected function pipeWrite($msg)
        $pipe = fopen("/var/www/cam2/FIFO", "w");
        fwrite($pipe, $msg . "\n");
    protected function loop()
        $state = file_get_contents("/var/www/cam2/status_mjpeg.txt");
        $this->recording = ($state == 'video');
        if ($this->switchedDown('record')) {
            if ($this->recording) {
                $this->pipeWrite('ca 0');
            } else {
                $this->pipeWrite('ca 1');
            $this->recording = !$this->recording;

        if ($this->switchedDown('setter')) {
            $this->nightMode = !$this->nightMode;
            $this->setGpioValue('ir', $this->nightMode ? $this::GPIO_HIGH : $this::GPIO_LOW);
            $this->setGpioValue('ir2', $this->nightMode ? $this::GPIO_HIGH : $this::GPIO_LOW);
            $this->setGpioValue('ircut', $this->nightMode ? $this::GPIO_HIGH : $this::GPIO_LOW);

        if ($this->recording) {
            $ledTime = time();
            if ($ledTime > $this->ledTime) {
                if ($this->ledState === $this::GPIO_HIGH) {
                    $this->setGpioValue('red', $this::GPIO_LOW);
                    $this->ledState = $this::GPIO_LOW;
                } else {
                    $this->setGpioValue('red', $this::GPIO_HIGH);
                    $this->ledState = $this::GPIO_HIGH;
            $this->ledTime = $ledTime;
        } else {
            $this->setGpioValue('red', $this::GPIO_LOW);

$app = new Buttoner();

pipeWrite function allows communication with RaspiMJPEG using a pipe. Sending ca 0 to pipe ends, ca 1 starts recording. Application reads current state from a file stored by the web interface application (in my case: /var/www/cam2/status_mjpeg.txt). Of course it is provisional. Even such temporary state should be already improved by storing that file in memory instead of SD card.

I target to add photos taking support by pressing of a button and different behaviors depending on how long button was pressed.

Red LED flashes while camera is recording.


Current solution does not provide any battery level indication. Recording time without IR LEDs is about 8 hrs, peaking to 12. With IR LEDs it is 3 up to 4 hours. Usage of two, although cheap and weak, charging modules gives a positive charging balance so it is possible to charge while using the camera.

Camera itself uses the OV5647 sensor which allows recording in 1920x1080 at 30 fps or 1280x720 at 60 fps. Important note is that sensor physical size differs a bit from these resolutions which affects the field of view. While recording in Full HD FOV is limited and gives zoom effect as whole sensor is not in use. In 720p mode more of the sensor is in use and therefore the brightness is much better. I believe that sensor is fully utilized in 1296x972 and 1640x1232 resolutions.

The IR LEDs from the camera package provide coverage of about 3 meters so it is about enough for a small room.

Recording provides a raw h264 stream which is converted to MP4 when stopped. This takes a while as RPi Zero is not a speedster. Why I have used that model in particular? Due to power consumption: it is very low when compared to other Raspberry Pis or Orange Pis.

Another problem is the lens focus. Because it is physically fixed you need to set it manually before or while recording: it is impossible to adjust it software-side.

It is worth of mentioning that lens gives quite nice macro photography capabilities!

Sample night photos

Sample 1 Sample 2 Sample 3 Sample 4 Sample 5

Sample night movie

I shall try to provide a better movie in the future, when I get more experience with focus adjustment.

Warning: content under this box is not visible due to your cookies settings as requires to load contents from YouTube. If you believe that you have made a wrong choice then please follow this link to reset your cookies settings and accept 3rd party cookies:

reset cookies settings

Sample daylight photos

Sample day 1 Sample day 2 Sample day 3 Sample day 4

Sample daylight movie.

I shall try to provide a better movie in the future, when I get more experience with focus adjustment.

Warning: content under this box is not visible due to your cookies settings as requires to load contents from YouTube. If you believe that you have made a wrong choice then please follow this link to reset your cookies settings and accept 3rd party cookies:

reset cookies settings


Please accept my apologies for any mistakes in the text.

Like I said before: for me it is just a hobby so it will be slowly improved, but without any pressure.

If you have any questions or suggestions please use to website's contact form.