author
4Instructables112,200Views42CommentsLaguna Beach, CA
I'm a lot of things. Galen Wollenberg https://hackaday.io/projects/hacker/246423 https://www.hackster.io/LagunaComputer

Achievements

10K+ Views Earned a bronze medal
  • GalenW1 commented on DavidB56's instructable Arduino Artnet Node
    Arduino Artnet Node

    https://www.facebook.com/galenwollenberg/videos/10220176242653583it took me 2 years lol but i finally got Jinx to work over wifi / Artnet with an ESP8266 and a 16x16 led matrix

    View Instructable »
  • Artnet LED Pixels With ESP8266

    thank you so much for the .bin , here is my 16x16 matrix with esp8266 artnet and jinx https://www.facebook.com/galenwollenberg/videos/10220176242653583

    View Instructable »
  • Please post or reply with a link to your improved MQTT code, thanks sir

    View Instructable »
  • rob, my original code was 'updated' by some others and it may have broke it. Go check out the newer (actually older) arduino code i posted a few days ago https://github.com/lagunacomputer/homebridge-MotionSensor

    View Instructable »
  • The HomeBridge install version has likely changed/updated by now, you may want to try an older version.

    View Instructable »
  • I would start a new basic sketch and make sure you can get your DHT11 or DHT22 sensor working first.'nan' means you are not getting a sensor value from the sensor yet.Start with a basic sketch that reads the DHT value only correctly first, then port it over to your homebridge code.https://playground.arduino.cc/Main/DHT11Libhttp://www.circuitbasics.com/how-to-set-up-the-dht...http://howtomechatronics.com/tutorials/arduino/dht...

    try https://github.com/lagunacomputer/

    View Instructable »
  • try fixing this:Multiple libraries were found for "OneWire.h"Used: /Users/jerry/Documents/Arduino/libraries/OneWireNot used: /Users/jerry/Documents/Arduino/libraries/DallasTemperature

    View Instructable »
  • Lookup 'arduino shift registers' , although it might be easier to just use 2-3 ESP's connected to the same power source, as they are so cheaphttps://www.arduino.cc/en/Tutorial/ShiftOut

    View Instructable »
  • check out the current version of homebridge-MotionSensor plugin. Better programmers than me have updated the code to support status updates, there is also a nice description on status possibilities within the comments, it can be modified for this purpose (basically what I did here):https://www.npmjs.com/package/homebridge-MotionSen...https://github.com/lagunacomputer/homebridge-MotionSensor

    View Instructable »
  • Dan, I'm pretty sure you can just ignore the temp and light sensor parts, code and hardware. It will just return 0 for values for those. Then can have the Arduino/ESP8266 code just call out for shorter http get request, i.e. Just one ?motion= In the get request . I will check the code in a few hours and see if I can send you a stripped down version. So basically chop the Arduino code to only make one request, and forget about installing the other plugins.

    #include <SPI.h>byte mac[] = { 0x5C, 0xCF, 0x7F, 0xC1, 0x1A, 0x33 };int photocellPin = 0; // the cell and 10K pulldown are connected to a0int photocellReading; // the analog reading from the analog resistor divider#include <DHT.h>#define DHT11Pin D6///////////////////////////////VARS//the time we give the sensor to calibrate (10-60 secs according to the datasheet)int calibrationTime = 30; //the time when the sensor outputs a low impulselong unsigned int lowIn; //the amount of milliseconds the sensor has to be low //before we assume all motion has stoppedlong unsigned int pause = 5000; boolean lockLow = true;boolean takeLowTime; int pirPin = 4; //the digital pin connected to the PIR sensor's outputint ledPin = 13;#include <ESP8266WiFi.h>IPAddres…

    see more »

    #include <SPI.h>byte mac[] = { 0x5C, 0xCF, 0x7F, 0xC1, 0x1A, 0x33 };int photocellPin = 0; // the cell and 10K pulldown are connected to a0int photocellReading; // the analog reading from the analog resistor divider#include <DHT.h>#define DHT11Pin D6///////////////////////////////VARS//the time we give the sensor to calibrate (10-60 secs according to the datasheet)int calibrationTime = 30; //the time when the sensor outputs a low impulselong unsigned int lowIn; //the amount of milliseconds the sensor has to be low //before we assume all motion has stoppedlong unsigned int pause = 5000; boolean lockLow = true;boolean takeLowTime; int pirPin = 4; //the digital pin connected to the PIR sensor's outputint ledPin = 13;#include <ESP8266WiFi.h>IPAddress ip(192, 168, 1, 147); IPAddress gateway(192, 168, 1, 1);IPAddress subnet(255, 255, 255, 0);const char* ssid = "IWILLSTEALYOURMONEY";const char* password = "namnamnewnew";// Create an instance of the server// specify the port to listen on as an argumentWiFiServer server(80);DHT dht(DHT11Pin, DHT11);unsigned long previousMillis = 0; // will store last temp was readconst long interval = 2000; ///////////////////////////////SETUPvoid setup(){ Serial.begin(9600); pinMode(pirPin, INPUT); pinMode(ledPin, OUTPUT); digitalWrite(pirPin, LOW);WiFi.begin(ssid, password);//WiFi.config(ip, gateway, subnet);while (WiFi.status() != WL_CONNECTED) { delay(500); //WiFi.begin(ssid, password); //Serial.print("."); } //Serial.println(""); //Serial.println("WiFi connected"); // Start the server server.begin(); //Serial.println("Server started");Serial.println(""); // Print the IP address Serial.println(WiFi.localIP()); //give the sensor some time to calibrate Serial.print("calibrating sensor "); for(int i = 0; i < calibrationTime; i++){ Serial.print("."); delay(1000); } Serial.println(" done"); Serial.println("SENSOR ACTIVE"); delay(50); } // get humidity float humidity = dht.readHumidity(); // get temperature as C float celsius = dht.readTemperature(); // get temperature as F float fahrenheit = dht.readTemperature(true);// prepare a web page to be send to a client (web browser)String prepareHtmlPage(){ //gettemperature(); String htmlPage = String("HTTP/1.1 200 OK\r\n") + "Content-Type: text/html\r\n" + "Connection: close\r\n" + // the connection will be closed after completion of the response "Refresh: 5\r\n" + // refresh the page automatically every 5 sec "\r\n" + "<!DOCTYPE HTML>" + "<html>" + "Analog input:" + String(analogRead(A0)) + " PIR input:" + String(digitalRead(D4)) + " celsius:" + float(dht.readTemperature()) + " fahrenheit:" + float(dht.readTemperature(true)) + " humidity:" + float(dht.readHumidity()) + "</html>" + "\r\n"; return htmlPage;}//////////////////////////////LOOPvoid loop(){readPhotocell();//delay(10000); // get humidity float humidity = dht.readHumidity(); // get temperature as C float celsius = dht.readTemperature(); // get temperature as F float fahrenheit = dht.readTemperature(true); // print results Serial.print("Humidity: "); Serial.print(humidity); Serial.print(" Celsius: "); Serial.print(celsius); Serial.print(" Fahrenheit: "); Serial.println(fahrenheit); if(digitalRead(pirPin) == HIGH){ digitalWrite(ledPin, HIGH); //the led visualizes the sensors output pin state if(lockLow){ //makes sure we wait for a transition to LOW before any further output is made: lockLow = false; Serial.println("---"); Serial.print("motion detected at "); Serial.print(millis()/1000); Serial.println(" sec"); delay(50); } takeLowTime = true; } ////high if(digitalRead(pirPin) == LOW){ digitalWrite(ledPin, LOW); //the led visualizes the sensors output pin state if(takeLowTime){ lowIn = millis(); //save the time of the transition from high to LOW takeLowTime = false; //make sure this is only done at the start of a LOW phase } //if the sensor is low for more than the given pause, //we assume that no more motion is going to happen if(!lockLow && millis() - lowIn > pause){ //makes sure this block of code is only executed again after //a new motion sequence has been detected lockLow = true; Serial.print("motion ended at "); //output Serial.print((millis() - pause)/1000); Serial.println(" sec"); delay(50); } } //low WiFiClient client = server.available(); // wait for a client (web browser) to connect if (client) { Serial.println("\n[Client connected]"); while (client.connected()) { // read line by line what the client (web browser) is requesting if (client.available()) { String line = client.readStringUntil('\r'); Serial.print(line); // wait for end of client's request, that is marked with an empty line if (line.length() == 1 && line[0] == '\n') { client.println(prepareHtmlPage()); break; } } } delay(1); // give the web browser time to receive the data // close the connection: client.stop(); Serial.println("[Client disonnected]"); } } //loopvoid readPhotocell(){photocellReading = analogRead(photocellPin); Serial.print(WiFi.localIP()); Serial.print(" Analog reading = "); Serial.print(photocellReading); // the raw analog reading // We'll have a few threshholds, qualitatively determined if (photocellReading < 10) { Serial.println(" - Dark"); } else if (photocellReading < 200) { Serial.println(" - Dim"); } else if (photocellReading < 500) { Serial.println(" - Light"); } else if (photocellReading < 800) { Serial.println(" - Bright"); } else { Serial.println(" - Very bright"); }}/*void gettemperature() { // Wait at least 2 seconds seconds between measurements. // if the difference between the current time and last time you read // the sensor is bigger than the interval you set, read the sensor // Works better than delay for things happening elsewhere also unsigned long currentMillis = millis(); if(currentMillis - previousMillis >= interval) { // save the last time you read the sensor previousMillis = currentMillis; // Reading temperature for humidity takes about 250 milliseconds! // Sensor readings may also be up to 2 seconds 'old' (it's a very slow sensor) humidity = dht.readHumidity(); // Read humidity (percent) celsius = dht.readTemperature(); // Read temperature as Fahrenheit fahrenheit = dht.readTemperature(true); // Read temperature as Fahrenheit // Check if any reads failed and exit early (to try again). if (isnan(humidity) || isnan(fahrenheit)) { Serial.println("Failed to read from DHT sensor!"); return; } }}*/

    Hi Dan, try this, I basically commented out all the Light and Temp sensor stuff. Remember to edit your MAC and WIFISSID and WIFIPassword, and not sure about the WeMos stuff, might have to change pins for the motion sensor.Send me your email if you cannot get it to compile, it seemed to compile fine on my end. Good Luck.// HomeKit/Homebridge v3 NodeMCU/ESP8266 Code with HC-SR501 PIR// https://www.instructables.com/HomeKit-HomeBrid...// requires the homebridge-MotionSensor plugin by Galen Wollenberg https://github.com/lagunacomputer/homebridge-Moti...// Copyright 2017 Galen Wollenberg LagunaBeachComputer.com - ok to use for personal projects or testing only. No Commercial use.#include <SPI.h>byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };//int photocellPin = 0; // the c…

    see more »

    Hi Dan, try this, I basically commented out all the Light and Temp sensor stuff. Remember to edit your MAC and WIFISSID and WIFIPassword, and not sure about the WeMos stuff, might have to change pins for the motion sensor.Send me your email if you cannot get it to compile, it seemed to compile fine on my end. Good Luck.// HomeKit/Homebridge v3 NodeMCU/ESP8266 Code with HC-SR501 PIR// https://www.instructables.com/HomeKit-HomeBrid...// requires the homebridge-MotionSensor plugin by Galen Wollenberg https://github.com/lagunacomputer/homebridge-Moti...// Copyright 2017 Galen Wollenberg LagunaBeachComputer.com - ok to use for personal projects or testing only. No Commercial use.#include <SPI.h>byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };//int photocellPin = 0; // the cell and 10K pulldown are connected to a0//int photocellReading; // the analog reading from the analog resistor divider//#include <DHT.h>//#define DHT11Pin D6///////////////////////////////VARS//the time we give the sensor to calibrate (10-60 secs according to the datasheet)int calibrationTime = 30; //the time when the sensor outputs a low impulselong unsigned int lowIn; //the amount of milliseconds the sensor has to be low //before we assume all motion has stoppedlong unsigned int pause = 5000; boolean lockLow = true;boolean takeLowTime; int pirPin = 4; //the digital pin connected to the PIR sensor's outputint ledPin = 13;#include <ESP8266WiFi.h>IPAddress ip(192, 168, 1, 147); IPAddress gateway(192, 168, 1, 1);IPAddress subnet(255, 255, 255, 0);const char* ssid = "yourwifissid";const char* password = "yourwifipassword";// Create an instance of the server// specify the port to listen on as an argumentWiFiServer server(80);//DHT dht(DHT11Pin, DHT11);unsigned long previousMillis = 0; // will store last temp was readconst long interval = 2000; ///////////////////////////////SETUPvoid setup(){ Serial.begin(9600); pinMode(pirPin, INPUT); pinMode(ledPin, OUTPUT); digitalWrite(pirPin, LOW);WiFi.begin(ssid, password);//WiFi.config(ip, gateway, subnet);while (WiFi.status() != WL_CONNECTED) { delay(500); //WiFi.begin(ssid, password); //Serial.print("."); } //Serial.println(""); //Serial.println("WiFi connected"); // Start the server server.begin(); //Serial.println("Server started");Serial.println(""); // Print the IP address Serial.println(WiFi.localIP()); //give the sensor some time to calibrate Serial.print("calibrating sensor "); for(int i = 0; i < calibrationTime; i++){ Serial.print("."); delay(1000); } Serial.println(" done"); Serial.println("SENSOR ACTIVE"); delay(50); } // get humidity // float humidity = dht.readHumidity(); // get temperature as C //float celsius = dht.readTemperature(); // get temperature as F //float fahrenheit = dht.readTemperature(true);// prepare a web page to be send to a client (web browser)String prepareHtmlPage(){ //gettemperature(); String htmlPage = String("HTTP/1.1 200 OK\r\n") + "Content-Type: text/html\r\n" + "Connection: close\r\n" + // the connection will be closed after completion of the response "Refresh: 5\r\n" + // refresh the page automatically every 5 sec "\r\n" + "<!DOCTYPE HTML>" + "<html>" + "Analog input:" + String(analogRead(A0)) + " PIR input:" + String(digitalRead(D4)) + //+ " celsius:" + float(dht.readTemperature()) + " fahrenheit:" + float(dht.readTemperature(true)) + " humidity:" + float(dht.readHumidity()) + "</html>" + "\r\n"; return htmlPage;}//////////////////////////////LOOPvoid loop(){//readPhotocell();//delay(10000); // get humidity //float humidity = dht.readHumidity(); // get temperature as C //float celsius = dht.readTemperature(); // get temperature as F //float fahrenheit = dht.readTemperature(true); // print results //Serial.print("Humidity: "); Serial.print(humidity); //Serial.print(" Celsius: "); Serial.print(celsius); //Serial.print(" Fahrenheit: "); Serial.println(fahrenheit); if(digitalRead(pirPin) == HIGH){ digitalWrite(ledPin, HIGH); //the led visualizes the sensors output pin state if(lockLow){ //makes sure we wait for a transition to LOW before any further output is made: lockLow = false; Serial.println("---"); Serial.print("motion detected at "); Serial.print(millis()/1000); Serial.println(" sec"); delay(50); } takeLowTime = true; } ////high if(digitalRead(pirPin) == LOW){ digitalWrite(ledPin, LOW); //the led visualizes the sensors output pin state if(takeLowTime){ lowIn = millis(); //save the time of the transition from high to LOW takeLowTime = false; //make sure this is only done at the start of a LOW phase } //if the sensor is low for more than the given pause, //we assume that no more motion is going to happen if(!lockLow && millis() - lowIn > pause){ //makes sure this block of code is only executed again after //a new motion sequence has been detected lockLow = true; Serial.print("motion ended at "); //output Serial.print((millis() - pause)/1000); Serial.println(" sec"); delay(50); } } //low WiFiClient client = server.available(); // wait for a client (web browser) to connect if (client) { Serial.println("\n[Client connected]"); while (client.connected()) { // read line by line what the client (web browser) is requesting if (client.available()) { String line = client.readStringUntil('\r'); Serial.print(line); // wait for end of client's request, that is marked with an empty line if (line.length() == 1 && line[0] == '\n') { client.println(prepareHtmlPage()); break; } } } delay(1); // give the web browser time to receive the data // close the connection: client.stop(); Serial.println("[Client disonnected]"); } } //end of void loop//void readPhotocell(){//photocellReading = analogRead(photocellPin); //Serial.print(WiFi.localIP()); //Serial.print(" Analog reading = "); //Serial.print(photocellReading); // the raw analog reading // We'll have a few threshholds, qualitatively determined //if (photocellReading < 10) { //Serial.println(" - Dark"); //} else if (photocellReading < 200) { // Serial.println(" - Dim"); // } else if (photocellReading < 500) { // Serial.println(" - Light"); //} else if (photocellReading < 800) { // Serial.println(" - Bright"); //} else { // Serial.println(" - Very bright"); //}//} //end of void readPhotocell/*void gettemperature() { // Wait at least 2 seconds seconds between measurements. // if the difference between the current time and last time you read // the sensor is bigger than the interval you set, read the sensor // Works better than delay for things happening elsewhere also unsigned long currentMillis = millis(); if(currentMillis - previousMillis >= interval) { // save the last time you read the sensor previousMillis = currentMillis; // Reading temperature for humidity takes about 250 milliseconds! // Sensor readings may also be up to 2 seconds 'old' (it's a very slow sensor) humidity = dht.readHumidity(); // Read humidity (percent) celsius = dht.readTemperature(); // Read temperature as Fahrenheit fahrenheit = dht.readTemperature(true); // Read temperature as Fahrenheit // Check if any reads failed and exit early (to try again). if (isnan(humidity) || isnan(fahrenheit)) { Serial.println("Failed to read from DHT sensor!"); return; } }}*/

    View Instructable »
    • ​Build a Digital Interactive Electronic Business Card
      2,561 views
      30 favorites
      0 comments
  • you could bypass and code or load the http page that the sensor/arduino serves:but i don't know how to force the check upon homebridgeie: "on_url": "http://192.168.1.110/gpio/1", "off_url": "http://192.168.1.110/gpio/0",http://192.168.1.110/gpio/0 etc

    View Instructable »
  • its above. strip out the <p> and </p> from the instructables website formating.

    you just name it in the config.json file. You should be able to test if HomeBridge can see the sensor by using the URL of the sensor in a web browser. that is all that HomeBridge basically does (my plugin is based on the HB html plugin). try the ip of your sensor, something like http://192.168.1.101/?light or http://192.168.1.101/?on or http://192.168.1.101/?off

    dunno, it just needs to run HomeBridge. Probably not.

    strip out the formatting the instructables website added to the code:</p><p>

    View Instructable »
  • added two toggle buttons:android ledcontrol.java:protected void onCreate(Bundle savedInstanceState){btnCam = (ToggleButton)findViewById(R.id.toggleButton);btnCam2 = (ToggleButton)findViewById(R.id.toggleButton2);btnCam.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { // The toggle is enabledturnOffLed(); //method to turn off} else { turnOnLed(); //method to turn on // The toggle is disabled} }});btnCam2.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { // The toggle is enabledturnOff…

    see more »

    added two toggle buttons:android ledcontrol.java:protected void onCreate(Bundle savedInstanceState){btnCam = (ToggleButton)findViewById(R.id.toggleButton);btnCam2 = (ToggleButton)findViewById(R.id.toggleButton2);btnCam.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { // The toggle is enabledturnOffLed(); //method to turn off} else { turnOnLed(); //method to turn on // The toggle is disabled} }});btnCam2.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { // The toggle is enabledturnOffLed2(); //method to turn off} else { turnOnLed2(); //method to turn on // The toggle is disabled} }});..........public class ledControl extends ActionBarActivity { Button btnOn, btnOff, btnDis; ToggleButton btnCam, btnCam2;..............private void turnOffLed2(){ if (btSocket!=null) { try{ btSocket.getOutputStream().write("2F".toString().getBytes()); } catch (IOException e) { msg("Error"); } }}private void turnOnLed2(){ if (btSocket!=null) { try{ btSocket.getOutputStream().write("2O".toString().getBytes()); } catch (IOException e) { msg("Error"); } }}Arduino:char command;String string;boolean ledon = false;boolean ledon2 = false;#define led 7const int ledPin = 7; // the number of the LED pin#define led2 6const int ledPin2 = 6; // the number of the LED pin void setup() { Serial.begin(9600); pinMode(7, OUTPUT); pinMode(6, OUTPUT); //Serial.println("ready"); } void loop() { delay(10); if (Serial.available() > 0) {string = "";} while(Serial.available() > 0) { command = ((byte)Serial.read()); if(command == ':') { break; } else { string += command; } delay(1); } if(string == "TO") { ledOn(); ledon = true; } if(string =="TF") { ledOff(); ledon = false; //Serial.println(string); } if(string == "2O") { ledOn2(); ledon2 = true; } if(string =="2F") { ledOff2(); ledon2 = false; //Serial.println(string); }/* if ((string.toInt()>=0)&&(string.toInt()<=255)) { if (ledon==true) { analogWrite(led, string.toInt()); Serial.println(string); delay(10); } }*/ }void ledOn() { digitalWrite(7, HIGH); delay(10); //Serial.println("on"); } void ledOff() { digitalWrite(7, LOW); delay(10); //Serial.println("off"); }void ledOn2() { digitalWrite(6, HIGH); delay(10); //Serial.println("on"); } void ledOff2() { digitalWrite(6, LOW); delay(10); //Serial.println("off"); }

    View Instructable »
  • using void setup() { Serial.begin(9600);

    i solved my 120 second timeout problem by extending the android tablets display timeout to 5 minutes, and inserting a 10ms delay right at the beginning of void loop. It just needs a little time rest each cycle of void loop void loop() { delay(10); if (Serial.available() > 0)

    View Instructable »
  • just strip out the HTML tags and be sure to install libraries like DallasTemperature

    </p><p> change these to carriage returns or Enter key new line

    View Instructable »
  • try the V4 code example

    just edit the PIR section of the code. instead of motion on/off it will just output HIGH/LOW to the D4 pin. just put a switch on/off there.you could then use the http://192.168.1.x/?pir command in the config.json file in HomeBridge. this would tell siri if it is on or off

    View Instructable »
  • i uploaded some sample code files, im not sure which one i actually used, but the meat of the code is there now, thanks

    i uploaded some sample code files, im not sure which one i actually used, but the meat of the code is there now, thanks

    View Instructable »
  • http://lagunabeachcomputer.com/arduino-based-solar-panel-tracker/

    View Instructable »
      • Glue Class
      • Astronaut Costume
      • Photography Class
  • because RPI3 is small, cheap, uses little power and it works (for Homebridge)i use the NodeMCU/ESP8266 ardiunos because they are cheaper, smaller and simpler to deal with as sensor controller. you don't need a whole linux layer and HDMI jack to read a temperature sensor or push a webpage

    View Instructable »
  • finally got the Living Room Lamp accessory to show on my iphone my recopying/pasting the text into BOTH /home/pi/.homebridge/config.json AND /var/homebridge/config.jsonthx this is cool

    Ok i get Homebridge to show up in iOS Home app, but not the "Living Room Lamp" accessory, it is never listed. what am I missing? thanks

    thank you that was driving me crazy i spent an hour trying to fix it myself

    View Instructable »
  • man thank you so much for the code base, it was the only stuff i could get to work with a SIM900 stacked on a Mega r3 and running hardware serial instead of software serial. You totally made my day, thanks

    View Instructable »