Sysfs GPIO
Posted: Wednesday 01 October 2025 0:06
I am transferring my setup on RPI4 from bullseye to bookworm
Use a switch to switch 2 relays on GPIO 17 an GPIO 18
This is my setup script
In /etc/rc.local
Did this, then reboot, then added hardware Generic sysfs GPIO with option autoconfigure devices
Followed the Domoticz GPIO wiki.
Use a switch to switch 2 relays on GPIO 17 an GPIO 18
This is my setup script
Code: Select all
echo 17 > /sys/class/gpio/export
echo 18 > /sys/class/gpio/export
#-----------------------------------------------------------------------------
# Set direction = out
#
echo out > /sys/class/gpio/gpio17/direction
echo out > /sys/class/gpio/gpio18/direction
#-----------------------------------------------------------------------------
# Set active_low = 0 (false)
#
echo 1 > /sys/class/gpio/gpio17/active_low
echo 1 > /sys/class/gpio/gpio18/active_low
Code: Select all
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
# Print the IP address
_IP=$(hostname -I) || true
if [ "$_IP" ]; then
printf "My IP address is %s\n" "$_IP"
fi
sudo /home/pi/scripts/sysfs-init.sh
exit 0
Followed the Domoticz GPIO wiki.