The Best Laid Schemes

“The best laid schemes of mice and men”… well, there’s a lesson here. I left Spain a few weeks ago with a Raspberry Pi running the watering system and more  – I had a hard drive to ensure the MYSQL database would not screw up the SD, I had checks for lost connectivity to reboot the board – etc etc and I have a more or less identical system here without the hard drive.

This morning in the early hours, both systems sent me an email to say that they were storing the log CACHE as they do every day… and that was the last I heard from the Spanish Pi.  I’ve just checked my remote cameras and they’re working – which means the mains is on – and the WIFI is working – but not a PEEP out of the Pi. I’ve various ports enabled so I can access it by VNC or WinSCP or the Node-Red setup – none of them are working.

So – I’m back there soon and the plants will be fine as someone will check up on them for me – but a lesson to be learned – clearly the Pi needs some kind of independent watchdog able to reboot it. I’m thinking perhaps if I set up a node-red job to read something from the web and if successful toggle a bit.. maybe every 5 minutes. That in turn will keep a little stand-alone ESP8266 or Arduino from rebooting the Pi….

What do you think?

Incidentally, the new ESP8266 SDK 1.11 is working fine and after looking all over for updated docs I’ve just realised they are in the SDK itself!!

25 thoughts on “The Best Laid Schemes

  1. Before anyone writes in… as a test of my newly working WIFI – I disabled the router WIFI – which of course would stop the PI AND the ESP working – and re-enabled it – within seconds both the ESP was working – and the PI was working as the ESP managed to contact my MQTT server… so THAT is not directly the issue.

    Thoughts anyone – I won’t be the only one having this problem. Repeatedly I can turn the access point off – turn it back on – and they both recover. So why would the WIFI dongle stop working – yet start again when disconnected and reconnected (without rebooting the Pi)?

  2. Ok so RIGHT NOW as I was sitting replying to queries in here, I noticed one of my ESP8266s was not responding – I checked the serial output (I output debug stuff to serial – very handy) and sure enough it was looking for the MQTT server… this has not happened before on this kit in the UK. I checked the Pi and sure enough – even VNC would not connect – just like Spain.

    My initial inclination was to reboot but I resisted, instead putting a usb mouse and keyboard on the live Pi – sure enough it was still running – I know that as a window was open which I’d left open last time I was messing around.

    I plugged in an Ethernet cable and pulled out the WIFI unit (a cheap one from Ebay, merely market 801.11n on the side – one I’ve seen recommended for the Pi – in fact I think the AD recommended it for the Pi… hang on…. this SPECIFIC one … http://www.ebay.co.uk/itm/Mini-USB-2-0-Wireless-Wifi-802-11n-USB-LAN-Adapter-Dongle-for-Raspberry-Pi-UK-/331400872324?hash=item4d29080184

    I bought two of these from the same place – “bgood” on Ebay.

    After removing the WIFI dongle – I opened a terminal and checked the IP address (the wired of course was different to the wireless) – and then went back to my web browser to check node-red etc.. sure enough – WORKING…

    I’m guessing but can’t prove that there is something similar going on in Spain. The WIFI unit simply STOPPED working while the Pi itself kept going.

    Have others had similar problems and if so – with the same model of WIFI dongle?

    1. More information.. After a few minutes, I thought I’d just try the WIFI unit again, so I plugged it in – again without rebooting or making any other change. Almost immediately my ESP8266 started to work again…. picking up on the WIFI.

      So – either the software to drive these things (default in the Pi) is crap – or the units themselves are crap.

      Any ideas as to a piece of software that could detect these stopping and restart the WIFI?

  3. Pete have you experienced the same unreliable [possibly] WiFi symptoms with the ESP8266 that you are experiencing with the RasPi?

    I would like to turn my Cable DVR/Boxes on and off at preset times (via a web page) as they are absolute power hogs and take up to 15 mins to reboot. Power for the ESP’s would be minuscule.

    If I could ever get a handle on all the Linux/C hoops it would seem a very doable application as a standalone for the ESP8266 but only of course if remains stable. Even a somewhat touchy WiFi connection would not be that bad as changing the off/on times via a web page would be a manual operation and a failed connection or two would not be the end of the world.

    Maybe I’ll have to wait until I can program these puppies in VB / Assembly. Too old for Linux/C.

    Love the blog by the way. Great information!

  4. Here is a over-engineered approach for a system you might heard of, from the guys at http://www.switchdoc.com – it’s a hardware watchdog. And their story: http://www.switchdoc.com/2015/05/solar-power-project-curacao-back-to-the-tropics/. And if you think minimal approach there is something to be said about a 555 with the purpose of resetting the board in case everything goes awry and GPIO pin to “pet the dog” out of the raspberry pi – as another simple WD.

  5. I have a pseudo home security system developed by myself than sends me SMS whenever a sensor detects movement. This works together with my PBX (Freeswitch) so when the system is armed, incoming VoIP or PSTN calls are forwarded to my cellular phone. If I leave the house before arming the security system then In just call from my cellular phone to my home number and the PBX activates the security system.

    I have several cron entries to check that the security core program is running, that PBX is running, that the network is connected and some additional stuff. If the script run by cron detects that a program is not running it starts the program. If the network is not responding it shuts down the interface and starts it again (ifdown followed by ifup). I have a USB GSM dongle acting as a network card. If after some tries the network doesn’t come up then this GSM interface is enabled. I keep it down to reduce bandwidth usage which is limited.

    You could implement cron entries to check that everything is running and if not, start what is down or failing.

  6. Just an update, I’ve got a TD-W8968 router and I’ve plugged in the RPi 2 with a jeelink plugged into the RPi USB and all is working OK.

    Great idea!

  7. While my raspberry pi is used just for kodi and torrents(I have a banana pi to play with for my project due to sata), I power my pi from my modem/router’s usb port. You could do the same and allow access to your router’s ui through the internet at some port(with a strong password), so in case you have no access to the raspberry, just reboot the router and the pi will reboot as well.

    1. THAT’S a good idea!!!!! It assumes the router has a usb connection – and it also assumes it turns off the USB on reboot… but it isn’t a bad idea. I like it. I’m planning on using a Draytek over there and that definitely does have a usb connector….

        1. 500ma that a usb2 gives are more than enough for a raspberry with just an Ethernet connection(assuming the usb hdd has it’s own power supply). My B+ works like that for months without a single issue, and is overclocked and usually hits 100% cpu usage. Even if that is not the case, a simple attiny circuit could restart the raspberry’s power supply when it detects loss of power from the router’s usb.

    2. Another thought…. you can do PoE for rPi…. save yourself the trouble of a power socket if deploying somewhere. i’ve not set it up.. not needed it, but it is an option.

      1. Yes I can see opportunities opening up here Andrew – first step when I get back to Spain (a few weeks) is to find out just what exactly went wrong… it’s now even stopped sending me nightly emails – I have visions of getting over there and seeing nothing but a smoking ruin.

  8. I’ve just thought, I have an old sky ethernet to WiFi adapter I dont use, I’ll give this a try, if it is the RPi OS problem for the dongle then this should solve it.

  9. Conclusion: if you want a reliable home automation system with raspberry pi, use it with eth not wifi. I’ve had my raspberry pi controlling my irrigation system for two years without any problem (good wifi router, good wifi dongle, lots of maintenance scripts covering all the abnormal situations). I’ve moved everything now on ESP8266 to avoid all unwanted situations. No issues at all, no ramdrive, no SD card problems. I still have the raspberry pi as cron and database server, but now I am confident that my system is bullet proof. From three raspberry pi, none of them gave me problems with SD card, but wireless issues I had a few. As soon I’ve moved to eth all problems were solved.

  10. I’m not sure reconnecting would help, I think something crashes in the OS, the wpa_gui says I’m connected but I’m not and if type sudo reboot nothing happens and I have to pull the power to get it working again.

    I do wonder if it’s still a power issue I’m thinking of trying a low power dongle, any suggestions?

  11. Have to agree, my mission critical 🙂 Pi is on ethernet as I had random dropouts.

    I had better luck on Wifi by using the wicd app to auto reconnect (https://launchpad.net/wicd) and others have built little reconnect scripts to do the same.

  12. I’ve got 3 rPi in the house, have had them from 2y or so to 6m. I have two on Ethernet and one on wifi. The one on wifi exhibits these exact symptoms, and I’ve got / tried several reboot scripts etc. both of the Ethernet ones have NEVER lost contact, not once! And one of them controls my home automation so I would know.

  13. Hi,
    I’ve been running an original Pi for a couple of weeks and I’m using a TP link 821N wifi dongle and I get sporadic disconnects, could be 2 hrs or 2 days it seems random.

    I replaced it with a model 2 and boy is it faster 🙂 I also upgrade the powered hub power supply and used a beefier USB cable and I thought I’d cured the problem but after a couple of days it lost connection to the wifi.

    Sometimes the dongle LED is stuck on sometimes off and the red node server is still running so I suppose it’s a new dongle or ethernet cable only for reliability, is your Pi in Spain on wifi or ethernet?

    1. The Pi2 in Spain is on WIFI but I’m seriously considering that might not be the smartest move I’ve ever made. The Pi here is on the same WIFI dongle and the day before yesterday I had some terrible issues with VNC keep dropping out – I mean every few seconds – then all of a sudden the day after all was well, I’m not seeing anything to indicate that the Pi was anything other than fine – when I turned the monitor on that is connected to the Pi it was working perfectly. I could see WIRED connections being the preferred solution in future. However, I noted this morning that the Pi in Spain had sent the usual daily message about log cacheing…

      /etc/cron.daily/logrotate:
      apache2: Could not reliably determine the server’s fully qualified domain name, using 127.0.1.1 for ServerName
      /etc/cron.daily/ramlog:
      Restarting ramlog = saving logs to hdd: .

      The bottom half of that message is normal (from /etc onwards) and so it is working and it is connected to the WIFI over there – but the message about qualified domain names is new – neither of the two Raspberry Pi2 units normally send this… so something over there has changed.

      1. All data indicate a problem with the internet connection. A failure in the ADSL.

Comments are closed.