Arduino library for connecting to Homebridge.
// Switch example
#include <ArduinoHomebridgeMqtt.h>
ArduinoHomebridgeMqtt client;
void operateSwitch(const char* serviceName, const char* characteristic, int value) {
if (strcmp(serviceName, "MySwitch") == 0) {
digitalWrite(D1, value);
}
}
void setup() {
Serial.begin(9600);
client.onSetValueFromHomebridge(operateSwitch);
client.connect(IPAddress(192, 168, 1, 1)); // Replace the IP with your MQTT server IP
}
void loop() {
client.loop();
}
See other examples in /examples