author

RobWuesten

Inbox View Profile
6CommentsBerlin, DE

Tell us about yourself!

  • At least a running instance of Homebridge. That can run as service an a Raspberry but also an a always on MacMini f.e.

    this is the homebridge plugin i m using:https://www.npmjs.com/package/homebridge-mqtt-moti...don't forget to customize the char values.also it is very important to use the correct board settings in the Arduino IDE:NodeMCU 1.0, 115200, 80Mhz, Flash, Disabled, 4M, v2 Lower Memory, Disabled, None, Only Sketch and the correct serial port of course. char* ssid = "Auenland"; //Wi-Fi AP Namechar* password = "xxxxxxxx"; //Wi-Fi Passwordchar* mqtt_server = "192.168.2.102"; //MQTT Server IPchar* mqtt_name = "Wohnzimmer Bewegungssensor"; //MQTT device namechar* mqtt_topic = "home/livingroom/sensors/motion"; //MQTT topic for communicationint pirPin = 13; //set the GPIO which you will connect the PIR sensorbool lowPower = false; //set to true if you w…

    see more »

    this is the homebridge plugin i m using:https://www.npmjs.com/package/homebridge-mqtt-moti...don't forget to customize the char values.also it is very important to use the correct board settings in the Arduino IDE:NodeMCU 1.0, 115200, 80Mhz, Flash, Disabled, 4M, v2 Lower Memory, Disabled, None, Only Sketch and the correct serial port of course. char* ssid = "Auenland"; //Wi-Fi AP Namechar* password = "xxxxxxxx"; //Wi-Fi Passwordchar* mqtt_server = "192.168.2.102"; //MQTT Server IPchar* mqtt_name = "Wohnzimmer Bewegungssensor"; //MQTT device namechar* mqtt_topic = "home/livingroom/sensors/motion"; //MQTT topic for communicationint pirPin = 13; //set the GPIO which you will connect the PIR sensorbool lowPower = false; //set to true if you want low power useint delayTime = 2000; //ONLY FOR LOW POWER - how long motion detected should be active#include <ESP8266WiFi.h>#include <ESP8266mDNS.h>#include <WiFiUdp.h>#include <PubSubClient.h>WiFiClient mainESP;PubSubClient MQTT(mainESP);char* mqtt_maintopic = mqtt_topic;void setup() { pinMode(pirPin, INPUT_PULLUP); Serial.begin(115200);}void loop() { if (!lowPower && WiFi.status() != WL_CONNECTED) startWiFi(); Serial.println(digitalRead(pirPin)); if ((digitalRead(pirPin)) == 0) delay(250); else { if (WiFi.status() != WL_CONNECTED) startWiFi(); MQTT.loop(); if (!MQTT.connected()) reconnect(); MQTT.publish(mqtt_topic, "1"); Serial.println("Message Published: TRUE"); while (digitalRead(pirPin) == 1) { if (!MQTT.connected()) reconnect(); MQTT.publish(mqtt_topic, "1"); Serial.println("Message Published: TRUE"); delay(5000); } if (!MQTT.connected()) reconnect(); if (lowPower) delay(delayTime); MQTT.publish(mqtt_topic, "0"); Serial.println("Message Published: FALSE"); MQTT.loop(); delay(5000); } if (lowPower) { WiFi.disconnect(); WiFi.mode(WIFI_OFF); WiFi.forceSleepBegin(); delay(1); }}void callback(char* topic, byte* payload, unsigned int length) { Serial.print("Message arrived ["); Serial.print(topic); Serial.print("] "); for (int i = 0; i < length; i++) { Serial.print((char)payload[i]); } Serial.println();}void reconnect() { while (!MQTT.connected()) { Serial.print("Attempting MQTT connection..."); if (MQTT.connect(mqtt_name)) { Serial.println("connected"); } else { Serial.print("failed, rc="); Serial.print(MQTT.state()); Serial.println(" try again in 5 seconds"); for (int i = 0; i < 5000; i++) { delay(1); } } }}void startWiFi() { WiFi.mode(WIFI_STA); WiFi.begin(ssid, password); while (WiFi.waitForConnectResult() != WL_CONNECTED) { Serial.println("Connection Failed! Rebooting..."); delay(1000); ESP.restart(); } WiFi.hostname(mqtt_name); Serial.println("Ready"); Serial.print("IP address: "); Serial.println(WiFi.localIP()); MQTT.setServer(mqtt_server, 1883); MQTT.setCallback(callback);}

    View Instructable »
  • Thanks for your reply. A few days ago I decided to switch to MQTT and the diy motion sensor works now like a charm. Also it was difficult to find the correct settings on the HC-SR501 (jumper on L-position, delay, sensitivity). However Your instruction was a good inspiration for me to get into the topic ESP8266. I already have made a diy temperature and humidity sensor based on a Genuino101. In comparison I will stay at ESP8266 because it’s much cheaper and it connects via WiFi.

    View Instructable »
  • Hey,First of all I would like to say thank you for this instruction. I tried to make it too and after evenings of struggling with the Arduino IDE I finally got it working except for one crucial part:HomeKit integrationI m able to send GET requests via http in a browser and I m receiving responds too. But in Apple's Home app the device shows a refresh state for about 3 seconds and then it goes to the 'not answering' state. I also increased the sensor timeout by editing the index.js of the Homebridge plugin MotionSensor but that did not helped. Do you have any idea what could be the reason?The sensor and the WiFi connectivity is working (tested both separately with a simpleSketch).

    View Instructable »
  • Thanks for reply. Btw the link to the Lua GitHub Repo is dead...

    View Instructable »