Allow me to introduce V0.1 of “ESPARTO” (ESP all-purpose run-time object) which is pretty much MQTT firmware-in-a-box for anything with an ESP8266 in it SONOFF, Wemos D1, NodeMCU etc. It is intended to take all the pain of getting your own project up and running quickstyle.
The repository is at GitHub - philbowles/esparto: Esparto v3.3 is a rapid development framework, synchronous task queue and GPIO manager with web UI for ESP8266 devices but I think the introduction tells you all you need to know:
"Wouldn’t it be nice if this was all it took to build a robust MQTT-capable firmware for SONOFF, WEMOS, NODEMCU etc to remotely turn the device on or off from you own WiFi network? No cloud APP, no dead device when Internet is down , no unexpected WDT resets…
#include <ESPArto.h>
// ToiioT-Etage is my SSID, pw="" (I live in the forest) my raspi mosquitto is on 192.168.1.4
ESPArto Esparto("ToiioT-Etage", "", "esparto666", "192.168.1.4", 1883);
void setupHardware(){
Esparto.pinDefDebounce(0,INPUT,buttonPressed,15); // 15 = ms debounce time
pinMode(12,OUTPUT); // SONOFF relay / switch
}
void onMqttConnect(){ Esparto.subscribe("switch",mqttSwitch); }
void toggleRelay(){ digitalWrite(12,!digitalRead(12)); }
void buttonPressed(bool hilo){ if(hilo) toggleRelay(); }
void mqttSwitch(String topic,String payload){
toggleRelay();
Esparto.publish("state",digitalRead(12) ? "ON":"OFF");
}
And wouldn’t it be nicer if that also already included MQTT support to set / read any pin, to reconnect automatically when the router fails, and to be able to update it via OTA? If it could also handle retriggering pins, latching pins and even fully debounced rotary encoder support, it would be pretty easy for newbies to get started…
Well now it is. Introducing Yet Another WiFi Novelty (YAWN…) <drum-roll…> ESPARTO"
I’m looking for initial comments, suggestions, beta testing if any of you have the time to check it out, I’d be grateful. If it helps anybody, I’ll be happy too!
Phil