The Pi camera module includes a red LED in one corner of the PCB. This lights up when the camera is active. It’s really useful in giving a visual indication that the camera is doing something and most of the time you will be glad it is there.
However there are a number of reasons you might wish it wasn’t.
In my testing here are some of the reasons it can get in the way :
- It can cause reflections on objects you are trying to photograph giving them a red glow.
- For nature photography it scares animals.
- For security applications it may draw unnecessary attention to the device.
- It consumes power.
To disable the red LED you simply need to add the following line to your config.txt file :
disable_camera_led=1
To edit the config.txt file you can use Nano :
sudo nano /boot/config.txt
Use the arrow keys to scroll to the end of the file and add “disable_camera_led=1” to the last line. Press “CTRL-x” to quit. If prompted press “Y” followed by “Return” or “Enter”.
Reboot your Pi with “sudo reboot” and when you next use the camera the red LED will be disabled.
To enable the light again you can either use Nano to remove the line you added above or you can change it to “disable_camera_led=0”. Reboot the Pi and you will have your camera light back.
GPIO Control
Thanks to a hint by @TeamRaspi on Twitter I checked the schematics of the Rev 2 Pi and discovered that once disabled using the process above you can control camera LED using the GPIO. On the Model B you can use GPIO5 and on the B+ you can use GPIO32. I tested this in Python and it works fine. Here is an example script that blinks the camera LED five times :
#!/usr/bin/env python import time import RPi.GPIO as GPIO # Use GPIO numbering GPIO.setmode(GPIO.BCM) # Set GPIO for camera LED # Use 5 for Model A/B and 32 for Model B+ CAMLED = 5 # Set GPIO to output GPIO.setup(CAMLED, GPIO.OUT, initial=False) # Five iterations with half a second # between on and off for i in range(5): GPIO.output(CAMLED,True) # On time.sleep(0.5) GPIO.output(CAMLED,False) # Off time.sleep(0.5)
Here is a short clip showing the camera LED being turned on and off using Python :
UPDATE : Since the latest update to Raspbian the disable_camera_led feature appears to have stopped working. Hopefully it will be restored soon! The Python script still allows control of the LED.
22 Comments
Awesome. When I saw the RTFS comment on Twitter I thought that would be the end of it. Well done for looking it up. GPIO 5 here we come.
Hi, Thank you for this. I successfully disabled the light, later re-enabled it to show a friend, and now I am unable to disable it again. Any ideas why that would be?
Have you completely removed the disable_cam_led line from your /boot/config.txt file?
I am not able to turn off the led for some reason the command is in the config but just not recognizing it.
It seems to have broken in the latest version of the camera utility. Hopefully they will restore it soon!
Hey Matt
Have just recived my camera today 25-05-2013 and testet the change in the config.txt and it seems to be working just fine.
The LED is powered of when using it.
I haven’t made any python script at all, just the change in boot/config.txt and a reboot. 🙂
Which version of GPIO lib you use?
Just my version does not know 3-d parameter:
GPIO.setup(CAMLED, GPIO.OUT, initial=False)
TypeError: ‘initial’ is an invalid keyword argument for this function
I think the latest version is 0.5.2a. Do a full update (sudo apt-get update followed by sudo apt-get upgrade). Definitely looks like you’ve got an older version.
Great news for the GPIO 5 controlling the LED.
Thank you for the tip !
Is there a way that to get the status of the camera led so that I can use a different led as my indicator?
Rather than remember this method every time I rebuild my pi, I simply head to google and end up on this page 🙂 Thanks for the post.
Without changing the config.text file, i made 2 python programs out of this blinky program. clighton.py and clightoff.py. I just took out the time function and the off function for the on script, and the on function for the off script.
clightoff.py
#!/usr/bin/env python
import RPi.GPIO as GPIO
# Use GPIO numbering
GPIO.setmode(GPIO.BCM)
# Set GPIO for camera LED
CAMLED = 5
# Set GPIO to output
GPIO.setup(CAMLED, GPIO.OUT, initial=False)
GPIO.output(CAMLED,False) # Off
clighton.py
#!/usr/bin/env python
import RPi.GPIO as GPIO
# Use GPIO numbering
GPIO.setmode(GPIO.BCM)
# Set GPIO for camera LED
CAMLED = 5
# Set GPIO to output
GPIO.setup(CAMLED, GPIO.OUT, initial=False)
GPIO.output(CAMLED,True) # On
Thanks for this great tip it is working and now I am playing around with the LED control.
I noticed one thing when implementing the LED control python script you suggested:
A RuntimeWarning was raised upon the line “GPIO.setup(CAMLED,GPIO.OUT,initial=False)”:
RuntimeWarning: This channel is already in use, continuing anyway. Use GPIO.setwarnings(False) to disable warnings.
It still does the LED control trick except for this error message.
Without fully understanding what’s going on, I solved this referring to this:
http://www.raspberrypi.org/phpBB3/viewtopic.php?f=32&t=20034
Basically just adding the line “GPIO.cleanup()” at the end of the code, or in a try-finally group.
That warning message happens if you run a script after you’ve already used the GPIO pins. As you found adding the GPIO.cleanup() command at the end of the script stops that warning the next time you add the script. I tend to always add it at the end of larger scripts but it is missing from the smaller examples. It’s not anything to worry about but neater if you include it.
Just for completeness, on B+ version of the board the led is on GPIO32.
The python script works also on A+ version, with CAMLED = 32.
Hi – I must admit that I followed the /boot/config.txt changes to disable the LED before reading the Update about it not working on the latest version of Raspbian. Rather worse than just not switching the LED off it actually stopped the camera working on my system.
Will be trying the python code to stop the reflection affecting low light photo streaming.
Graham
This works fine on the B+ for me. Just the one line in /boot/config.txt.
Is there also a way to dimm the led?
Not as far as I am aware.
Thanks, Works great I have motion detecting movement and turning on camled when motion is detected.
Very old topic but just for completeness. On Pi Zero W the led is on Pin 40.