Raspberry Pi Camera: turn off the LED

Since our camera is placed behind a window glass and the LED causes reflection, there’s a need to turn it off. Current versions of Raspbian seem to ignore the disable_camera_led=1 setting in /boot/config.txt. Fortunately, we can control the led over GPIO 32 on model B+ (this used to be GPIO 5 on older models):

sudo sh -c 'echo "32" > /sys/class/gpio/export'
sudo sh -c 'echo "out" > /sys/class/gpio/gpio32/direction'

Turn the LED off:

sudo sh -c 'echo "0" > /sys/class/gpio/gpio32/value'

Turn the LED on:

sudo sh -c 'echo "1" > /sys/class/gpio/gpio32/value'

This should work for the regular Pi camera as well as the Pi NoIR.

Context

Streaming video from the Pi is easy, following the instructions here: Streaming Raspberry Pi Camera. You may want to create two tiny scripts for convenience.

start_camera.sh:

sudo raspistill -w 640 -h 480 -q 5 -o /tmp/stream/pic.jpg -tl 100 -t 9999999 -th 0:0:0 -n &
LD_LIBRARY_PATH=/opt/mjpg-streamer/ /opt/mjpg-streamer/mjpg_streamer -i "input_file.so -f /tmp/stream -n pic.jpg" -o "output_http.so -p 9000 -w /opt/mjpg-streamer/www" &

stop_camera.sh:

sudo pkill -6 mjpg_streamer
sudo pkill -6 raspistill

One more thing, I needed to update the firmware to get the camera working:

sudo rpi-update

2 thoughts on “Raspberry Pi Camera: turn off the LED”

Comments are closed.