← 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.

  1. Download YaranaSmartHome.zip from the button below
  2. Arduino IDE: Sketch → Include Library → Add .ZIP Library...
  3. Select the ZIP file and click Open
  4. Restart Arduino IDE if required
  5. Open example: File → Examples → YaranaSmartHome → YaranaBasic
📦 Download ZIP v0.3.5 🐙 GitHub

Dependencies

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.

MQTT Topics

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

Install Arduino library

Arduino IDE: Sketch > Include Library > Add .ZIP Library.