### Raspberry Pi GPIO

To be able to use the Raspberry Pi GPIO, make use of sysfs, which is part of the raspbian operating system.
Define GPIO in Domoticz Script domoticz.sh
Add the GPIO settings at the end of the file, using
sudo nano /etc/init.d/domoticz.sh
Example GPIO18:
Note: sleep 1 between 'export' and 'direction' to allow time for the operating system to set up the GPIO number specific direction file
echo "GPIO..."
echo "18" > /sys/class/gpio/export
sleep 1
echo "out" > /sys/class/gpio/gpio18/direction
echo "GPIO OK"
... add more
Then reboot (sudo reboot).
To test the GPIO port using echo
Turn ON
echo "1" > /sys/class/gpio/gpio18/value
Turn OFF
echo "0" > /sys/class/gpio/gpio18/value
Hardware Device
Create a Hardware Device "Generic sysfs GPIO" with settings
• Data Timeout = disabled
• Auto Configure Devices = checked
• Debounce = Default
Then restart Domoticz (sudo service domoticz.sh restart).
Note: If restart fails, reload the daemon prior restart: sudo systemctl daemon-reload
In the Domoticz Logfile and entry is set for the GPIO.
2017-08-09 14:40:44.048 Sysfs GPIO: Startup - polling:no interrupts:no debounce:50msec inputs:0 outputs:1
Because Auto Configure Devices option is set and outputs:1, a new device is created and added to the Devices list.
This is GPIO18 as defined previous in the Domoticz Script.
Switch Configuration
Open the Devices list, select the new device GPIO18 and add the device.
Select Switches, GPIO18 and test ON/OFF.
If required, make further changes using Edit.
Hints
Check GPIO exports by running: gpio exports
GPIO Pins exported:
18: out 0 none

Changed: , Category: Domoticz Home Automation, File: T6C186M1356.htm, ID: 1356