- Last update:

Raspberry Pi NoIR camera module and IR LEDs

Seeing in the dark with the Raspberry Pi camera modules and some infrared LEDs

🕒 5 min read

Category: Computers

Tags: raspberry pi, camera

Lately I've been looking into adding infrared LEDs to my Raspberry Pi, as I just purchased the latest camera module v3, in its NoIR (no infrared filter) edition.

Basic knowledge required

Physics courses in high school took place like forever ago, I basically remembered nothing. So I had to dig it up a little bit and study basics again (Ohm's law for instance 😅).

Raspberry Pi

Multimeter

A tool to measure various things. The "A" (Ampere meter) plug acts as a closed circuit, so never put the test leads into the home sockets! The "V" (Voltmeter) plug acts as an open circuit.

LEDS

Resistor needed

As seen above, with 2 LEDs in series, each with a forward voltage of 1.5V for 20mA, plugged on a GPIO pin supplying 3.3V, we need a resistor as follow:

I = V/R
IF = (VS - VF) / R
# IF = forward current, VS = supplied voltage, VF = forward voltage
0.020 = (3.3 - 1.5 - 1.5) / R
R = (3.3 - 1.5 - 1.5) / 0.020 = 15 Ω

Note that, if we shift our target amps from 20 to say 40mA to allow the LEDs to draw more current, their forward voltage will increase. Check the specs to know how much. Never aim higher than 60mA, as it's the maximum the Raspberry Pi can deliver.

Now if we have just one LED and aim for maximum current (60mA):

R = (3.3 - 1.5) / 0.060 = 30 Ω

That's why in the beginning of the article I wrote that 50 Ω is safe for almost all scenarios. 1.5V is among the lowest voltage values drawn by LEDs, since infrared LEDs are those that need the least. For a different color (blue for instance), the computation would most likely look like this, depending on the actual specs of course:

R = (3.3 - 2.5) / 0.060 = 13.3 Ω

What I ended up doing

In the end, I bought two 1.5V 5mm IR LEDs and a 6.8 Ohm resistor, that I soldered all together. The result is pretty nice, and it's working like a charm. By connecting it to a regular GPIO pin, I can programmatically turn it on and off.

A Raspberry Pi with two LEDs and a resistor
Before soldering
Two LEDs and a resistor soldered
After soldering

Note that the LEDs I bought have a wavelength of 940 nm. I believe the camera with embedded LEDs I had before was 850 nm. 850 nm is visible by the human eye (dim red) while 940 is not at all. 940 also appears less bright on video than 850, from my experience, in pitch dark.

Others who did it before me