-
-
Notifications
You must be signed in to change notification settings - Fork 3
Getting Started
This guide will walk you through installing ksIotFrameworkLib and creating your first IoT application.
Before you begin, ensure you have:
- PlatformIO (recommended) or Arduino IDE installed
- Basic C++ knowledge
- An ESP32 or ESP8266 development board
- USB cable for programming your device
PlatformIO is highly recommended because it:
- Automatically manages all dependencies
- Provides better build system integration
- Offers advanced debugging features
- Handles platform-specific configurations easily
Note: All examples in this documentation use PlatformIO configuration.
-
Create a new PlatformIO project:
pio project init --board esp32dev
-
Add the library to your
platformio.ini:[env:esp32dev] platform = https://github.com/pioarduino/platform-espressif32/releases/download/stable/platform-espressif32.zip board = esp32dev framework = arduino lib_deps = cziter15/ksIotFrameworkLib
-
For ESP8266, add this build flag:
[env:esp8266] platform = espressif8266 board = d1_mini framework = arduino build_flags = -D PIO_FRAMEWORK_ARDUINO_ESPRESSIF_SDK305 lib_deps = cziter15/ksIotFrameworkLib
-
Install dependencies:
pio lib install
- Open Arduino IDE
- Go to Sketch β Include Library β Manage Libraries
- Search for ksIotFrameworkLib
- Click Install
-
Clone the repository:
git clone https://github.com/cziter15/ksIotFrameworkLib.git
-
Copy to your Arduino libraries folder:
-
Windows:
Documents/Arduino/libraries -
macOS:
~/Documents/Arduino/libraries -
Linux:
~/Arduino/libraries
-
Windows:
Let's create a simple LED blink application to understand the framework basics.
my-first-project/
βββ include/
β βββ MyBlinkApp.h
βββ src/
β βββ main.cpp
βββ platformio.ini
Create include/MyBlinkApp.h:
#pragma once
#include <ksf/ksApplication.h>
class MyBlinkApp : public ksf::ksApplication
{
protected:
bool init() override {
// Initialize your components here
// Return false to signal initialization failure
return true;
}
bool loop() override {
// Main application loop
// Return false to stop the application
return true;
}
};Create src/main.cpp:
#include <ksf/ksAppRotator.h>
#include "MyBlinkApp.h"
// Use the framework's macro to implement app rotation
KSF_IMPLEMENT_APP_ROTATOR(
MyBlinkApp
)# Build the project
pio run
# Upload to device
pio run --target upload
# Monitor serial output
pio device monitorYou should see the framework initialize:
[ksIotFrameworkLib] Application rotator starting
[ksIotFrameworkLib] Attempting to run: MyBlinkApp
[ksIotFrameworkLib] Application initialized successfully
Now let's make it actually blink an LED. Modify MyBlinkApp.h:
#pragma once
#include <ksf/ksApplication.h>
#include <ksf/comp/ksLed.h>
#include <ksf/comp/ksSimpleTimer.h>
class MyBlinkApp : public ksf::ksApplication
{
private:
ksf::comps::ksLed* led;
ksf::ksSimpleTimer* timer;
protected:
bool init() override {
// Add LED component for built-in LED
addComponent<ksf::comps::ksLed>(LED_BUILTIN);
// Add timer for 500ms blink interval
addComponent<ksf::ksSimpleTimer>(500);
return true;
}
bool postInit() override {
// Get component references
led = findComponent<ksf::comps::ksLed>();
timer = findComponent<ksf::ksSimpleTimer>();
return led && timer;
}
bool loop() override {
if (timer->elapsed()) {
led->toggle();
timer->reset();
}
return true;
}
};Now upload and watch your LED blink!
Ready for something more advanced? Let's add WiFi and MQTT support.
-
Update
platformio.ini:lib_deps = cziter15/ksIotFrameworkLib -
Create MQTT LED App:
#pragma once #include <ksf/ksApplication.h> #include <ksf/comp/ksWifiConnector.h> #include <ksf/comp/ksMqttConnector.h> #include <ksf/comp/ksLed.h> class MqttLedApp : public ksf::ksApplication { protected: bool init() override { // Add WiFi connector addComponent<ksf::comps::ksWifiConnector>("MyDevice"); // Add MQTT connector addComponent<ksf::comps::ksMqttConnector>(); // Add LED control addComponent<ksf::comps::ksLed>(LED_BUILTIN); return true; } };
-
First Boot - Configuration Mode:
- On first boot, the device will create an access point
- Connect to
MyDevice_ConfigWiFi network - Open browser to configure WiFi and MQTT settings
- After configuration, device restarts and connects to your network
-
Control via MQTT:
# Turn LED on mosquitto_pub -h broker -t "MyDevice/led/set" -m "ON" # Turn LED off mosquitto_pub -h broker -t "MyDevice/led/set" -m "OFF"
Now that you have a basic application running:
- ποΈ Architecture β Understand how the framework works
- π§© Core Concepts β Applications, Components, App Rotator
- π¦ Components Reference β Explore all built-in components
- βοΈ Configuration β Manage device settings
- π Device Portal β Web interface and OTA updates
- π‘ Examples β More practical examples
- Check serial monitor for error messages
- Verify WiFi credentials are correct
- Try resetting to configuration mode (hold reset button)
- Verify MQTT broker is accessible
- Check broker address and port settings
- Ensure no firewall is blocking connection
- Clean build:
pio run -t clean - Update PlatformIO:
pip install -U platformio - Check platform URL for ESP32 is correct
- π Check Troubleshooting page
- π Report issues on GitHub
- π¬ Join community discussions
Complete working examples are available in the examples directory:
- led-blink β Basic LED control
- mqtt-led β MQTT-controlled LED with full IoT stack
- And more...
Clone and explore these examples to learn best practices!
π Congratulations! You've created your first ksIotFrameworkLib application. Continue exploring to build powerful IoT solutions!
π€ This wiki is automatically generated and may contain errors.
Please report any issues here:
π https://github.com/cziter15/ksIotFrameworkLib/issues