I was wondering if there is a way to find out that a GPIO is under voltage, say - the GPIO is set to HIGH. I need to be able to check this in a linux terminal, using a command or a script that simply returns true or false.

I tried to use the WiringPi library, but I can't seem to find a function in documentation that would be able to do this. Any help appreciated.

2 Answers 2


To control GPIO from the command line you can use the GPIO Sysfs Interface for Userspace. For example to monitor pin 26 you can do:

Prepair pin 26

rpi ~$ sudo -Es
rpi ~# echo 26 > /sys/class/gpio/export
rpi ~# echo "in" > /sys/class/gpio/gpio26/direction

Get status of pin 26

rpi ~# cat /sys/class/gpio/gpio26/value

Finish monitoring of pin 26

rpi ~# echo 26 > /sys/class/gpio/unexport
rpi ~# exit
rpi ~$

Here you can find a small script to Continuesly monitor GPIO input change/events in Bash with inotify.


Use wiringPi's gpio command.

man gpio for details.

Use pigpio's pigs command.


sudo pigpiod # start the pigpio daemon

pigs r 4     # read GPIO 4
pigs w 4 1   # set GPIO 4 high

man pigs for details.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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