I did one more test after I had everything hooked up - I disconnected my internet cable at the wall and waited sure enough the router went off and then on. Your router should reboot and now is monitoring the internet. If all goes well, you can now put it all together and turn the Iot Power Relay off, disconnect the lamp, connect the router and turn the Power Relay back on. :~/Documents/RebootRouter $ sudo systemctl enable rvice :~/Documents/RebootRouter $ sudo systemctl start rviceĮnable the service to start at boot time: Test that the service starts without any errors: :~/Documents/RebootRouter $ sudo cp rvice /etc/systemd/system/rvice Save the file.Ĭopy the file to the systemd/system folder: Open up rvice and edit the ExecStart and WorkingDirectory lines with your full paths to the python code. I set up a service to run this at boot time so it is always running on my Raspberry Pi. The first set run with the -test parameter set, the second set are what will be used in all other cases. You can change the CONSTANTS in the top part of the program to whatever values you like. You can not just use -test, it must be the second parameter after -debug. You can just use -debug and see the messages. Note - this will print out debugging information and turn the lamp off and on as it will test out not connected to the internet. :~/Documents/RebootRouter $ python3 rpi-internet-monitor.py -debug -test Open up a terminal session in the folder you put the code and execute the following command: The main python program, rpi-internet-monitor.py can be run with 1 or 2 parameters for debugging and testing purposes. I also had to consider that maybe there is an outage in my area and the internet is going to be down for awhile - rare, but it does occur (at least in my area.) and I didn't want the router restarting every 6 to 8 minutes so I put in a flag that would postpone the next restart for 1 hour in this case. It then waits for 4 minutes before resuming the 2 minute internet connectivity check. After 2 minutes, the Pi powers up the internal USB hub causing the Iot Power Relay to switch on the router. If there are no returned 'pings' the Pi shuts off power to the internal USB hub which in turn causes the Iot Power Relay to switch off the router. As long as at least one of them responds, we are all good. I tested and installed it and so far so good!īasically, the Raspberry Pi checks for an internet connection every 2 minutes via a 'ping' to 2 different websites. Having an extra Raspberry Pi laying around and some python skill, I decided to look into how it could help with my dilemma and came up with this solution. Unfortunately, a couple of mornings I didn't have the internet - a review of the router logs for those days indicated that the internet 'disconnected' around 4:00 am and my router wouldn't connect unless I restarted it. At first, I just bought a digital timed power strip and set it to turn the router off at 2:00 am for 5 minutes. When I got back, I started to search for a good solution but couldn't find anything comprehensive enough for what I needed. I also thought of calling the power company and having them cut the power to my house for about 5 minutes - my S.O. I really didn't want to bother a neighbor to get past my security system and then find my router and restart it. Well, this has happened to me more often than I care for it to occur.Įarlier this year, I went out of town for 3 weeks and on the first day my router disconnected from the internet! This meant I had no connection to the things in my house I rely upon to 'check in' on periodically - e.g., Nest thermostat, Arlo cameras.Since I wasn't home, I could not restart my router. Is it frustrating to get up in the morning and have to 'reboot' the router to get the internet back? ![]() Have you ever noticed that you are no longer connected to the internet?
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |