Hi,
I've been writing a framework for internet of things devices for a few years now, which drives entire smart-home solutions for me at home. Recently I built a gateway to Zigbee, which is also driven by this framework. You can find a description of it here: https://www.elektroda.pl/rtvforum/topic4103124.html .
At first I supported the ESP8266, then also the ESP32. There is an Arduino core underneath and the whole thing runs on PlatformIO. This means only that there are structures known from Arduino underneath, i.e. functions such as millis(). However, the code runs natively on the esp, without any 'atmegs' along the way. In theory I could get rid of the Arduino as such but then I would rather decide to drop support for the ESP8266. The code is written in such a way that it enables and drastically simplifies doing many things at once.
Functions .
- I decided at the outset that I would like to go in the direction of a compzy, implemented along the lines of... Unity3D
- the main object is the application rotator, which is created at the start of the application
- the rotator has a list of applications that are instantiated and executed until the end - when the application finishes, the next one rises and at the end this loops
usually the device software consists of a functional application (device behaviour) and a configuration application (own access point)
- having a pointer to the application we can search for components by type and easily avoid rigid references
components can be added and removed while the application is running and by using the lock mechanism and weak_ptr we can write stable and safe code
Components .
In addition to the framework itself, the user can use internal components as well as their own. Among the internal components, we have such as:
- the device portal over HTTP on the local network, with terminal, status and also the possibility of software updates
- the MQTT connection component
- configuration components (provider and master)
- a component for sending device statistics (RSSI, IP and others)
- a component performing various RESET button functions
Software architecture
Let's get started.
Example piece of code, showing how the application is initialised. The aim was clarity and simplicity.
.
Gallery .
.
.
Repository .
The code is available under the MIT license at:
https://github.com/cziter15/ksIotFrameworkLib .
I've been writing a framework for internet of things devices for a few years now, which drives entire smart-home solutions for me at home. Recently I built a gateway to Zigbee, which is also driven by this framework. You can find a description of it here: https://www.elektroda.pl/rtvforum/topic4103124.html .
At first I supported the ESP8266, then also the ESP32. There is an Arduino core underneath and the whole thing runs on PlatformIO. This means only that there are structures known from Arduino underneath, i.e. functions such as millis(). However, the code runs natively on the esp, without any 'atmegs' along the way. In theory I could get rid of the Arduino as such but then I would rather decide to drop support for the ESP8266. The code is written in such a way that it enables and drastically simplifies doing many things at once.
Functions .
- I decided at the outset that I would like to go in the direction of a compzy, implemented along the lines of... Unity3D
- the main object is the application rotator, which is created at the start of the application
- the rotator has a list of applications that are instantiated and executed until the end - when the application finishes, the next one rises and at the end this loops
usually the device software consists of a functional application (device behaviour) and a configuration application (own access point)
- having a pointer to the application we can search for components by type and easily avoid rigid references
components can be added and removed while the application is running and by using the lock mechanism and weak_ptr we can write stable and safe code
Components .
In addition to the framework itself, the user can use internal components as well as their own. Among the internal components, we have such as:
- the device portal over HTTP on the local network, with terminal, status and also the possibility of software updates
- the MQTT connection component
- configuration components (provider and master)
- a component for sending device statistics (RSSI, IP and others)
- a component performing various RESET button functions
Software architecture

Example piece of code, showing how the application is initialised. The aim was clarity and simplicity.
/*
Budowanie listy komponentów, inicjalizacja aplikacji.
*/
bool EnergyMonitorApp::init()
{
/* Add WiFi connector component. */
addComponent<ksf::comps::ksWifiConnector>(apps::config::EnergyMonitorConfig::emonDeviceName);
/* Add MQTT components. */
auto mqttWp{addComponent<ksf::comps::ksMqttConnector>()};
addComponent<ksf::comps::ksDevStatMqttReporter>();
/* Add LED indicator components. */
statusLedWp = addComponent<ksf::comps::ksLed>(STATUS_LED_PIN);
eventLedWp = addComponent<ksf::comps::ksLed>(EVENT_LED_PIN);
/* Create Device Portal component. */
addComponent<ksf::comps::ksDevicePortal>();
/* Add sensor component. */
auto sensorCompWp{addComponent<components::EnergySensor>(ANA_PIN)};
/* Setup reset button. */
addComponent<ksf::comps::ksResetButton>(CFG_PUSH_PIN, LOW);
/* Bind MQTT connect/disconnect events for LED status. */
if (auto mqttSp{mqttWp.lock()})
{
mqttSp->onConnected->registerEvent(connEventHandleSp, std::bind(&EnergyMonitorApp::onMqttConnected, this));
mqttSp->onDisconnected->registerEvent(disEventHandleSp, std::bind(&EnergyMonitorApp::onMqttDisconnected, this));
}
/* Set event LED. */
if (auto sensorCompSp{sensorCompWp.lock()})
sensorCompSp->setEventLed(eventLedWp);
/* Start blinking status LED. */
if (auto statusLedSp{statusLedWp.lock()})
statusLedSp->setBlinking(500);
return true;
}
Gallery .


Repository .
The code is available under the MIT license at:
https://github.com/cziter15/ksIotFrameworkLib .
Cool? Ranking DIY