Supervise your Home Server with a Watchdog and Heartbeats (Raspberry Pi, ESP8266, Docker)

Spread the love



Home automation systems must run all the time. Today we will make sure you get an alarm on your Smartphone if something goes wrong with your system. But how can we create an alarm if the server is down? Let’s have a closer look.
I am a proud Patreon of @GreatScott!, @ElectroBOOM , @Electronoobs , @EEVblog , and others. No Microsoft Teams, Zoom

Links:
Raspberry Pi4 US: https://amzn.to/3pP32HZ
Raspberry Pi4 DE: https://amzn.to/3avMgaG
Raspberry Pi4: https://ebay.to/3n1sPef
ESP-01s Boards: https://s.click.aliexpress.com/e/_9iUH4Z or https://amzn.to/2SDaYAx or https://ebay.to/3wG6I1K
ESP-01 Programmer: https://s.click.aliexpress.com/e/_AsjoBx or https://ebay.to/2S0TcY3
ESP-01 Programmer: https://s.click.aliexpress.com/e/_9w9QoH or https://amzn.to/3i7BUTQ
Solid Polymer Capacitors 1000uF : https://s.click.aliexpress.com/e/_A2Ii9X
Power supplies (110-240V – 3.3V) : https://s.click.aliexpress.com/e/_A6pG3T
Prototype Boards : https://s.click.aliexpress.com/e/_AtVdgv

Sketch and Flow: https://github.com/SensorsIot/Heartbeat8266
Telegram Library: https://github.com/witnessmenow/Universal-Arduino-Telegram-Bot
PubSub Library: https://github.com/knolleary/pubsubclient

The links above usually are affiliate links that support the channel (no additional cost for you).
Supporting Material and Blog Page: http://www.sensorsiot.org
Github: https://www.github.com/sensorsiot
My Patreon Page: https://www.patreon.com/AndreasSpiess
Discord: https://discord.gg/JfgDSa8
If you want to support the channel, please use the links below to start your shopping. No additional charges for you, but I get a commission of your purchases to buy new stuff for the channel
My Amazon.com shop: https://www.amazon.com/shop/andreasspiess
For Banggood https://bit.ly/2jAQEf4
For AliExpress: http://bit.ly/2B0yTLL
For Amazon.de: http://amzn.to/2r0ZCYI
For Amazon UK: http://amzn.to/2mxBaJf
For ebay.com: http://ebay.to/2DuYXBp

https://www.facebook.com/profile.php?id=100013947273409
https://twitter.com/spiessa
https://www.instructables.com/member/Andreas%20Spiess/
Please do not try to email me. This communication channel is reserved for my primary job
As an Amazon Associate, I earn from qualifying purchases
#no#midroll#ads

source

