Introduction
This tutorial explains the design of your Raspberry Pi camera and how you can connect, test and control it. A library of numerous parameters and commands that you can use to control your camera via the Raspberry Pi and a detailed data sheet offer you a comfortable introduction to the functionality of the Raspberry Pi camera and the associated infrared LEDs for the night vision function.
You don’t have a camera yet? Let’s get your’s here!
Here we go!
Prerequisite
What do you need? These are required for the connection of your Raspberry camera:
- Raspberry Pi (compatible with all models which have a camera interface -CSI-). For the connection to a Raspberry Pi Zero you need a special Zero flat-flex-cable as the connection socket is different.
- A micro SD-card (HC) with at least 8GB storage capacity, on which a bootable operating system is installed. In this tutorial we refer to the common operating system Raspberry Pi OS (formally Raspbian).
- A power supply with micro USB or USB-C (depends on your Pi) connector – output 5.0 V DC (‘=’, DC voltage); minimum 2A
- And for the operation, a screen with HDMI input, accordingly also a HDMI cable, as well as a USB keyboard and mouse if necessary (Unless you access the Raspberry Pi with your computer via remote display or SSH). Check which HDMI connector your Pi have.
We are not shipping to you country in our online shop? No big deal, just check out “Electreeks” on Amazon.
Scope of delivery
The package contents of the Electreeks Raspberry Pi camera comes securely packaged in anti-static film and a neat folding box. A small cover cap is included to protect the camera lens.
Construction
Camera module
The OV5647 CMOS (BSI) photo sensor installed in the camera has a resolution of 5 megapixels and can record videos in full HD quality (1080p) at 30 fps, as well as photos with a resolution of 2592 x 1944 pixels. It has an automatic infrared cut filter, which allows the camera to take night shots. The focus can be adjusted manually to suit the distance.
The integrated infrared cut filter ensures that infrared radiation is not picked up by the photo sensor during the day, thus avoiding a red tint in pictures.
There are contact surfaces on the front and back of the board’s four corners, as well as four holes. These are used to mount the infrared LED and at the same time to supply it with power.
The connection to the Raspberry Pi is done via a FFC ribbon cable AWM 20624 80C 60V VW-1. The socket for this is located below the lens.

Standard lens and wide angle lens
Currently two different Electreeks Raspberry Pi camera modules are available. One with a 75.7° (d) standard lens and one with 175° (d) wide angle lens (fisheye) in full screen format. The standard lens is roughly equivalent to a human’s field of view, whereas the fisheye lens offers an extended field of view due to the 175° wide-angle lens and the shortened focal length.
Infrared LED boards
Even though the infrared LED boards, which enable night vision in the first place, look quite inconspicuous, they contain many functional components. You can see them circled and numbered in the picture below. The infrared LED (2) is the heart of the board. It emits infrared light in a wavelength between 845 and 855 nanometers in the electromagnetic spectrum, which is picked up by the photosensor in the dark. Since this wavelength just borders on visible light, you can still see a red glow. But the majority is emitted in the non-visible infrared range. A diffusing lens (1) is plugged on top of this, which ensures that the light from the LED is well distributed in the room. This allows the camera to take an evenly illuminated night shot.
The LEDs automatically adjust to the lighting conditions due to the integrated photoresistor (3). On top of that, you can adjust the intensity via a small potentiometer (4) or turn off the LEDs if you don’t need them at the moment.
The module itself is supplied with 3.3 V directly from the camera module. This is possible because there are gold contacts (5) on the screw connections for power transfer. Since these are applied to the front and back, it doesn’t matter if the LED board or the camera module is on top. What you should avoid is to mount the IR LED board radiating to the back. Apart from the fact that it wouldn’t really be of any use, you would destroy the LED, as it is not protected against reverse polarity. The current consumption is between 200mA and 900mA.
Infrared light is characterized by its heat radiation. Therefore, two heat sinks, which are attached to the gold surfaces on the back, serve for better heat dissipation.

