Navigation

    • Register
    • Login
    • OpenHardware.io
    • Categories
    • Recent
    • Tags
    • Popular
    1. Home
    2. rhuehn
    3. Topics
    • Profile
    • Following
    • Followers
    • Topics
    • Posts
    • Best
    • Groups

    Topics created by rhuehn

    • rhuehn

      Prevent Relay from triggering on power loss or broker reboot
      Troubleshooting • • rhuehn  

      22
      0
      Votes
      22
      Posts
      8295
      Views

      Ben Andrewes

      @rhuehn I know this is an old post but I had a similar issue which I solved by inserting a line in my sketch to pull the pin high before setting it as output digitalWrite(RELAY_1_PIN , HIGH); //stops relays cycling state during boot digitalWrite(RELAY_2_PIN , HIGH); //stops relays cycling state during boot pinMode(RELAY_1_PIN , OUTPUT); pinMode(RELAY_2_PIN , OUTPUT);
    • rhuehn

      Mysensors 2.0 + Relay, DHT, and PIR - No Relay
      Hardware • • rhuehn  

      6
      0
      Votes
      6
      Posts
      2643
      Views

      dbemowsk

      I did a similar project that is working well. Mine was powered all the time, so I didn't use the sleep code. The main reason I didn't was so that I could manually control the relay/light when there was no motion detected. It also allowed me to get continuous readings from the LDR so I could use that light level for other things if I ever wanted to. Here is a link to my project. https://forum.mysensors.org/topic/5243/driveway-motion-light . Maybe you can get some ideas from my code.
    • rhuehn

      Help with PIR and Water Sensor or Nano - Water Sensor won't trigger
      Troubleshooting • • rhuehn  

      7
      0
      Votes
      7
      Posts
      1374
      Views

      rhuehn

      Got it working with this sleep function properly: // Sleep until interrupt comes in on motion or water sensor. Send update every two minute. gw.sleep(DIGITAL_INPUT_SENSOR - 2, CHANGE, DIGITAL_INPUT_WATER_SENSOR - 2, CHANGE, SLEEP_TIME);
    • rhuehn

      Combining Multiple sensors - Reed switch not working
      Development • • rhuehn  

      5
      0
      Votes
      5
      Posts
      2279
      Views

      rhuehn

      thanks @fets have I specified the wait time at the wrong location? In the sketch below, everything works, BUT the PIR triggers 0 over and over and over again..... #define MY_GW_ID 50 // Enable debug prints #define MY_DEBUG // Enable and select radio type attached #define MY_RADIO_NRF24 //#define MY_RADIO_RFM69 #include <SPI.h> #include <MySensor.h> #include <DHT.h> #include <Bounce2.h> //Constants #define SKETCH_NAME "3 in 1 Sensor" #define SKETCH_VERSION "1.0" #define CHILD_ID_TEMP 11 // Child id for Temperature #define CHILD_ID_HUM 10 // Child id for Humidity #define CHILD_ID_MOT 2 // Child id for Motion #define HUMIDITY_SENSOR_DIGITAL_PIN 7 // Where is my DHT22 data pin connected to #define DIGITAL_INPUT_SENSOR 3 // The digital input you attached your motion sensor. (Only 2 and 3 generates interrupt!) #define INTERRUPT DIGITAL_INPUT_SENSOR-2 // Usually the interrupt = pin -2 (on uno/nano anyway) #define CHILD_ID_SW 3 // Child id for Reed Switch #define BUTTON_PIN 2 // Arduino Digital I/O pin for button/reed switch #define RELAY_1 4 // Arduino Digital I/O pin number for first relay (second on pin+1 etc) #define NUMBER_OF_RELAYS 1 // Total number of attached relays #define RELAY_ON 1 // GPIO value to write to turn on attached relay #define RELAY_OFF 0 // GPIO value to write to turn off attached relay int node_id=50; // What is my node id MySensor gw; Bounce debouncer = Bounce(); int oldValue=-1; DHT dht; //Store last values float lastTemp = 0 ; float lastHum = 0 ; ; boolean lastTripped = false ; boolean metric = true; boolean gwsend = true; // to determine if data has to be sent MyMessage msgHum(CHILD_ID_HUM, V_HUM); MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP); MyMessage msgMot(CHILD_ID_MOT, V_TRIPPED); MyMessage msgsw(CHILD_ID_SW,V_TRIPPED); void setup() { gw.begin(NULL,node_id,false); gw.wait(5); dht.setup(HUMIDITY_SENSOR_DIGITAL_PIN); // Send the Sketch Version Information to the Gateway gw.sendSketchInfo("3 in 1 Sensor", "1.0",true); // - NEW Setup the button pinMode(BUTTON_PIN,INPUT); // Activate internal pull-up digitalWrite(BUTTON_PIN,HIGH); // After setting up the button, setup debouncer debouncer.attach(BUTTON_PIN); debouncer.interval(5); // - NEW Setup the button END pinMode(DIGITAL_INPUT_SENSOR, INPUT); // sets the motion sensor digital pin as input // Register all sensors to gw (they will be created as child devices) gw.present(CHILD_ID_HUM, S_HUM,"Garage Humidity"); gw.present(CHILD_ID_TEMP, S_TEMP,"Garage Temperature"); gw.present(CHILD_ID_SW, S_DOOR,"Garage Door"); metric = gw.getConfig().isMetric; } void loop() // Read Reed switch value { debouncer.update(); // Get the update value int value = debouncer.read(); if (value != oldValue) { // Send in the new value gw.send(msgsw.set(value==HIGH ? 1 : 0)); oldValue = value; } // Read Temp - Humidity Value { delay(dht.getMinimumSamplingPeriod()); float temperature = dht.getTemperature(); if (isnan(temperature)) { Serial.println("Failed reading temperature from DHT"); } else if (temperature != lastTemp) { lastTemp = temperature; if (!metric) { temperature = dht.toFahrenheit(temperature); } gw.send(msgTemp.set(temperature, 1)); Serial.print("T: "); Serial.println(temperature); } float humidity = dht.getHumidity(); if (isnan(humidity)) { Serial.println("Failed reading humidity from DHT"); } else if (humidity != lastHum) { lastHum = humidity; gw.send(msgHum.set(humidity, 1)); Serial.print("H: "); Serial.println(humidity); } { // Read digital motion PIR value boolean tripped = digitalRead(DIGITAL_INPUT_SENSOR) == HIGH; Serial.println(tripped); gw.send(msgMot.set(tripped?"1":"0")); // Send tripped value to gw } } } Thanks
    • rhuehn

      Low Bat Powered 3 in 1 sensor Please Help
      Troubleshooting • • rhuehn  

      12
      0
      Votes
      12
      Posts
      4415
      Views

      rhuehn

      Thanks @AWI for the reply. I thought I was sending values based on the above code with the following: //Misc. variables unsigned long SLEEP_TIME =60000UL; // Sleep time between reads (in milliseconds) int sleepcycle=1; // Counter to count the amout of time not sending data int humoffset=2; // only data is send if humidity is changed for this amout int tempoffset=1.0; // only data is if temperature is changed for this amout int gwsendtimout=20; // each 20*sleep_time (20 minutes) data will be send The Temp and Humidity in the sketch is quite honestly of lower importance to me as the PIR. I believe ( please correct me if I am wrong ), but the sensor should only report every 20 minutes, and only if a temp changes by a degree or humidity changes by 2 correct? The PIR, and sensor should sleep as often as possible, but based on motion in the vicinity of the sensor, should trigger an action immediately, and based on that, could send the temp and hum readings at the same time, OR every 20 minutes if there is a change... Thanks @AWI comments welcome.
    • rhuehn

      Motion Sensor stopped working on combined sketch ( Hum, Temp, Motion + Bat Level )
      Troubleshooting • • rhuehn  

      3
      0
      Votes
      3
      Posts
      918
      Views

      Dave Dan

      Yeah, @TimO Is right. Check the code example here http://www.mysensors.org/build/motion and look for the gw.sleep sentence. I have a similar sensor and this is what I have in my scketch: gw.sleep(INTERRUPT,CHANGE, SLEEP_TIME); The problem with your sentenc is that the sleep command is not overridden by the motion detection. You need to include the interruption as part of the sleep command.