Page 1 of 1

No way to use GPIO pins

Posted: Tuesday 04 November 2025 11:09
by happyuser
New on that software I cannot succeed in what I consider the first stage, controlling a Led.

I tried with 3 different OS to use gpio hardware on my raspberry Pi3 without success.
I have just built a new SD card with Bookworm for which I thought sysfs Gpio was available. I added gpio as hardware but cannot switch any pin ON or OFF. When I read the wiki about GPIO I read :

Domoticz currently supports two ways of accessing the pins:

1. SYSFS GPIO. This is a standardised way of connecting to pins that is used on a lot of devices, and can be used without a driver. It is the prefered method within Domoticz.
2. The CLASSIC way is to install a driver, like WiringPi or PiGPIO.

and under OPTION 1 SYSFS I read :
4 You can manually set the output pins on or off using this command. One is on, zero is off.
echo 1 > /sys/class/gpio/gpio4/value echo 0 > /sys/class/gpio/gpio4/value

But I cannot configure gpio that way ; if I try the answer is :
pi@Bookworm:~ $ echo 2 > /sys/class/gpio/export
-bash: echo: erreur d'écriture : Argument invalide

On the contrary, if I use a terminal, I can switch a pin with the command :
pi@Bookworm:~ $ gpioset gpiochip0 2=1 The Led glows
pi@Bookworm:~ $ gpioset gpiochip0 2=0 The Led gets dark

Is there a way to use the simpler system that is sysfs GPIO without using any external library or can I use the new version gpiochipN that is apparently resident in the kernel and that switches the Led perfectly?
Any advice will be appreciated.
Thank you

Edit :
I succeeded using gpio via command line using that syntax :
echo 514 > /sys/class/gpio/export
echo high > /sys/class/gpio/gpio514/direction
The Led is switched on

But I dont know how to use this within domoticz, when I try to add a switch I see "No sysfs gpio export"
What have I forgotten?

Edit one more :
Finally I get a full operating system but there are two things to consider to obtain a working interface :
1 - due to a new version of sysfs gpio implementation all pins are renumbered you should add 512 to the former number
Thus my led whose number was 2 is now 514 and the command lines are modified for example
pi@Bookworm:~ $ echo 514 > /sys/class/gpio/export
2 - before trying to use those signals to build devices, you have to declare all of the pins you want to use with command lines in a terminal
After that you see the lines declared in the tab "devices" and you should activate them (green arrow)

Re: No way to use GPIO pins

Posted: Tuesday 04 November 2025 14:36
by Rik60
happyuser wrote: Tuesday 04 November 2025 11:09 New on that software I cannot succeed in what I consider the first stage, controlling a Led.

I tried with 3 different OS to use gpio hardware on my raspberry Pi3 without success.
I have just built a new SD card with Bookworm for which I thought sysfs Gpio was available. I added gpio as hardware but cannot switch any pin ON or OFF. When I read the wiki about GPIO I read :

Domoticz currently supports two ways of accessing the pins:

1. SYSFS GPIO. This is a standardised way of connecting to pins that is used on a lot of devices, and can be used without a driver. It is the prefered method within Domoticz.
2. The CLASSIC way is to install a driver, like WiringPi or PiGPIO.

and under OPTION 1 SYSFS I read :
4 You can manually set the output pins on or off using this command. One is on, zero is off.
echo 1 > /sys/class/gpio/gpio4/value echo 0 > /sys/class/gpio/gpio4/value

But I cannot configure gpio that way ; if I try the answer is :
pi@Bookworm:~ $ echo 2 > /sys/class/gpio/export
-bash: echo: erreur d'écriture : Argument invalide

On the contrary, if I use a terminal, I can switch a pin with the command :
pi@Bookworm:~ $ gpioset gpiochip0 2=1 The Led glows
pi@Bookworm:~ $ gpioset gpiochip0 2=0 The Led gets dark

Is there a way to use the simpler system that is sysfs GPIO without using any external library or can I use the new version gpiochipN that is apparently resident in the kernel and that switches the Led perfectly?
Any advice will be appreciated.
Thank you

Edit :
I succeeded using gpio via command line using that syntax :
echo 514 > /sys/class/gpio/export
echo high > /sys/class/gpio/gpio514/direction
The Led is switched on

But I dont know how to use this within domoticz, when I try to add a switch I see "No sysfs gpio export"
What have I forgotten?

Edit one more :
Finally I get a full operating system but there are two things to consider to obtain a working interface :
1 - due to a new version of sysfs gpio implementation all pins are renumbered you should add 512 to the former number
Thus my led whose number was 2 is now 514 and the command lines are modified for example
pi@Bookworm:~ $ echo 514 > /sys/class/gpio/export
2 - before trying to use those signals to build devices, you have to declare all of the pins you want to use with command lines in a terminal
After that you see the lines declared in the tab "devices" and you should activate them (green arrow)
See topic:
viewtopic.php?t=43984

This is allready discribed in several topics how to use GPIO in Domoticz, useing Bookworm and Trixie.