Posts: 92
Threads: 12
Joined: Jan 2015
Reputation:
0
08-24-2015, 03:41 PM
(This post was last modified: 08-24-2015, 04:54 PM by danieljo.)
@ Curlymo: Same Problems i posted earlier one or two months ago.
I have actually the same Problem in my Ad-Hoc network and an RPi 2 with a 8 Port Relay Card on my Fish-Tank. I comment out the check function and compiled it manually so the Relays don't go in off state after a lost connection or pilight daemon reset.
Posts: 7,238
Threads: 92
Joined: Aug 2013
Reputation:
76
Can someone summarize the issue here?
Posts: 327
Threads: 32
Joined: Oct 2014
Reputation:
3
03-10-2016, 10:55 PM
(This post was last modified: 03-10-2016, 11:12 PM by terrar.)
Summary:
If using relay's with pilight 7 stable and also development after every reboot the state of the relay's is "on" in the webgui but "off" in real.
To get the correct state again you have to switch every relay device off/on/off in the gui. Without this pilight does not recognize the real state of the relays.
Error is also reported in issue #201 on github
Terrarium: RPi Model B Rev 2 / pilight 8.1.2 / stretch
Aquarium: RPi Model B Plus Rev 1.2 / pilight 8.0.6 / jessie
Posts: 7,238
Threads: 92
Joined: Aug 2013
Reputation:
76
A GPIO can be set as input or output. The problem is that as soon as you set the GPIO as input, the already set state cannot be read.
Example:
1. Set GPIO as output
2. Set GPIO as HIGH
3. Set GPIO as input
4. Read GPIO
This will result in a LOW reading while the GPIO is still HIGH.
So, reading the state of a relay cannot be implemented. What we can implement is a "bootstate". So as soon as pilight starts, it will set all relays to this state.
Posts: 1,095
Threads: 30
Joined: Mar 2014
Reputation:
18
03-11-2016, 08:50 PM
(This post was last modified: 03-11-2016, 09:14 PM by wo_rasp.)
The problem with the GPIO is even more complex. First of all the GPIO lines are General Purpose IO Lines, and that is the issue here. The GPIO interface has no provisions for what you are asking for.
During the boot sequence of the Pi, the state of the GPIO lines changes twice, before the final status of last known configuration of the pull up/down resistors is restored. Thus the first problem arises at this point in time.
AFAIK at this point in time, the OS has no clue whether the GPIO lines were used last as Input or Output lines, thus the logical state of the GPIO lines is still undetermined.
After start of the application, the application needs to remember its last state.
The current concept of pilight is doing so by reading its last config.json file. If pilight was able to terminate properly, it restores the last known state, if pilight was not terminated properly, well - there is a big question mark.
IMHO, for a 100% reliable solution to work, you do need to latch the states of the GPIO lines on an interface board, use some logic for latching and set/reset the latch registers using some kind of additional interface logic (strobe signals either edge or pulse triggered), and read the status of those latches back upon restart (using a R/W interface line and one or two address bits).
For the latches we were using 245 chips to implement 8 data lines. Nowadays you may want to look into 74LCX16245 chips. The strobe signals/RW/address lines can be implemented using rules.
Remember the aforementioned boot behaviour, while implementing the latch interface and logic.
Posts: 7,238
Threads: 92
Joined: Aug 2013
Reputation:
76
Where do you read the NPN advice?