Dead man‘s switch for ReefPi

Sral

Well-Known Member
Review score
+0 /0 /-0
View Badges
Joined
May 2, 2022
Messages
746
Reaction score
820
Review score
+0 /0 /-0
Location
Germany
Rating - 0%
0   0   0
I‘ve been thinking of adding some kind of dead man‘s switch to my Setup.

My current idea goes along the lines of using a small reliable microcontroller, like an ATtiny85 or similar, that receives a ping from ReefPi every minute or so. If no signal is detected for e.g. 3-5 minutes, the power to the RaspberryPi is cut for a few seconds (I’m thinking a p-channel MOSFET in the +5V line).

What are your thoughts about this ?
Most importantly: What are your experiences with the reliability of ReefPi on Raspberry PIs ?

If reliability is good, the added complexity of such a setup might actually cause more problems than it solves, after all.
 
Nutramar Foods

fishyjoes

Community Member
Review score
+0 /0 /-0
View Badges
Joined
Oct 10, 2022
Messages
43
Reaction score
73
Review score
+0 /0 /-0
Location
US
Rating - 0%
0   0   0
I have no experience with ReefPi or raspberryPi at all, however I spent several years doing embedded programming.
The concept you explain is known in the embedded world as a "watch dog timer" and is included in many microcontrollers (so you might not need another device).
I suggest you research whether raspberryPi have a watchdog timer and how to use it if they do.
 
Top Shelf Aquatics

theatrus

Valuable Member
Review score
+0 /0 /-0
View Badges
Joined
Mar 26, 2016
Messages
1,693
Reaction score
3,034
Review score
+0 /0 /-0
Location
Sacramento, CA area
Rating - 0%
0   0   0
I‘ve been thinking of adding some kind of dead man‘s switch to my Setup.

My current idea goes along the lines of using a small reliable microcontroller, like an ATtiny85 or similar, that receives a ping from ReefPi every minute or so. If no signal is detected for e.g. 3-5 minutes, the power to the RaspberryPi is cut for a few seconds (I’m thinking a p-channel MOSFET in the +5V line).

What are your thoughts about this ?
Most importantly: What are your experiences with the reliability of ReefPi on Raspberry PIs ?

If reliability is good, the added complexity of such a setup might actually cause more problems than it solves, after all.


The RPi does have a watchdog, but it does depend on more functionality working.

I built a SMC on the Pico board.

https://github.com/blueacro/pcb-reefpi-pico/blob/master/reefpi_pico_v2.pdf See page 3 (power switch) and page 4 (SMC controller).

Firmware and command set for reset is here: https://github.com/blueacro/reefpi-firmware-pico-smc
 
OP
OP
S

Sral

Well-Known Member
Review score
+0 /0 /-0
View Badges
Joined
May 2, 2022
Messages
746
Reaction score
820
Review score
+0 /0 /-0
Location
Germany
Rating - 0%
0   0   0
The RPi does have a watchdog, but it does depend on more functionality working.

I built a SMC on the Pico board.

https://github.com/blueacro/pcb-reefpi-pico/blob/master/reefpi_pico_v2.pdf See page 3 (power switch) and page 4 (SMC controller).

Firmware and command set for reset is here: https://github.com/blueacro/reefpi-firmware-pico-smc
The I2C command is likely send by a service, right ?
I was thinking about whether a GPIO flank triggered by ReefPi itself might be better, since the second service doesn’t necessarily mean that ReefPi itself is running.

Thanks a lot for the link, I found that my LM2596 module also has an enable pin that I can use to cycle power to my Pi Zero. Thankfully I have 2 DC/DC converters, so I can run the watchdog chip from the second one.
 

theatrus

Valuable Member
Review score
+0 /0 /-0
View Badges
Joined
Mar 26, 2016
Messages
1,693
Reaction score
3,034
Review score
+0 /0 /-0
Location
Sacramento, CA area
Rating - 0%
0   0   0
The I2C command is likely send by a service, right ?
I was thinking about whether a GPIO flank triggered by ReefPi itself might be better, since the second service doesn’t necessarily mean that ReefPi itself is running.

Thanks a lot for the link, I found that my LM2596 module also has an enable pin that I can use to cycle power to my Pi Zero. Thankfully I have 2 DC/DC converters, so I can run the watchdog chip from the second one.

Using a GPIO is also ok, aka "must be toggled every N seconds". You could also slide the watchdog resets as a I2C sensor read action.

The most important part is the watchdog should only be reset if the control loop is totally functioning (no paniced go routines, no hung sensors, etc). Its tricky.
 
www.dinkinsaquaticgardens.com
OP
OP
S

Sral

Well-Known Member
Review score
+0 /0 /-0
View Badges
Joined
May 2, 2022
Messages
746
Reaction score
820
Review score
+0 /0 /-0
Location
Germany
Rating - 0%
0   0   0
Using a GPIO is also ok, aka "must be toggled every N seconds". You could also slide the watchdog resets as a I2C sensor read action.

