PiNoIR Raspberry Pi Camera Board, Raspberry Pi Noir
Table of Contents
Raspberry Pi Camera Board and PiNoIR:
The Camera Board and the PiNoIR are small bare digital camera boards that specially developed for use with the Raspberry Pi (see Figure 1). When the camera board came out first, due to the simple connection, very easy operation, and diverse application possibilities it become very popular. This is going to be a very detailed tutorial as I will be explaining how to take images, how to record videos, how to live stream on web page etc.
Sometime later, a second model of the camera was developed that was named PiNoIR carries. The same image sensor is installed in the PiNoIR as in its predecessor, and it does not differ in its external form either. The PiNoIR is missing only the infrared filter in the camera lens. With such a filter it is possible to detect infrared to capture light. A normal remote control suddenly appears in the picture of the PiNoIR to the flashlight that illuminates a dark room, but more on that later. Both camera modules have the following key data:
- 1080p video recording
- CSI interface to the Raspberry Pi
- 5 megapixel resolution
- Size of the module about 20 x 25 x 9mm
Amazon Purchase Links:
Wireless Keyboard and Mouse for raspberry pi:
Night vision Camera for Raspberry Pi:
Oled HDMI touch display for raspberry pi:
Other Tools and Components:
Super Starter kit for Beginners
PCB small portable drill machines
*Please Note: These are affiliate links. I may make a commission if you buy the components through these links. I would appreciate your support in this way!
Connection:
The connection of both cameras is also identical. Both modules have an approximately 10 cm long CSI ribbon cable, which is inserted into the intended terminal on the Raspberry Pi is introduced. Because the process requires a lot of tact the first time we will go into more detail. When you connect the camera, the Raspberry Pi must be switched off! Make sure you disconnect the minicomputer from the supply voltage beforehand! The CSI socket is behind the LAN socket. A plastic clamp is mounted to hold the cable in place. The position of the CSI socket is similar in all Raspberry Pi B versions, from model B+ however, it is still between the camera connection and the LAN socket Audio / video connection. On the A models you will find the socket between HDMI and Audio / video connection.
Use two fingers to lift the clamp slightly. The plastic clamp should now stand loosely over the plug connection. The ribbon cable of the camera module, now insert it vertically from above into the clamp. The bare contacts of the line point away from the LAN socket (see Figure 2)! hold the connection cable still tight, and now press the Plastic clamp with the other hand back down. This should snap into place easily. Check it out, the vertical seat of the cable in the socket again. The camera is now ready to go.
Drivers for the camera modules are already integrated in the current Raspbian distributions, which can be activated during installation or afterwards. Power up the Raspberry Pi. After logging in, call the configuration menu with the following command:
sudo raspi – config
Now select point 5 – Enable Camera and activate loading the driver in the next window (see Figure 3). After a restart the drivers are loaded and you can use the cameras completely. The Operation can take place in different ways. Depending on the application, you operate the camera manually in bash or in Python. You also have the option to set up a video stream and this in a browser or with video software.
raspistill and raspivid:
Let’s start with the commands available by default under Raspbian raspistill and raspivid, which are easy to use in the terminal or in bash Enable scripts. raspistill takes a photo. However, it takes some further parameters that define this function more precisely. A simple photo in JPG format can be saved under any path with the following command will:
raspistill -o / tmp / myPicture.jpg
The standard resolution is 2592 x 1944 pixels. Adjust the resolution with the Parameters -w and -h:
raspistill -o / tmp / myPicture.jpg -w 800 -h 600
The resulting photo would now have a resolution of 800 x 600 pixels. A video under the same path is created with the following command:
raspivid -o / tmp / myVideo.h264
Without any further parameters, the above command takes a five-second video in resolution 1920 1080. You can influence the recording length with the parameter -t. The time is specified in milliseconds. For example, the command a ten-second video:
raspivid -o / tmp / myVideo.h264 -t 10000
raspistill and raspivid can be controlled using various options (see the below table). You can combine multiple options in one command by typing simply write the options one after the other. Example:
raspivid -o video.h264 -w 1204 -h 768 -sh 50 -t 10000
option | function | Available for | Example |
-o | Image location | raspistill | -o /home/pi/demo.jpg |
-o | Video location | raspivid | -o /home/pi/video.h264 |
-w -h -q | Width, height and quality | both | -w 800 -h 600 -q 80 |
-tl n | Timelapse (image every nms) | raspistill | -tl 3000 |
-f | HDMI full screen preview | both | -f |
-n | no preview | both | -n |
-sh n | Sharpness (-100 to 100) | both | -sh 75 |
-co n | Contrast (-100 to 100) | both | -co 50 |
-rot n | Rotation (0 to 359 degrees) | raspivid | -rot 275 |
-t n | Length of video (in ms) | raspivid | -t 3000 |
-t n | Time to photo (in ms) | raspistill | -t 3000 |
-b n | Bit rate (bits / second) | raspivid | -b 15000000 |
A listing of all parameters for raspistill and raspivid would take several pages include. With the following commands you can view the possible parameters in bash display:
raspistill | less
raspivid | less
Camera control through Python:
The integration of the camera in Python opens up many other possibilities for automated use of the camera in your projects. So are combinations with various sensors, such as motion sensors or buttons, to trigger the Camera conceivable. As usual, the use in Python requires its own library, which should be installed in advance. We recommend you to use picamera in the straight current version to use.
The package manager installation takes place conveniently:
sudo apt-get install python3-picamera
The software, like any other software, comes with the update and upgrade Commands kept up to date:
sudo apt – get update
sudo apt – get upgrade
After installation, the library can be used as usual in the head of the program code with import picamera. In the following example we create a small program, the image is created with the Raspberry Pi Camera as soon as a motion sensor has recognized an object.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
#! / usr / bin / python3 # Rpicam.py file import picamera, sys, time import RPi.GPIO as GPIO cam = picamera.PiCamera () cam.resolution = (1920, 1080) GPIO.setmode (GPIO.BOARD) GPIO.setup (7, GPIO.IN, pull_up_down = GPIO.PUD_DOWN) def motion (pin): t = time.strftime ("% Y_% m_% d -% H:% M:% S") print ("Create photo") cam.capture ('/ folder / image_% s.jpg'% t) print ("Photo saved") return GPIO.add_event_detect (7, GPIO.RISING) GPIO.add_event_callback (7, motion) # with minimal CPU load at the end of the program # wait with Ctrl + C try: while True: time.sleep(5) except KeyboardInterrupt: GPIO.cleanup() sys.exit() cam.close() |
We took the Python code from my pervious article, »PIR Motion Sensor«. The motion function, however, has been changed and now contains the command to create an image. With every detected movement there is now an image recorded and with the current date and time according to the following scheme saved:
demo_2020_07_02-20:59:45.jpg
Of course, the program code does not provide all of the picamera commands available.
View videos and pictures on the Raspberry Pi:
You can display the recorded images and videos directly on the Raspberry Pi. Make sure that you connect a display device (e.g. via HDMI) to the Raspberry Pi. A display of pictures and videos over an SSH connection does not work with these examples. You can e.g. with the program fbi directly in a text console display. Install the package with:
apt-get install fbi
You can then display images with the following commands:
- The command fbi/home/pi/photo.jpg opens the image file and displays it.
- You can display all images in a folder with fbi /home/pi/Bilder/*.jpg, for example to let.
- A slideshow of all images in the folder with a display time of five seconds For each picture you generate with the command fbi /home/pi/photo/*.jpg -t 5.
fbi can also be easily operated using the keyboard (see below table 1).
Table 1: Operation of the image viewer fbi
button | Function |
Cursor keys | Move picture |
Up/down | show next / previous picture |
+/- | Zoom image |
H | to show help |
V | Show / hide status bar |
P | Stop slideshow |
Shift + D | Clear image |
R / L | Rotate image (right / left) |
Q | exit program |
To play videos you can use the omxplayer, which is available under Raspbian installed by default. You are playing a saved video with the following Command from:
omxplayer/home/pi/video.h264
Here, too, you have a few options for operation during video playback (see table 2). You call help of the program with omxplayer -h.
Table 2: Operation of the video player omxplayer
Button | Function |
Space bar | Play / pause |
Right/ left | a few frames forward / back |
Up / down | Chapter forward / back |
1 | play slower |
2 | play faster |
Q | exit program |
Video streams and online access:
The small camera modules only become really exciting when we use them together with the strengths of the Raspberry Pi. This is how the little PC can take the picture even stream live from the camera. There are also various options to access the live image of the camera or automatically take photos online. We’ll start with the easiest of all livestreams, really to be precise, it is not a video, but a constantly updated image. A liquid one so video is not to be expected – accordingly, the Implementation. You should have installed a web server on the Raspberry Pi. Now create in the Server’s DocumentRoot folder, by default in /var/www/, an HTML file with the name cam.html. As content of the file write the following lines:
1 2 3 4 5 6 7 8 |
<html> <head> <meta http - equiv = Refresh Content = "3;"> </ head> <body> <img src = "image.jpg"> </ body> </ html> |
The mini website only shows the image file bild.jpg. The Refresh command Content in the <head> area of the file updates the website every three seconds. The The associated Python script below regularly generates a photo and saves it under image.jpg. If the Python file is in the same folder as the picture, if the script is under a different path, so adjust the storage location of the picture to /var/www/image.jpg.
1 2 3 4 5 6 7 8 9 10 11 12 |
#! / usr / bin / python3 # browserstream.py import time, sys import picamera cam = picamera.PiCamera () try: while True: cam.capture ('image.jpg') time.sleep (3) except KeyboardInterrupt: cam.close () sys.exit () |
Now start the Python script and let it run. Now when you have the cam.html with a browser, you will see a new image every three seconds Camera.
VLC live stream
Another method is streaming into the home network via VLC player. Herewith achieve a fairly smooth video. First install the VLC player the Raspberry Pi:
sudo apt-get install vlc
The following command starts a live stream with a resolution of 800 600 pixels and makes this accessible on port 8554 of the Raspberry Pi:
raspivid -t 0 -o – -w 800 -h 600 | \
cvlc -vvv stream: /// dev / stdin \
– sout ‘#rtp {sdp = rtsp: //: 8554 /}’: demux = h264
Add an additional -n after raspivid to preview output via HDMI to deactivate. The stream now runs through (Ctrl) + (C) until the command is canceled. Use the -t parameter to determine the runtime in milliseconds (0 stands for “Infinite”). Now you can watch the stream e.g. with the VLC player from another PC in Get network from. To do this, select the item Open network stream on your video player, and enter the IP address of the Raspberry Pi, followed by the port. The correct spelling looks like this, for example:
rtsp: //192.168.0.38:8554 /
The video player now shows the live image from the Raspberry Pi camera. For streaming video straight to the web browser.
PiNoIR:
Even if the operation and handling of the PiNoIR version is similar to that of the normal RasPi-Cam is identical, we would like to specifically focus on the special features of the PiNoIR. The PiNoIR is similar to the Raspberry Pi Cam, but does without an infrared filter. This gives you the option of using infrared light sources as a torch and thus to illuminate dark surroundings in the image of the PiNoIR. Infrared light is not perceived by the human eye and is available so for use as a nightly surveillance camera. Do the first Test with a normal infrared remote control. Darken the room, hold on Press any button on the remote control and take a picture with the PiNoIR. You will see that the infrared light from the remote control is already sufficient to partially illuminate the completely darkened room. Use the principle we now for our own invisible headlight.
Infrared spotlight for the PiNoIR:
Infrared LEDs serve as the basis for the headlights. These are in everyone Electronic retailers or online shops can be obtained easily and cheaply. Additionally you should have a few resistors ready, which are on the required Forward voltage based, as well as a piece of perforated or strip grid board. An infrared LED usually has a forward voltage of 1.2 V to 1.5 V and requires a current of approx. 20mA at this voltage. We design the headlight so that it is still connected to the 5 V pin of the Raspberry Pi can be operated. Should you build an even bigger headlight, so it may be necessary to operate it on an external voltage source.
The headlight we planned consists of six LEDs (see Figure 4). Three of these are connected in series and two in parallel. Every strand gets a series resistor. If you recreate our headlight as shown, can be operated with 5 V and requires less than 40mA. You can so operate it on the 5 V pin of the GPIO strip.
Assemble the headlight according to the circuit diagram. Best use for this a strip or breadboard. We have the connections as a two-pole pin header executed. You are of course free to choose the type of connection. An ordinary camera takes the switched-on IR headlight completely differently true than the PiNoIR camera (see Figure 5). The six LEDs are enough to Illuminate objects in pitch dark rooms up to a distance of approx. 4 meters. Everything built into a beautiful housing, results in a cheap do-it-yourself Night vision device.