Install the library, write a tiny sketch, see a button on your phone control the LED on your Arduino. That’s the whole loop — the rest of this section just adds widgets to the same shape.
[image] Arduino IDE Library Manager with InstantIoT highlighted
Install the library
Arduino IDE
- Open the Arduino IDE.
- Go to Tools → Manage Libraries.
- Search for InstantIoT.
- Click Install.
PlatformIO
Add the library to your platformio.ini:
lib_deps =
jeanloickdt/InstantIoT
The library compiles for your Arduino board with no extra configuration — pick your board in the IDE and you’re set.
Hello World
A button on the phone toggles the LED on your Arduino. Three pieces: a widget in the app, a sketch on your Arduino, your phone connecting to either your Arduino directly (Direct Mode) or your InstantIoT Server (Server Mode).
[gif] Tap the button on the phone, the LED on the Arduino reacts
In the app
Open the dashboard editor. Tap + in the toolbar, pick Simple Button, drop it on the canvas. Open its Inspector and set:
- Widget ID →
btn1 - Mode →
Toggle
The app is now wired up to receive your sketch.
On the Arduino — Direct Mode
In Direct Mode, your Arduino broadcasts its own Wi-Fi network. Your phone joins it directly. No router, no server.
#include <InstantIoTWiFiAP.hpp>
const char* AP_SSID = "InstantIoT-Greenhouse";
const char* AP_PASS = "12345678";
#define LED_PIN 2
InstantIoTWiFiAP instant(AP_SSID, AP_PASS);
ISimpleButton("btn1") {
WHEN_TOGGLED(isOn) {
digitalWrite(LED_PIN, isOn ? HIGH : LOW);
}
};
void setup() {
Serial.begin(115200);
pinMode(LED_PIN, OUTPUT);
instant.begin();
}
void loop() {
instant.loop();
}
Flash this sketch. Your Arduino now broadcasts a Wi-Fi network called InstantIoT-Greenhouse with password 12345678. In the app, open the connection sheet, pick the network, connect. Tap the button — the LED toggles.
On the Arduino — Server Mode
In Server Mode, your Arduino joins your home Wi-Fi and connects to your self-hosted InstantIoT Server. Multiple devices can share one server, state is persistent, and many phones can connect at once.
#include <InstantIoTWiFiServer.hpp>
const char* WIFI_SSID = "YOUR_WIFI_SSID";
const char* WIFI_PASS = "YOUR_WIFI_PASSWORD";
const char* SERVER_IP = "192.168.1.42";
const uint16_t SERVER_PORT = 9001;
const char* DEVICE_TOKEN = "YOUR_DEVICE_TOKEN";
#define LED_PIN 2
InstantIoTWiFiServer instant(SERVER_IP, SERVER_PORT, DEVICE_TOKEN);
ISimpleButton("btn1") {
WHEN_TOGGLED(isOn) {
digitalWrite(LED_PIN, isOn ? HIGH : LOW);
}
};
void setup() {
Serial.begin(115200);
pinMode(LED_PIN, OUTPUT);
instant.begin(WIFI_SSID, WIFI_PASS);
}
void loop() {
instant.loop();
}
Same logic, two changes: the #include, and the constructor takes your server’s IP, port, and the device token you copied from the server’s dashboard. The WHEN_TOGGLED(isOn) block doesn’t change.
What just happened
Five lines did the work:
#include <InstantIoTWiFiAP.hpp>— selects the connection mode. Switch this line to<InstantIoTWiFiServer.hpp>to move the same sketch to Server Mode.InstantIoTWiFiAP instant(...)— creates the runtime object that communicates with the app.ISimpleButton("btn1") { ... }— declares a block at global scope. The library calls it when the widget with IDbtn1fires an event.WHEN_TOGGLED(isOn)runs once per toggle, capturing the new state.instant.begin(...)— starts the connection.instant.loop()— drives the protocol. Call it once per Arduinoloop()iteration.
To add a slider, a gauge, a chart — same shape, different macros. The next two pages walk through every one.
Next
→ Receive command from App — Every WHEN_* block, by widget category.
→ Send data to App — Every method to push values to Display widgets.
→ Manage Connections — Direct Mode and Server Mode in detail.