Rpi5 Domoticz GPIO config

Please use template to report bugs and problems. Post here your questions when not sure where else to post
Only for bugs in the Domoticz application! other problems go in different subforums!

Moderators: leecollings, remb0

Forum rules
Before posting here, make sure you are on the latest Beta or Stable version.
If you have problems related to the web gui, clear your browser cache + appcache first.

Use the following template when posting here:

Version: xxxx
Platform: xxxx
Plugin/Hardware: xxxx
Description:
.....

If you are having problems with scripts/blockly, always post the script (in a spoiler or code tag) or screenshots of your blockly

If you are replying, please do not quote images/code from the first post

Please mark your topic as Solved when the problem is solved.
Post Reply
Wimpi
Posts: 4
Joined: Sunday 07 January 2024 12:52
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.1
Location: Belgium
Contact:

Rpi5 Domoticz GPIO config

Post by Wimpi »

I have an Rpi3B, with Buster OS and Domoticz

Bought an Rpi5, put Bookworm OS (64bit) on USB 3 and runs on stick.
Installed Domoticz and placed a backup of my 3B on the 5.

Now also know that wiringpi, which I worked with with Domoticz on my 3B, does not work on the Rpi5...


The fact that I do this best via SysFS or something is new to me and I can't get it right at all...

This is what I note in the domoticz sh file, for GPIO 5, relay control on/off in Domoticz:
echo 5 > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio5/direction
echo 0 > /sys/class/gpio/gpio5/value

But every time I want to add a switch (GPIO 5) in Domoticz, I see No-sysfs-GPIO exports

When I run 'dmesg'
I see in the list: export_store: invalid GPIO5

Do I need to configure the ports before installing Domoticz?

What am I doing wrong?
Someone who can help me or just with a new better step-by-step plan to make Domoticz work on my Rpi5 as it does on my 3B

Thank you in advance for your time.
willemd
Posts: 621
Joined: Saturday 21 September 2019 17:55
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.1
Location: The Netherlands
Contact:

Re: Rpi5 Domoticz GPIO config

Post by willemd »

You are aware that the Rpi 5 has a different way of handling GPIO when compared to all previous Pi's ?
Probably best to ask at the raspberry pi forums whether you can still use sysfs or what you should do to still use it. (it seems deprecated)
I think the domoticz documentation has not been updated yet for the Raspberry Pi 5.

Maybe this link helps? https://lloydrochester.com/post/hardwar ... intro-rpi/
Wimpi
Posts: 4
Joined: Sunday 07 January 2024 12:52
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.1
Location: Belgium
Contact:

Re: Rpi5 Domoticz GPIO config

Post by Wimpi »

Yes indeed, I have already read it.
That's why I'm having a bit of a problem with the GPIO.

I saw on the Raspberry site that it does work with GPIOzero.
But how do we integrate that...

And yes, the Domoticz site is not yet up to date.

I'll give it a try, wait and see...

Thanks for the link, please read it carefully and try it.
willemd
Posts: 621
Joined: Saturday 21 September 2019 17:55
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.1
Location: The Netherlands
Contact:

Re: Rpi5 Domoticz GPIO config

Post by willemd »

Since the sysfs commands are command-line commands to set/get gpio pins, the libgpiod seems to be a good alternative. The LED example provided seems also usable for your relay. I don't see separate commands for configuring the pin as output or input, so it seems this is automatically included in using gpioset or gpioget.
luckymr2201
Posts: 8
Joined: Wednesday 24 July 2019 8:30
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Rpi5 Domoticz GPIO config

Post by luckymr2201 »

Hello, I hope I am writting this question in the right section.

I have a rpi4B running with latest stable released Domoticz (2024.01)which among other things is using GPIO (pin 4) to detect if someone attempt to ring the bell at the entrance of my house.
This works very well using GPIO Sysfs and this declaration made at each boot:

sudo sh -c 'echo 4 > /sys/class/gpio/export'
sudo sh -c 'echo in > /sys/class/gpio/gpio4/direction'
sudo sh -c 'echo both > /sys/class/gpio/gpio4/edge'

My surprise comes from the rpi5 ). I found on it the gpio are completely changed but after many tries and error, it seems converting my 3 lines from the pi4 to:

sudo sh -c 'echo 403 > /sys/class/gpio/export'
sudo sh -c 'echo in > /sys/class/gpio/gpio403/direction'
sudo sh -c 'echo both > /sys/class/gpio/gpio403/edge'

gives the expected result at least using commands to check the state of my gpio:


pi@Pie5B:~ $ cat /sys/class/gpio/gpio403/value
1
pi@Pie5B:~ $ cat /sys/class/gpio/gpio403/value
0
pi@Pie5B:~ $ cat /sys/class/gpio/gpio403/value
0
pi@Pie5B:~ $ cat /sys/class/gpio/gpio403/value
1

The problem seems to come from Domoticz where it seems to detect 2 entries but none are working (change state when I put my GPIO to ground):

Has anyone already successfully used GPIO on Pi5 with Domoticz ? I read here and there that everything changed that Sysfs is depreciated but I see no alternative to it and second I get the impression the sysfs works when I run the command for my GPIO from a terminal so cannot see why Domoticz would not work.

