Subj : how to write and read back GPIO pin states with lgpio To : All From : =?UTF-8?Q?Josef_M=C3=B6llers?= Date : Sun Aug 04 2024 22:13:55 Hi, I used to use the sysfs interface to the GPIO pins (/sys/class/gpio) but I understand that is deprecated nowadays. So I tried to switch to lgpio which looks OK. However, I have problems writing and reading back pin states from different programs. My setup is as follows: I have a couple of relays (solid state and mechanical ones) that control various external devices. I use one program to switch devices on and off and want to use another program to read back the state of the device. Doing that with sysfs is easy: 1) export the pin: echo $pin > /sys/class/gpio/export echo $direction > /sys/class/gpio/gpio$pin/direction this needs to be done only once. 2) write the state of the pin, thus switching the device on/off: echo $newstate > /sys/class/gpio/gpio$pin/value this is done every time this is required 3) read back the state of the pin value=$(Usenet Gateway (3:770/3) .