The most important part is the watchdog should only be reset if the control loop is totally functioning (no paniced go routines, no hung sensors, etc). Its tricky.
Good idea ! I could simply use the robo-tank pH driver and reset the timer every time I get an "r". That saves me a GPIO pin.

What exactly did you mean with the second paragraph ? Which "control loop" are you referring to ? I'm also not versed in what you mean with "paniced go routines" and "hung sensors" and why that would be important. Can you please elaborate a bit more on that ?
 

fishyjoes

Community Member
Review score
+0 /0 /-0
View Badges
Joined
Oct 10, 2022
Messages
43
Reaction score
73
Review score
+0 /0 /-0
Location
US
Rating - 0%
0   0   0
Which "control loop" are you referring to ?
They mean the main loop of the program - as opposed to an interrupt handler, timer handler, or a separate thread or anything like that because you want the watchdog to time out if the main loop hangs.

If you put the watchdog reset in a timer or interrupt handler the main loop can hang and the watchdog will keep resetting just fine because the timer or interrupt (or whatever) is a separate entity that is not hung.
 
OP
OP
S

Sral

Well-Known Member
Review score
+0 /0 /-0
View Badges
Joined
May 2, 2022
Messages
746
Reaction score
820
Review score
+0 /0 /-0
Location
Germany
Rating - 0%
0   0   0
@fishyjoes and @theatrus :
If I understand correctly this would need an understanding of how ReefPi handles its jobs.

Do you know if there is ReefPi functionality that is incompatible with this ? I‘m thinking whether for example timers are handled like this, vs running in the main ReefPi loop.
 
Top Shelf Aquatics

gbroadbridge

2500 Club Member
Review score
+0 /0 /-0
View Badges
Joined
Mar 25, 2021
Messages
2,814
Reaction score
2,804
Review score
+0 /0 /-0
Location
Sydney, Australia
Rating - 0%
0   0   0
I‘ve been thinking of adding some kind of dead man‘s switch to my Setup.

My current idea goes along the lines of using a small reliable microcontroller, like an ATtiny85 or similar, that receives a ping from ReefPi every minute or so. If no signal is detected for e.g. 3-5 minutes, the power to the RaspberryPi is cut for a few seconds (I’m thinking a p-channel MOSFET in the +5V line).

What are your thoughts about this ?
Most importantly: What are your experiences with the reliability of ReefPi on Raspberry PIs ?

If reliability is good, the added complexity of such a setup might actually cause more problems than it solves, after all.
My reef-pi has been running two years without crashing once. I virtually never reboot it.
A hardware watchdog is something I thought about, but I considered it a solution looking for a problem in my case.
 
OP
OP
S

Sral

Well-Known Member
Review score
+0 /0 /-0
View Badges
Joined
May 2, 2022
Messages
746
Reaction score
820
Review score
+0 /0 /-0
Location
Germany
Rating - 0%
0   0   0
My reef-pi has been running two years without crashing once. I virtually never reboot it.
A hardware watchdog is something I thought about, but I considered it a solution looking for a problem in my case.
Great to hear ! What version and features are you using ?
 

gbroadbridge

2500 Club Member
Review score
+0 /0 /-0
View Badges
Joined
Mar 25, 2021
Messages
2,814
Reaction score
2,804
Review score
+0 /0 /-0
Location
Sydney, Australia
Rating - 0%
0   0   0
Great to hear ! What version and features are you using ?
  • running 5.0, on Raspberry Pi 3 Model B Rev 1.2
pi@fluval-evo135:~ $ uptime
20:45:17 up 137 days, 34 min, 1 user, load average: 1.04, 0.75, 0.68

Using Temp sensors, and controlling power outlets for auto feeding, etc
 
BRS

Ranjib

7500 Club Member
Review score
+0 /0 /-0
View Badges
Joined
Apr 16, 2016
Messages
9,810
Reaction score
16,998
Review score
+0 /0 /-0
Location
Pleasant Hill, Concord
Rating - 0%
0   0   0
I‘ve been thinking of adding some kind of dead man‘s switch to my Setup.

My current idea goes along the lines of using a small reliable microcontroller, like an ATtiny85 or similar, that receives a ping from ReefPi every minute or so. If no signal is detected for e.g. 3-5 minutes, the power to the RaspberryPi is cut for a few seconds (I’m thinking a p-channel MOSFET in the +5V line).

What are your thoughts about this ?
Most importantly: What are your experiences with the reliability of ReefPi on Raspberry PIs ?

If reliability is good, the added complexity of such a setup might actually cause more problems than it solves, after all.
raspberry pi can use the hardware watchdog thats available on the board and exposed via systemd, i think. you have to do some investigation.
 

Polyp polynomial: How many heads do you start with when buying zoas?

  • One head is enough to get started.

    Votes: 27 10.6%
  • 2 to 4 heads.

    Votes: 145 57.1%
  • 5 heads or more.

    Votes: 65 25.6%
  • Full colony.

    Votes: 10 3.9%
  • Other.

    Votes: 7 2.8%

New Posts

Kessil
Back
Top