← Yarana Smart Home
📦 Arduino Library
ESP32 relay controller library for Yarana Smart Home. Easy BLE provisioning, MQTT cloud control, and safe GPIO management.
Installation
Download the ZIP and import it in Arduino IDE, or use PlatformIO with the GitHub URL.
- Download
YaranaSmartHome.zipfrom the button below - Arduino IDE: Sketch → Include Library → Add .ZIP Library...
- Select the ZIP file and click Open
- Restart Arduino IDE if required
- Open example: File → Examples → YaranaSmartHome → YaranaBasic
Dependencies
ArduinoJson≥ 6.21.0PubSubClient≥ 2.8.0NimBLE-Arduino≥ 2.0.0
Quick Start — 4-Channel
#include <YaranaSmartHome.h>
YaranaSmartHome yarana;
void setup() {
Serial.begin(115200);
YaranaConfig config;
config.relayCount = 4;
YARANA_SET_RELAY_PIN(config, 0, 32);
YARANA_SET_RELAY_PIN(config, 1, 26);
YARANA_SET_RELAY_PIN(config, 2, 27);
YARANA_SET_RELAY_PIN(config, 3, 14);
config.relayActiveLow = true;
config.ledPin = 2;
config.bootButtonPin = 0;
config.mqttHost = "your.mqtt.host";
config.mqttPort = 1883;
config.mqttBaseTopic = "yarana";
yarana.begin(config);
}
void loop() {
yarana.loop();
}
Quick Start — 8-Channel
config.relayCount = 8;
YARANA_SET_RELAY_PIN(config, 0, 32);
YARANA_SET_RELAY_PIN(config, 1, 26);
YARANA_SET_RELAY_PIN(config, 2, 27);
YARANA_SET_RELAY_PIN(config, 3, 14);
YARANA_SET_RELAY_PIN(config, 4, 25);
YARANA_SET_RELAY_PIN(config, 5, 33);
YARANA_SET_RELAY_PIN(config, 6, 16);
YARANA_SET_RELAY_PIN(config, 7, 17);
⚠️ GPIO Safety Rules
Important: The
YARANA_SET_RELAY_PIN macro validates pins at compile time and blocks unsafe assignments.
- GPIO 2 — Reserved for status LED. Blocked by the macro at compile time.
- GPIO 0, 12, 15 — Strapping pins. Avoid as relay outputs.
- GPIO 6–11 — Internal flash. Never use.
- GPIO 34–39 — Input-only. Cannot drive relays.
- Set
relayActiveLow = truefor standard active-low relay modules.
MQTT Topics
- Command:
yarana/{deviceId}/cmd - User status:
yarana/{userId}/{deviceId}/status - Fallback status:
yarana/{deviceId}/status
MQTT Commands
Turn relay on:
{"cmd":"relay","index":0,"state":1}
Turn relay off:
{"cmd":"relay","index":0,"state":0}
All relays off:
{"cmd":"relay_all","state":0}
Request status:
{"cmd":"status"}
Reset device:
{"cmd":"reset"}
BLE Commands
{"op":"relay","idx":0,"state":1}
{"op":"relay_all","state":0}
{"op":"status"}
{"op":"reset"}
Device Status JSON
{
"device_id": "AABBCCDDEEFF",
"brand": "Yarana Smart Home",
"owner": "Yarana Web Tech",
"library": "YaranaSmartHome",
"library_version": "0.3.5",
"user_id": "user123",
"ble_name": "YARANA_DDEEFF",
"relay_count": 4,
"ip": "192.168.1.20",
"wifi_rssi": -58,
"free_heap": 180000,
"uptime_sec": 120,
"mqtt_connected": true,
"firmware": "0.3.5",
"relays": [0, 1, 0, 0]
}
Factory Reset
Hold the BOOT button (GPIO0) for 5 seconds. The device clears its NVS and reboots into BLE provisioning mode.
Additional Documentation
📂 Setup
Install Arduino library
Arduino IDE: Sketch > Include Library > Add .ZIP Library.