Any help will be greatly apprecaited.
Wimpi
Posts: 4
Joined: Sunday 07 January 2024 12:52
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.1
Location: Belgium
Contact:

Re: Rpi5 Domoticz GPIO config

Post by Wimpi »

We have to wait …
But I hope anyone will find a solution 😉
elgringo
Posts: 92
Joined: Thursday 18 May 2017 8:08
Target OS: Raspberry Pi / ODroid
Domoticz version: Left
Contact:

Re: Rpi5 Domoticz GPIO config

Post by elgringo »

I got simular issues on a pi 5 with bookworm

I have connect a doorbell on GPIO 26 (pin 37)
With the file /sys/kernel/debug/gpio file I figured out it was gpio425.

Configured and hooked it up, domoticz did found gpio425:
Naamloos.png
Naamloos.png (8.2 KiB) Viewed 1760 times
Logging also seems to detect something:

Code: Select all

2024-02-03 15:56:53.028  Status: GPIO: Startup - polling:no interrupts:yes debounce:10msec inputs:1 outputs:0
2024-02-03 15:56:53.028  Status: GPIO: Edge detection started

2024-02-03 16:00:45.441  GPIO: Lighting 2 (Input)
2024-02-03 16:00:45.480  Status: GPIO: gpio425 new state = on
But the doorbell devices remains 'off'
elgringo
Posts: 92
Joined: Thursday 18 May 2017 8:08
Target OS: Raspberry Pi / ODroid
Domoticz version: Left
Contact:

Re: Rpi5 Domoticz GPIO config

Post by elgringo »

HvdW
Posts: 504
Joined: Sunday 01 November 2015 22:45
Target OS: Raspberry Pi / ODroid
Domoticz version: 2023.2
Location: Twente
Contact:

Re: Rpi5 Domoticz GPIO config

Post by HvdW »

sysfs is deprecated in bookworm.

For buster ande everything preceding it there is this sysfs setup.
In ~/scripts there is this file named sysfs-inti.sh

Code: Select all

#! /bin/sh
#-----------------------------------------------------------------------------
# Init sysfs GPIO ports
#-----------------------------------------------------------------------------

#-----------------------------------------------------------------------------
# unexport
#
#echo 4 > /sys/class/gpio/unexport
#echo 12 > /sys/class/gpio/unexport
#echo 13 > /sys/class/gpio/unexport


#-----------------------------------------------------------------------------
# export
#

echo 17 > /sys/class/gpio/export
echo 18 > /sys/class/gpio/export
#echo 22 > /sys/class/gpio/export

#-----------------------------------------------------------------------------
# Set direction = in
#
# echo in > /sys/class/gpio/gpio4/direction

echo out > /sys/class/gpio/gpio17/direction
echo out > /sys/class/gpio/gpio18/direction
#echo out > /sys/class/gpio/gpio22/direction
#-----------------------------------------------------------------------------
# Set active_low = 0 (false)
#
# echo 0 > /sys/class/gpio/gpio4/active_low
echo 1 > /sys/class/gpio/gpio17/active_low
echo 1 > /sys/class/gpio/gpio18/active_low
#echo 1 > /sys/class/gpio/gpio22/active_low

#-----------------------------------------------------------------------------
# Set edges = none
#
# echo none > /sys/class/gpio/gpio4/edge


#-----------------------------------------------------------------------------
# Set pullups
#
# raspi-gpio set 4 pu


#raspi-gpio set 11 dl
#raspi-gpio set 12 dl


#-----------------------------------------------------------------------------
In /etc/rc.local place this line before the exit statement, to be executed @startup

Code: Select all

sudo ~/scripts/sysfs-init.sh
Bugs bug me.
Wimpi
Posts: 4
Joined: Sunday 07 January 2024 12:52
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.1
Location: Belgium
Contact:

Re: Rpi5 Domoticz GPIO config

Post by Wimpi »

With a sh script can I set my GPIO for my outputs, relay.
So I can set the gpio one or zero

Code: Select all

#!/bin/bash
sudo gpioset gpiochip4 10=1
But what I don’t know, is how I can read a GPIO continuously for check soms alarms, inputs.
That doesn’t work with a sh script in Domoticz I believe.

I think I need a Python script within Domoticz for read a GPIO pin.
But don’t know how to begin.
I have to set first the GPIO pin as a input, low or high at startup.


Someone could give soms hints or what should I do?
vwstepha
Posts: 23
Joined: Saturday 17 March 2018 12:18
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: Marseille
Contact:

Re: Rpi5 Domoticz GPIO config

Post by vwstepha »

Hello everyone!!
Still no solution for GPIO, even in version 2024.7?
It's really a shame. I use 5 GPIO on my RPi.
Thank you for your help!
Rpi Master 2022.2 Beta 14905 (Broadlink ok.....)
Rpi slave 2020.2 (since 10days but with error...) with 2 rflink(rts 433 + 833)
User avatar
waltervl
Posts: 5148
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Rpi5 Domoticz GPIO config

Post by waltervl »

It should be implemented in 2024.7 https://github.com/domoticz/domoticz/pull/6019
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest