-
Notifications
You must be signed in to change notification settings - Fork 7.7k
ksIotFrameworkLib - my iot helper framework targeting esp32 and esp8266 (Arduino) #10714
-
ksIotFrameworkLib is composition oriented internet of things framework that provides simple and extendable architecture, handles device setup (WiFi setup, MQTT and application specific configuration), network connectivity, MQTT telemetry protocol and more...
Currently all my esp based devices are running this on top of this framework:
- led strip driver -> https://hackaday.io/project/198005-esp12-s-ws2812-driver
- zigbee gateway -> https://hackaday.io/project/194721-ks-zigbee-gateway
- energy monitor -> https://hackaday.io/project/175653-iot-for-old-energy-meter
- kettle controller -> https://hackaday.io/project/176557-pelletmon-iot-for-central-heating-boiler
- RF gateway -> https://hackaday.io/project/185280-raesp-gateway
To build an application, simply create a new class inherited from ksApplication and add your initial components inside the init method. See projects like emon_fw for reference.
🔎 How does it work under the hood?
- The application is created, followed by the invocation of its init() method. If false is returned from the init method, the subsequent execution of the loop will be skipped, resulting in no iteration over the components. The App Rotator will then try to run next apllication.
- In case the init() method returns true, the application proceeds to execute its loop() function. This function traverses through the components, initializing each of them.
- In the subsequent iteration, the application triggers the postInitialize() method for each component.
- Following this, the application is fully initialized and enters a looping state where it iterates over the components, invoking their respective loop methods.
- If any component returns false during it's loop method, the application will break and the App Rotator will select the next application for execution.
Example code:
bool PelletInfo::init() { /* Create required components (Wifi and Mqtt debug). */ addComponent<ksf::comps::ksWifiConnector>(PelletInfoConfig::pelletInfoDeviceName); addComponent<ksf::comps::ksMqttDebugResponder>(); addComponent<ksf::comps::ksDevStatMqttReporter>(); /* Create OTA updater component. */ addComponent<ksf::comps::ksDevicePortal>(); /* Create state display and receiver components. */ addComponent<comps::StateDisplay>(); addComponent<comps::StateReceiver>(); /* Create reset button component. */ addComponent<ksf::comps::ksResetButton>(CFG_PUSH_PIN, LOW); /* Create mqttConnector and statusLed components. */ addComponent<ksf::comps::ksMqttConnector>(); /* Application finished initialization, return true as it succedeed. */ return true; }
You can grab the library here:
https://github.com/cziter15/ksIotFrameworkLib
Reference projects:
https://github.com/cziter15/raesp_gateway
https://github.com/cziter15/emon_fw
Built-in examples:
https://github.com/cziter15/ksIotFrameworkLib/tree/master/examples
Works best with platformio.
Beta Was this translation helpful? Give feedback.
All reactions
-
👍 1