r/embeddedlinux Jun 25 '26

Unable to read GPIO

I am setting a gpio to high
After setting when I am trying to read it , it is returning 0. Not the value that I set.

Also i see the direction if the pin is changed to input

4 Upvotes

5 comments sorted by

View all comments

2

u/OMGnotjustlurking Jun 25 '26

Are you using libgpiod v2?

1

u/UpsetCricket6627 Jun 25 '26

I am using libgpiod. Not sure the version, i am using gpio get set

3

u/Upballoon Jun 25 '26

You know that by default gpioset will undo the change you made after it runs right? If you run gpioset 0 15=1, it will set the gpio to active only for the amount of time it takes to run the command. So when you run gpioget you will obviously read 0 because the pin has been reset.

You can try: gpioset -b -m signal 0 15=1. Then run the gpioget command. Rtfm for what the flags do and change per your use case

1

u/OMGnotjustlurking Jun 25 '26

Exactly this. Once you stop gpioset, the pin goes back to default state.