Monday, December 12, 2016

Brutal High Availability vs Simplicity

I've been toying with the idea of using an ESP8266 Wi-Fi SoC (running NodeMCU) as the basis for my kitchen/stove monitor.  It's cheap ($3), it has the sensor inputs (and libraries) I need and gets my device on the Internet (IoT!)

However, I have some serious questions regarding the stability of the platform (mostly the software -- and yeah I know I can punt NodeMCU and go with C, but I am still using frameworks and libraries I don't trust yet).   Can I run this SoC for years without a glitch?  My device can't afford to "fail".  It needs to always be working. Even if it had to "reset" due to a watchdog or long running glitch, it needs to be up and running in order to be useful.  It needs "High Availability". 

What can I do if I want to use this useful SoC?

Well...assuming that the hardware is stable, I can address software instabilities by adding another "trusted/reliable" system.

Maybe an ATmega326 running minimal firmware: Just logic.  It would be the "master".  But, it is quite an anemic master.

Since my device is AC powered (I wanted something you could enable and use without thinking about battery replacement, etc -- not play the Wi-Fi power budget problem),  I don't have to limit myself to an anemic microcontroller.  Maybe a Linux SBC?  Maybe... a Beaglebone Black?

So, here, I begin to abandon "Simplicity" (and increase my cost significantly).  But, I can do a few more things by choosing a Linux SBC:

  1. More robust protocol for Internet use:  A real messaging system (XMPP? RabittMQ client?) with caching and reconnect strategies.
  2. More security (Stronger encryption and authentication at endpoint)
  3. Leverage proven multi-year uptime of a Debian or Ubuntu distro

But, why use the ESP8266 at all?  Because getting peripherals (e.g. I2C, 1-wire, etc) to work on a Linux SBC is black magic and a waste of my time.  Plus, the ESP8266 is cheaper than any Wi-Fi USB module I can get for Linux.

The idea here is to have the Beaglebone control the ESP8266.  The Beagle will periodically either ping it for liveliness or simply reset the module before transactions or as a "daily" ritual.  It may sound kludgey but so as long as the ESP8266 is okay with periodic resets, this lends the system to higher availability than a pure MCU (bare metal or non-commercial RTOS) solution.  

Another benefit is I can do an "all Lua" implementation (Lua on the ESP8266 via NodeMCU) and LuaJIT on the Beaglebone.  This would allow me to integrate some telephony (SIP) stuff I've been working on (a completely different project) to "call" instead of just message the user about kitchen/stove activity.

Or, I could just continue developing with my current minimalistic approach of using the ATmega326p with Charley Shattuck's myforth-arduino (which is a pleasure to use -- I've already got my temperature monitor working :)


1 comment:

Charley Shattuck said...

So cool that you like myforth-arduino!