27 thoughts on “Supervise your Home Server with a Watchdog and Heartbeats (Raspberry Pi, ESP8266, Docker)

  • June 6, 2021 at 8:49 am
    Permalink

    Hello Herr Spiess,
    One piece that has been missing from my IoT system is the ability to remotely monitor without paying for some service. I understand I could port-forward on my router but I think that creates a security risk on my home network. Would appreciate your input. Thanks for the video.

    Reply
  • June 6, 2021 at 8:49 am
    Permalink

    Hi Andreas,
    feedback from (another) old-timer
    Great description on the watchdog principle. In the early days of CPU, I used to implement those in hardware, based on a timer/counter that got reset as long as everything is fine. If it missed a heartbeat, then the hardware did reset/reboot the whole thing.
    Have you looked at the app IFTTT? That (internet) service can generate alarms if it does not get a signal within a certain time.
    BTW… there is also a Telegram bot called Watchdog. It looks like it can do everything… except what we want it to do. Would it not be cool if Telegram could generate an alert if it didn't get a heartbeat from our RPI?
    Thank you for your weekly high quality video. It brightens up my Sundays !
    Every time
    chrisV

    Reply
  • June 6, 2021 at 8:49 am
    Permalink

    Andreas thank you for another very informative video although a little short.

    I have the usual Raspberry Pi Server running NodeRed and other programs supporting a selection of 24 ESP 01/8266/32 MC's dotted throughout my home. All ESP's have an MQTT heartbeat which will get a Software Reset if the heartbeat fails for more than 2 minutes then if this fails to reset the device I use a Sonoff Basic to RESET all power for that device and its peripherals via an MQTT Last Will. The Raspberry Pi has its power supported by a bank of batteries. All of this works very well and essentially looks after itself but I have just designed a 555 based external watchdog module that will hopefully replace most of the above. I do not use WiFi on the Pi Server so have never had your problem, I do however have another Pi acting as a WiFi Access Point and is faultless

    Much of what I have achieved has been as a result of your and other makers videos for which I thank you.

    Reply
  • June 6, 2021 at 8:49 am
    Permalink

    Too bad of the fake capacitors. In general, I really hate fake components… A while ago, a large amount of fake 2N3055 was discovered. One of my favourite transistors. Contraband is spread out all over the electronic components spectrum. A real pain in the….

    Reply
  • June 6, 2021 at 8:49 am
    Permalink

    My Home assistant pings my webserver every 5 mins.. If it misses a heartbeat my webserver sends me an email. Simple and elegant. The heart beat also has a small log of things..

    Reply
  • June 6, 2021 at 8:49 am
    Permalink

    I​ would​ like​ to​ follow your​ method, and​ build​ one​ myself.​ Thank​ you​ very​ much.

    Reply
  • June 6, 2021 at 8:49 am
    Permalink

    Please do yourself a favor and implement some function like "timePassedSince" or "timeDiff". (see your code at 9:50)

    inline int32_t timeDiff(const unsigned long prev, const unsigned long next) {

    return ((int32_t) (next – prev));

    }

    inline long timePassedSince(unsigned long timestamp) {
    return timeDiff(timestamp, millis());

    }

    This will save you a lot of headaches when the stuff stops working after 49.7 days.

    You now use 2 different ways to compute whether some interval has passed and it does take me a while to figure out whether or not they are correct.
    In my optinion, such simple code that cannot be "read" in seconds is very likely incorrect, or at least raises doubts about the correctness.
    By using those 2 simple one-liners you can take away a lot of doubt.

    Reply
  • June 6, 2021 at 8:49 am
    Permalink

    Even Andreas, I am playing with a ESP32-WRoom-32 but it doesn't show up on Win10. It's usb doesn't show up tried the CP210xVCP driver. It is a deve board from China 38 pins mate. Nice vlog time to watch you mate. My front gate needs a watchdog.

    Reply
  • June 6, 2021 at 8:49 am
    Permalink

    I get my mains/internet connection watchdog from Flightradar24 feeder outage notification e-mails. It takes a bit more than an hour to trigger, but it's quite foolproof and probably very redundant on their side.

    Reply
  • June 6, 2021 at 8:49 am
    Permalink

    I implemented watchdog as folloving: the node red pings the nodes (asks for their ip via mqtt) if two responses from one node is missing it send a message with telegram. If connection is restored a new message is sendt.

    If node red receives no messages it is set up to execute a reboot.

    This has worked flawless. Without any extra components.

    Reply
  • June 6, 2021 at 8:49 am
    Permalink

    Healthchecks.io is a simple to use, open source monitoring/watchdog system. I use it for nothing more than monitoring backup scripts but it has a lot of flexibility. I also like the philosophy of the developer – I'm confident if he ever had a youtube channel he would have no midroll ads.

    Reply
  • June 6, 2021 at 8:49 am
    Permalink

    Thanks for this vid about such an important topic!
    I am using Homematic for ca, 10years and ioBroker as an integration platform since its beginnings. Both can send emails ad/or messages via a messanger. So, I implemented a bidirectional watchdog monitoring system. Both systems monitor each other.
    I also monitor many of my ESP sensors.
    And I implemented power grid monitoring. As a backup power source, in my first units I used supercaps but switched to energizer Li primary cell batteries. They claim 20 years shelf life which the supercaps do not do.

    Reply
  • June 6, 2021 at 8:49 am
    Permalink

    Thats perfect timing, because i just wanted to put together a server.
    My Raspberry Pi recently died soo… I bought a Mini ITX board from Ricardo
    I hope you had great holidays too!

    Reply
  • June 6, 2021 at 8:49 am
    Permalink

    I have had heartbeats and watchdogs on my mind lately with my soon to start HA project after my lab move to the new property. This video is saved to watch again when I get started. Thanks!

    Reply
  • June 6, 2021 at 8:49 am
    Permalink

    Once again an excellent, very informative video. The topics of reliability, availability and safety are rarely addressed elsewhere.

    Reply
  • June 6, 2021 at 8:49 am
    Permalink

    Yes, monitoring becomes more and more important. In servercenters we are doing it for years, without thinking about it. All the important stuff is monitored, heartbeated, watchdogd and redundant at several levels. It is a set rule. However, at hobby we do not value availability. Even commercial smart home devices do not care about it, it seems. Glad your wife did "force" you do think about it. I was creating a ESP32 to act as a forwarder for BLE beacon sensor data to Home Assistant. However, sometimes the ESP32 dies due the heavy BLE scanning and Wifi use. So I added a ATTiny45, created a serial connection between both microcontrollers, let them play "ping pong". If there is no pong from the ESP32, the ATTiny switches a relay, which cuts the power to both microcontrollers. If there is no ping from the ATTiny, the same action happens triggered by the ESP. Works as expected, and turns the BLE to Wifi forwarder into an almost maintenance free device.

    Reply
  • June 13, 2021 at 8:24 pm
    Permalink

    Best view i have ever seen !

    Reply

Leave a Reply

Your email address will not be published.