[RESOLVED] fast-gpio read only returns 0



  • I am not able to get the current status of a gpio pin, I am typing fast-gpio read 0 and it will return 0 even if I just set the pin high with fast-gpio set 0 1.

    Not sure where to look to resolve this issue

    Thanks



  • @Christopher-Whitney I wonder if you might actually have GPIO 0 connected to ground (i.e. zero voltage).

    fast-gpio read 0
    

    Reads what ever GPIO pin is externally connected to.

    Only if it is left floating (i.e. not connected to anything) will it return whatever you set it to by:

    fast-gpio set 0 1
    

    or

    fast-gpio set 0 0
    

    GPIO pins are intended for setting or accessing external signals and not really intended for storing values.
    You should also note that it is generally best to first set the direction (input or output) usage of a GPIO pin using one of:
    for input:

    fast-gpio set-input <pin-number>
    

    or for output:

    fast-gpio set-output <pin-number>
    

    By way of confirmation, I have just done some tests:

    1. With GPIO 0 left unconnected:
    root@Omega-0A97:~# fast-gpio set 0 0
    > Set GPIO0: 0
    root@Omega-0A97:~# fast-gpio read 0
    > Read GPIO0: 0
    root@Omega-0A97:~# fast-gpio set 0 1
    > Set GPIO0: 1
    root@Omega-0A97:~# fast-gpio read 0
    > Read GPIO0: 1
    root@Omega-0A97:~#
    

    The read reflects what the pin was last set to

    1. With GPIO 0 connected to ground
    root@Omega-0A97:~# fast-gpio set 0 0
    > Set GPIO0: 0
    root@Omega-0A97:~# fast-gpio read 0
    > Read GPIO0: 0
    root@Omega-0A97:~# fast-gpio set 0 1
    > Set GPIO0: 1
    root@Omega-0A97:~# fast-gpio read 0
    > Read GPIO0: 0
    root@Omega-0A97:~#
    

    The read reflects that the pin is connected to a zero level irrespective of what it is set to



  • @Kit-Bishop That is helpful. so testing with a pin that I am not using it reads the value, my plan is I have a few relays that I am controlling and I would like to know if one of the pins is set high to trigger the relay? I have the pin connected to an NPN transistor and that might be the issue?

    EDIT: adding a resister fixed the reading. thanks for clearing that up.


Log in to reply
 

Looks like your connection to Community was lost, please wait while we try to reconnect.