rahlquist
Posts: 149
Joined: Tue Jan 21, 2014 1:02 pm

Rpi2 LED control

Fri Feb 06, 2015 3:41 pm

Ok so far Dom has been a gem and given me this much info.

Code: Select all

#act off
echo none | sudo tee /sys/class/leds/led0/trigger

#pwr off
echo 35  | sudo tee /sys/class/gpio/export
echo out | sudo tee /sys/class/gpio/gpio35/direction
echo 0   | sudo tee /sys/class/gpio/gpio35/value

#act on
echo mmc0 | sudo tee /sys/class/leds/led0/trigger

#pwr on
echo 35  | sudo tee /sys/class/gpio/export
echo in  | sudo tee /sys/class/gpio/gpio35/direction
I had to update to latest firmware to get the led0 device.

The PWR led does not respond to that pwr on for me. What I have found works is;

Code: Select all

echo 35  | sudo tee /sys/class/gpio/export
echo out  | sudo tee /sys/class/gpio/gpio35/direction
echo 1   | sudo tee /sys/class/gpio/gpio35/value
The above does not stick after a reboot though. During reboot initally both LED work but the power one drops off during this part of the boot(over serial console)

Code: Select all

[    2.501309] Waiting for root device /dev/mmcblk0p2...
[    2.519111] Indeed it is in host mode hprt0 = 00021501
[    2.699025] usb 1-1: new high-speed USB device number 2 using dwc_otg
[    2.707116] Indeed it is in host mode hprt0 = 00001101
[    2.846801] mmc0: host does not support reading read-only switch, assuming write-enable
[    2.860212] mmc0: new high speed SDHC card at address 5379
[    2.867974] mmcblk0: mmc0:5379 SD16G 14.9 GiB
[    2.875763]  mmcblk0: p1 p2
[    2.909340] usb 1-1: New USB device found, idVendor=0424, idProduct=9514
[    2.917645] usb 1-1: New USB device strings: Mfr=0, Product=0, SerialNumber=0
[    2.927257] hub 1-1:1.0: USB hub found
[    2.932738] hub 1-1:1.0: 5 ports detected
[    3.068477] EXT4-fs (mmcblk0p2): mounted filesystem with ordered data mode. Opts: (null)
[    3.080003] VFS: Mounted root (ext4 filesystem) readonly on device 179:2.
[    3.089832] devtmpfs: mounted
[    3.095239] Freeing unused kernel memory: 396K (80767000 - 807ca000)
[    3.219178] usb 1-1.1: new high-speed USB device number 3 using dwc_otg
[    3.339449] usb 1-1.1: New USB device found, idVendor=0424, idProduct=ec00
[    3.348290] usb 1-1.1: New USB device strings: Mfr=0, Product=0, SerialNumber=0
[    3.360575] smsc95xx v1.0.4
[    3.423233] smsc95xx 1-1.1:1.0 eth0: register 'smsc95xx' at usb-bcm2708_usb-1.1, smsc95xx USB 2.0 Ethernet, b8:27:eb:79:0e:11
[    4.156954] udevd[175]: starting version 175
[    4.711666] bcm2708_i2c_init_pinmode(1,2)
[    4.743208] bcm2708_i2c_init_pinmode(1,3)
I moved this troubleshooting out of the other thread as not to clutter it anymore. If any mods want to delete the inital troubleshooting from there please feel free.

User avatar
rpdom
Posts: 17449
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Rpi2 LED control

Fri Feb 06, 2015 6:10 pm

To be able to control the PWR LED you first have to do

Code: Select all

echo 35  | sudo tee /sys/class/gpio/export
echo out | sudo tee /sys/class/gpio/gpio35/direction
The you turn it on with

Code: Select all

echo 1   | sudo tee /sys/class/gpio/gpio35/value

Code: Select all

echo 0   | sudo tee /sys/class/gpio/gpio35/value
and put it back to normal with

Code: Select all

echo in | sudo tee /sys/class/gpio/gpio35/direction
None of that will stick over a reboot.

If the PWR LED is turning off during normal usage then you not enough power is getting to your Pi. You may also see a coloured square in the top right of your screen.

rahlquist
Posts: 149
Joined: Tue Jan 21, 2014 1:02 pm

Re: Rpi2 LED control

Fri Feb 06, 2015 7:05 pm

rpdom wrote: If the PWR LED is turning off during normal usage then you not enough power is getting to your Pi. You may also see a coloured square in the top right of your screen.
Good info to have. I am running headless so I have no idea about the dot. The adapter I am using is rated at 5V 2A and is putting out 5.18-5.2v and on average 450ma but I have seen it spike as high as 680ma. I get the same behavior on an Anker charger, and powered from my PC's USB over console cable. I have a new 5v 3A buck converter on the way that I will feed from an old 120W laptop power supply. So hopefully that fixes things.

wilminator
Posts: 1
Joined: Wed Jun 17, 2015 2:22 am

Re: Rpi2 LED control

Wed Jun 17, 2015 2:28 am

I'm running Jessie (NOOBS Wheezy upgraded to Jessie online) and the commands provided above did not work for me. But this did:

Code: Select all

sudo su
echo 0 >/sys/class/leds/led1/brightness
I tried following but it did not work:

Code: Select all

sudo echo 0 >/sys/class/leds/led1/brightness
echo 0 > sudo tee /sys/class/leds/led1/brightness
I'm hoping to write this into a shutdown script.

Return to “General discussion”