I started using my raspberry pi again (B+), reinstalled the os (Raspbian) and tried to play with some leds. But I'm having trouble writing a value to GPIO 23. The circuit is very simple, just a led and a resistor it is currently on and I can't turn it of. I executed on the console:

root@raspberrypi:~# echo "23" > /sys/class/gpio/export
root@raspberrypi:~# echo "out" > /sys/class/gpio/gpio23/direction
root@raspberrypi:~# echo "0" > /sys/class/gpio/gpio23/value 

But the led is still on

  1. Export worked because it created the directory for gpio23
  2. Direction seems to work since the check returned correctly root@raspberrypi:/home/pi# cat /sys/class/gpio/gpio23/direction out
  3. Yet when checking the value I get: root@raspberrypi:/home/pi# cat /sys/class/gpio/gpio23/value 1
  4. And when reading the debug info: root@raspberrypi:/home/pi# cat /sys/kernel/debug/gpio GPIOs 0-53, platform/20200000.gpio, pinctrl-bcm2835: gpio-23 ( |sysfs ) out hi gpio-35 ( |? ) in hi gpio-47 ( |? ) out lo

I definitively have permissions, since I'm running it as root. Any ideas on why it may not write the value?

This is the circuit I'm using

  • Apart from the fact that you seem to have logged on a root, which is unnecessary and undesirable, what you have posted seems OK. Are you sure you are using the correct pin. Try writing "0" & "1" and see if the info changes. – Milliways Oct 16 '16 at 2:01
  • the steps seem ok to me. just to scratch off one possiblity, can you post a photo of the wiring ? there might be something off there. many times the cause is the wrong pin being hooked up. bcm mode GPIO 23 corresponds to physical pin 16 on the header while physical pin 23 corresponds to bcm mode GPIO 11. I know I have been stung by this confusion a couple of times. – Shreyas Murali Oct 16 '16 at 2:01
  • The thing is that I don't even care about the wiring at this point. I write the new value to the gpio23/value file, and when I read it again it still shows the old value. – Troveldom Oct 16 '16 at 7:30
  • I tried the exact 3 commands as you but I got the expected results (0 when writing "0" and 1 when writing "1" to the value file). Can you check if the behavior is same on any other GPIO pin ? Also can you share the output of uname -a and /etc/os-release ? – Shreyas Murali Oct 17 '16 at 5:34
  • root@raspberrypi:/home/pi# uname -a Linux raspberrypi 4.4.21+ #911 Thu Sep 15 14:17:52 BST 2016 armv6l GNU/Linux root@raspberrypi:/home/pi# cat /etc/os-release PRETTY_NAME="Raspbian GNU/Linux 8 (jessie)" NAME="Raspbian GNU/Linux" VERSION_ID="8" VERSION="8 (jessie)" ID=raspbian ID_LIKE=debian HOME_URL="raspbian.org" SUPPORT_URL="raspbian.org/RaspbianForums" BUG_REPORT_URL="raspbian.org/RaspbianBugs" – Troveldom Oct 18 '16 at 3:17

A GPIO set as an output and driven low will only show high if it is connected to an external power source greater than that driving it low.

I suggest you switch off the Pi and post a photograph of the circuit.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.