0

Restarting program on loss of internet connection
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Restarting program on loss of internet connection

by wsquared58 on Mon Sep 16, 2019 7:17 am

How do I go about restarting my weather program on loss of internet connection once that connection is reestablished. I've got the loss of AC power restart service sorted out and have a backup battery source to minimize those but based on my experience so far, loss of internet connection is much more likely and I know that that kills the data feed to IO until I restart program.
Seems like another systemd service script would be appropriate but not sure how to monitor loss than reconnection of internet.

wsquared58
 
Posts: 150
Joined: Sun Jun 09, 2019 9:13 pm

Re: Restarting program on loss of internet connection

by franklin97355 on Mon Sep 16, 2019 7:44 am

What hardware are you trying to connect"

franklin97355
 
Posts: 21204
Joined: Mon Apr 21, 2008 2:33 pm
Location: Lacomb, OR.

Re: Restarting program on loss of internet connection

by wsquared58 on Mon Sep 16, 2019 8:01 am

RasPi 3B+ and downstream weather oriented sensors on proto board.
I have one of your PowerBoost 1000C and hefty battery to support utility power hiccups, but that won't help the internet connectivity issue.

It's been a while since I just let it all run for a few days straight to see the faults that come in but internet provider here stinks so drops of and comes back pretty quickly. See it in the IO oriented program but highlights a problem I need to resolve.

Going to let it run for a bit to get a better sense of fault messages but I expect it is pretty standard.

wsquared58
 
Posts: 150
Joined: Sun Jun 09, 2019 9:13 pm

Re: Restarting program on loss of internet connection

by franklin97355 on Mon Sep 16, 2019 8:19 am


franklin97355
 
Posts: 21204
Joined: Mon Apr 21, 2008 2:33 pm
Location: Lacomb, OR.

Re: Restarting program on loss of internet connection

by wsquared58 on Mon Sep 16, 2019 8:47 am

Thanks. I'll check those out.
My problem isn't really the Pi, it reconnects of it's own accord once the internet comes back. It is restarting the the program. It is the equivalent of the service I battled with in regards to loss of AC power.

Just that in this instance the program needs to go "connectivity is back so restart program". This is about the reestablishing the connection to IO. Program stops because IO connection is written in to program. Loss of connection, program fault.

I'm still debating whether to run a hardwired Ethernet cable to Pi, vs relying on Pi wifi and residence wifi router not sure how much of a difference in loss of connectivity that relates to in real world environment but that is a separate question

wsquared58
 
Posts: 150
Joined: Sun Jun 09, 2019 9:13 pm

Re: Restarting program on loss of internet connection

by millercommamatt on Mon Sep 16, 2019 2:41 pm

I put my Adafruit IO stuff under a try/except conditional to catch any errors in sending data to Adafruit IO.

This keeps the python script from stopping due to a temporary connection error.

millercommamatt
 
Posts: 467
Joined: Tue Jul 31, 2018 4:57 pm

Please be positive and constructive with your questions and comments.