Assembly and installation
Now let’s get to the exciting part of this chapter. How can I install my Raspberry Pi camera? In fact, this is not particularly difficult. The first thing you should decide is where you want to use your camera. Do you want to use it only in the light? Then we recommend not to install the LED boards for the time being. They permanently emit infrared light and thus influence the image color more strongly. However, you can also switch off the LEDs after installation via the potentiometers. This is entirely up to you.
A note at the beginning: Always carry out the work in a voltage-free state. Disconnect your Raspberry Pi from the power supply beforehand. Also make sure that you do not discharge static electricity on the components. In the worst case, this can lead to a defect. It is therefore best to touch another metallic grounded object beforehand to be on the safe side. A radiator is always very suitable.
Attach the infrared LED boards:
- Mount the infrared LED board to the left and right side of the Raspberry Pi camera module using the screws and nuts, so that the infrared lights point in the same direction as the camera lens. It doesn’t matter which board you put on the left or right side. They are completely identical. The best thing to use for mounting is a small Phillips screwdriver and steady fingers.
Connection of the 15-pin FFC ribbon cable:
- To attach the flex cable to the camera, first lift the black bar on the connector base below the camera lens.
- Then, insert the ribbon cable into the fixture provided and push the bar back down to tighten it.
- Make sure that the cable is fully inserted and that its contacts are correctly positioned on the contacts of the connection socket on the camera module.
Connection of the 15-pin FFC ribbon cable:
- To attach the flex cable to the camera, first lift the black bar on the connector base below the camera lens.
- Then, insert the ribbon cable into the fixture provided and push the bar back down to tighten it.
- Make sure that the cable is fully inserted and that its contacts are correctly positioned on the contacts of the connection socket on the camera module.
Connect to your Raspberry Pi:
- Plug the cable into the designated Camera Connector (CSI) on the Raspberry Pi. This is located between the HDMI and the audio connector on the current models (on the RPi Zero it is located on the front side. Note that you need a different cable for this). Again, lift the bar on the connector socket beforehand and make sure you insert the flex cable correctly. Please don’t confuse it with the connection slot for the display. This is exactly the same. The two ports are usually labeled on the Raspberry Pi.
Compatibility with other developer boards
Basically, compatibility is given if the board (or expansion modules for it) have a CSI connector or similar and support the following hardware: Raspberry Pi camera V2 / OV5647 sensor.
Depending on the operating system and chipset, a different driver may be necessary.
Start-up
Last but not least, we need to set up the Raspberry Pi camera on the RPi. Again, this is no big deal and done quickly.
Set up the Raspberry Pi camera:
Start the Raspbian operating system. Open the LXTerminal in the upper ribbon and enter the command sudo raspi-config in the console. The configuration menu opens. Select the item 5 “Interfacing Options”. Under the item P1 you can now enable your camera by confirming the question “Would you like the camera interface to be enabled?”. That’s it.

Note that in older software versions of Raspberry Pi OS (Raspbian) the navigation of the configuration menu may differ slightly.
Optionally you can enable the camera setup in the GUI (graphical) based configuration menu. You can find this in the start menu, under settings in the menu item Raspberry Pi configuration. Under the tab Interfaces you have to activate the radio button “Camera”. If your Raspberry Pi is set to English, the navigation is as follows: Home Button – Preferences – Raspberry Pi Configuration – Interfaces – Camera – Enabled.


The setting requires a reboot of the Pi in each procedure.
Test Raspberry Pi camera:
To test if everything worked, switch back to the LXTerminal and enter the command vcgencmd get_camera. This will check if the camera is properly connected (detected) and if your Raspberry Pi computer supports the camera and the interface is enabled in the configurations as described above (supported).
- If supported=1 and detected=1, the camera is correctly set up and connected.
- If supported=0: check the software version of the Pi and update if necessary. Check if you have configured the camera correctly.
- If detected=0: The camera is not connected properly or there is no full contact to the camera due to dirt, damage, etc.
- If supported=0 is displayed, usually the camera is not detected either, so detected is also 0. This is a clear indication that the camera interface is not set up.
Now it is time to finally let us output a picture. The command raspistill -f should be sufficient for this at the beginning.
It gives you a preview in full screen 4:3 format for five seconds. If the image is a bit blurry, you can adjust it by turning the focus on the lens.
If you want to output the preview image longer, you can change the output length with the suffix -t and a value in milliseconds (without unit). Example: raspistill -f -t 20000 outputs the preview image for 20 seconds.
Control Raspberry Pi camera
In the following accordion menu you will find countless commands that you can use to operate the Raspberry Pi camera. Among them are settings for image and video capture and various filters.
With the introductory commands “raspistill” for image capture and “raspivid” for video capture you define what the camera should do. With the parameters like “-o” for location, “-br xxx” for brightness or “- -contrast xxx” for contrast settings, you define the additional capture settings.
The parameters can be entered either in a short notation with one hyphen or in a long version with two hyphens: “-br xxx” or “- -brightness xxx”. What is preferred is solely a matter of taste for the programmer.
Many of the parameters can be listed together in one command. Like for example:
raspistill -f -br 50 --rotation 90 -o pi/home/testimage.jpg
Explanation of the accordion menu:
At the top is the name of the parameter, behind it the code for it in short notation. Behind it is the value range, if needed.
In the content area is the code in short and long notation for copying, the description of the parameter and for some example images.
A standard shot with the Raspberry Pi camera with default parameters.
Parameter für Raspistill (Foto) und Raspivid (Video)
Help
Code
#picture raspistill -? raspistill --help #video raspivid -? raspivid --help
Description
With the help command you get a list of all possible parameters for the respective command entered, as well as a definition of the possible value range.
Output recording parameters in the terminal
Code
#picture raspistill -v raspistill --verbose #video raspivid -v raspivid --verbose
Description
If you implement this parameter in your code, the system returns an exact and detailed listing of the recording parameters and the processing as a protocol. If you output the parameter alone, all default values will be output accordingly.
Save and store recording
Code
#picture raspistill -o speicherpfad/dateiname.jpg raspistill --output speicherpfad/dateiname.jpg #video raspivid -o speicherpfad/videoname.h264 raspivid --output speicherpfad/videoname.h264
Description
With this parameter you can set the location and file name for your image or video. If this parameter is not entered, nothing will be saved.
For images you can specify a different file format. The following file extensions are available, which the system converts automatically: .jpg, .bmp, .gif and .png. The default is always .jpg (if you do not specify a file extension).
For videos, formats are supported that conform to the H.264 (MPEG4/AVC) encoding standard for videos or higher. Examples would be the file extension .h264 or .mkv.
A corresponding command can look like this: raspistill -o images/image1.png. The default directory is /home/pi/. The program does not create folders automatically. So the save path must already exist. If files with the same name are saved, the existing one will be replaced.
For photo or video series, which are to be saved, an automatic numbering can be done by the following suffix: %04d. The numerical value stands for the number of zeros.
raspistill -tl 1000 -t 10000 -o images/image series%02d.jpg would output the following 11 images in an interval of one second: ImageRow00.jpg, ImageRow01.jpg, ImageRow02.jpg … ImageRow10.jpg.
Timer
Code
#picture raspistill -t 10000 raspistill --timeout 10000 #video raspivid -t 10000 raspivid --timeout 10000
Description
The timeout parameter has a different function for the two commands.
With raspistill the parameter provides a recording delay of x milliseconds (image timer).
For raspivid it defines the recording length. In both cases it sets the length of the preview image. The input value is always in milliseconds.
For example, if you want to record a five minute video, the command would be: raspivid -t 300000 -o videos/shortfilm.h264.
The default value is always 5 seconds.
Image position and size
Code
#picture raspistill -p x,y,w,h raspistill --preview x,y,w,h #video raspivid -p x,y,w,h raspivid --preview x,y,w,h
Description
Creates an image preview in a specified window size and screen position. The parameters x and y specify the position of the image preview on the screen in pixels, where the upper left edge of the image are the coordinates 0, 0.
The parameters w (width) and h (height) specify the size of the image section in pixels.
The default format for photos is 4:3, for videos 16:9. If you specify an image size that differs from these formats, the image will be cropped to fit the frame.
An example can be:
raspistill -p 100,50,1024,512. The image is 100 px from the left edge and 50 pixels from the top edge. The preview displayed is 1024 px in image width and 512 px in image height. So the format is 2:1, which means that the image is cropped at the top and bottom.
Fullscreen
Code
#picture raspistill -f raspistill --fullscreen #video raspivid -f raspivid --fullscreen
Description
Uses the complete screen height and scales the screen width or vice versa. Here again the standard formats for raspistill in 4:3 and raspivid 16:9 apply.
It is not necessary to enter additional values.
The fullscreen is already stored as default parameter.
Image width
Code
#picture raspistill -w x raspistill --width x #video raspivid -w x raspivid --width x
Description
Changes the width of the saved image or video in pixels. This is useful if you don’t need the files in full resolution.
It makes sense to choose a smaller resolution to save disk space. The preview of the image at raspistill will still be in full resolution. With raspivid the preview is scaled up.
Image height
Code
#picture raspistill -h x raspistill --height x #video raspivid -h x raspivid --height x
Description
Changes the height of the saved image or video in pixels. This is useful if you don’t need the files in full resolution.
It makes sense to choose a smaller resolution to save disk space. The preview of the image at raspistill will still be in full resolution. With raspivid the preview is scaled up.
Image rotation
Code
#picture raspistill -rot x raspistill --rotation x #video raspivid -rot x raspivid --rotation x
Description
With this command you can rotate the image. This is suitable for image correction if your camera is operated in a position other than the default. However, due to hardware limitations only rotations of 0, 90, 180, 270 degrees are supported.
Flip horizontally
Code
#picture raspistill -hf raspistill --hflip #video raspivid -hf raspivid --hflip
Description
Mirrors the image along the horizontal axis. The image or video is mirrored.
Example image
Flip vertically
Code
#picture raspistill -vf raspistill --vflip #video raspivid -vf raspivid --vflip
Description
Mirrors the image along the vertical axis. The image or video is upside down.
Example image
Image sharpness
Code
#picture raspistill -sh x raspistill --sharpness x #video raspivid -sh x raspivid --sharpness x
Description
Changes the sharpness of the image. The default value is 0.
Example image
Sharpness 100
Image brightness
Code
#picture raspistill -br x raspistill --brightness x #video raspivid -br x raspivid --brightness x
Description
Changes the brightness of the image. The default value is 50. 0 is black. 100 is white.
Example image
Brightness 75
Contrast
Code
#picture raspistill -co x raspistill --contrast x #video raspivid -co x raspivid --contrast x
Description
Changes the contrast of the image. The default value is 0.
Example image
Contrast -25
Saturation
Code
#picture raspistill -sa x raspistill --saturation x #video raspivid -sa x raspivid --saturation x
Description
Changes the saturation, respectively the color intensity of the image. The default value is 0. A value of -100 produces a grayscale image/video.
Example image
Saturation -100
Exposure compensation
Code
#picture raspistill -ev x raspistill --ev x #video raspivid -ev x raspivid --ev x
Description
Changes the exposure compensation of the image. The default value is 0.
Example image
Exposure value EV 10
ISO Light sensitivity
Code
#picture raspistill -ISO x raspistill --ISO x #video raspivid -ISO x raspivid --ISO x
Description
The ISO value describes the light sensitivity of the photo sensor. The lower the ISO value, the darker and less sensitive the image.
Example image
ISO 700
Effects / Filter
Code
#picture raspistill -ifx x raspistill --imxfx x #video raspivid -ifx x raspivid --imxfx x
Description
The command puts an effect over the image.
The following effects are possible:
negative (negative image appearance), solarise (colored solarization), sketch (crayon drawing), denoise (noise reduction), emboss (embossing – gray/silver), oilpaint (oil painting look), hatch (hatching sketch effect), gpen (graphite sketch effect), pastel (pastel painting look), watercolour (watercolor painting), film (film look – slight image noise), blur (soft focus), saturation (color saturation of the image), colorswap (blue cast), washedout (faded/washed out image), posterise (gray-scale poster look with color accents), cartoon (cartoon drawing).
Images
Parameters especially for Raspistill (photo)
Image triggering by ENTER key
Code
#picture raspistill -k raspistill --keypress
Description
With the keypress parameter at raspistill, a photo can be taken by pressing the ENTER key, considering the selected timeout value. The process can be aborted by the key combination Ctrl + c or by x + ENTER.
The image series is saved by adding the suffix %04d to the image name, as described above in the Save parameter. The number in the suffix describes the number of zeros. An example is: raspistill -k -t 10000 -o images/keypress%02d.jpg.
Quality
Code
#picture raspistill -q x raspistill --quality x
Description
With -q or – -quality you can set the quality of the image.
But be careful: The quality has an effect on the file size. An image quality of 100 is almost completely uncompressed, so the images need a lot of storage space. The default value is 35.
Generate image raw data
Code
#picture raspistill -r raspistill --raw
Description
This option inserts the raw Bayer sensor data from the camera into the JPEG metadata.
Timelapse mode
Code
#picture raspistill -tl x raspistill --timelapse x
Description
With this parameter a recording is made in a specified interval in x milliseconds. Here it must be noted that the suffix %02d is appended to the file name.
With the example raspistill -t 6000 -tl 600 -o Images/Timelapse_%04d.jpg a picture is taken every 600ms and stored as: Timelapse_0000.jpg, Timelapse_0001.jpg, Timelapse_0002.jpg, … Timelapse_0010.jpg.
The value should be above 500ms, otherwise there will be delays in the recording. The LXTerminal will indicate this delay.
Parameters specifically for Raspivid (Video)
Bitrate of the video
Code
#video raspivid -b x raspivid --bitrate x
Description
Bitrate is an indicator of video quality. It describes the amount of data in a video. Changing the bit rate thus implicitly has an effect on the file size.
The specification in the LXTerminal must be in bits per second. For a bit rate of 10 Mbit/s, the parameter must therefore be “-b 10000000”.
The maximum bit rate is 25 Mbits/s. However, a bitrate above 17 Mbits/s will not show any noticeable improvement when recording in Full HD @ 30 fps. This value is also stored as the default value.
Frames per second (fps)
Code
#video raspivid -fps x raspivid --framerate x
Description
Adjusts the frame rate to the specified value. The minimum frame rate is 2 fps, the maximum is 30 fps. Default is 30.
Timed switch between recording and pause
Code
#video raspivid -td x_an,x_aus raspivid --timed x_an,x_aus
Description
This option allows to pause a video and restart it in certain time intervals. Two values are required for this: The first value is the power-on time. This is the duration in which the video is recorded. The second value, the off time, is the duration for which the video is paused. It is specified, as always, in milliseconds.
The total time of recording can be limited by the timeout option.
Example: raspivid -td 4000, 2000 -t 20000 -o videos/timed.h264. The output will then be a video with the off times cut out.
Manually switching between recording and pause
Code
#video raspivid -k raspivid --keypress
Description
Each time the Enter key is pressed, recording is paused or restarted. After entering the command, recording is started immediately.
Pressing x+Enter or Ctrl+c will stop recording and close the application. If you set a timeout value with -t, the application will be stopped as soon as you intend to start playback with ENTER outside the time window.
Activate image stabilizer
Code
#video raspivid -vs raspivid --vstab
Description
The parameter turns on video stabilization. By default, this function is disabled.