Navigation

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

    Posts made by Terence Faul

    • RE: 💬 Door, Window and Push-button Sensor

      Hi I notice that there is not sleep in this sketch. Is it not required for this build

      posted in Announcements
      Terence Faul
      Terence Faul
    • Understanding the Serial Monitor?

      Hi

      These are messages received at my gateway by a temp/hum/door node powered y battery.

      299665 TSF:MSG:READ,1-1-0,s=1,c=1,t=0,pt=7,l=5,sg=0:20.0
      299676 TSF:MSG:READ,1-1-0,s=0,c=1,t=1,pt=7,l=5,sg=0:31.0
      299686 TSF:MSG:READ,1-1-0,s=3,c=1,t=16,pt=2,l=2,sg=0:1
      

      Should there not be a message formatted by ; also going to the gateway?

      posted in Troubleshooting
      Terence Faul
      Terence Faul
    • Repeater node

      Hi

      I have a repeater node setup along side a motion sketch.
      As soon as I power it up I get the following lines constantly run on my gateway serial monitor.

      It looks to me like something is wrong, I was under the impression that the repeater will only repeat messages that it receives from other nodes

      TSF:MSG:READ,4-4-0,s=1,c=1,t=16,pt=0,l=1,sg=0:0
      3087 TSF:MSG:READ,4-4-0,s=1,c=1,t=16,pt=0,l=1,sg=0:0
      3095 TSF:MSG:READ,4-4-0,s=1,c=1,t=16,pt=0,l=1,sg=0:0
      3102 TSF:MSG:READ,4-4-0,s=1,c=1,t=16,pt=0,l=1,sg=0:0
      3110 TSF:MSG:READ,4-4-0,s=1,c=1,t=16,pt=0,l=1,sg=0:0
      3119 TSF:MSG:READ,4-4-0,s=1,c=1,t=16,pt=0,l=1,sg=0:0
      3127 TSF:MSG:READ,4-4-0,s=1,c=1,t=16,pt=0,l=1,sg=0:0
      3134 TSF:MSG:READ,4-4-0,s=1,c=1,t=16,pt=0,l=1,sg=0:0
      3142 TSF:MSG:READ,4-4-0,s=1,c=1,t=16,pt=0,l=1,sg=0:0
      3150 TSF:MSG:READ,4-4-0,s=1,c=1,t=16,pt=0,l=1,sg=0:0
      3159 TSF:MSG:READ,4-4-0,s=1,c=1,t=16,pt=0,l=1,sg=0:0
      3166 TSF:MSG:READ,4-4-0,s=1,c=1,t=16,pt=0,l=1,sg=0:0
      3174 TSF:MSG:READ,4-4-0,s=1,c=1,t=16,pt=0,l=1,sg=0:0
      3182 TSF:MSG:READ,4-4-0,s=1,c=1,t=16,pt=0,l=1,sg=0:0
      3190 TSF:MSG:READ,4-4-0,s=1,c=1,t=16,pt=0,l=1,sg=0:0
      
      3197 TSF:MSG:READ,4-4-0,s=1,c=1,t=16,pt=0,l=1,sg=0:0
      3206 TSF:MSG:READ,4-4-0,s=1,c=1,t=16,pt=0,l=1,sg=0:0
      3214 TSF:MSG:READ,4-4-0,s=1,c=1,t=16,pt=0,l=1,sg=0:0
      3222 TSF:MSG:READ,4-4-0,s=1,c=1,t=16,pt=0,l=1,sg=0:0
      3229 TSF:MSG:READ,4-4-0,s=1,c=1,t=16,pt=0,l=1,sg=0:0
      3237 TSF:MSG:READ,4-4-0,s=1,c=1,t=16,pt=0,l=1,sg=0:0
      3248 TSF:MSG:READ,4-4-0,s=1,c=1,t=16,pt=0,l=1,sg=0:0
      3256 TSF:MSG:READ,4-4-0,s=1,c=1,t=16,pt=0,l=1,sg=0:0
      3263 TSF:MSG:READ,4-4-0,s=1,c=1,t=16,pt=0,l=1,sg=0:0
      3271 TSF:MSG:READ,4-4-0,s=1,c=1,t=16,pt=0,l=1,sg=0:0
      3279 TSF:MSG:READ,4-4-0,s=1,c=1,t=16,pt=0,l=1,sg=0:0
      3288 TSF:MSG:READ,4-4-0,s=1,c=1,t=16,pt=0,l=1,sg=0:0
      3295 TSF:MSG:READ,4-4-0,s=1,c=1,t=16,pt=0,l=1,sg=0:0
      3303 TSF:MSG:READ,4-4-0,s=1,c=1,t=16,pt=0,l=1,sg=0:0```
      posted in Troubleshooting
      Terence Faul
      Terence Faul
    • RE: bootloaders

      Yep that's why I was asking.

      Anyone able to assist in getting this board into platformio?

      posted in General Discussion
      Terence Faul
      Terence Faul
    • bootloaders

      Hi

      Can someone assist.

      is mysensors/MySensorsBootloaderRF24 the same as MYSbootloader?

      posted in General Discussion
      Terence Faul
      Terence Faul
    • RE: Interupt not waking sensor

      Is it possible the reed switch is causing a wake up, but not detecting a change in the state of the reed switch and that is why the value is not changing?

      posted in My Project
      Terence Faul
      Terence Faul
    • RE: Interupt not waking sensor

      @mfalkvidd said in Interupt not waking sensor:

      Serial.println(value);

      It looks as if the Interupt is waking the sensor correctly, but not changing the value.
      If I wait for UPDATE_INTERVAL to expire though then the value is updated?

      when the Interupt is called does that invoke the loop from the beginning?
      What do you think?

      0
      6565 MCO:SLP:MS=60000,SMS=0,I1=1,M1=1,I2=255,M2=255
      6572 TSF:TDI:TSL
      6574 MCO:SLP:WUP=1
      6576 TSF:TRI:TSB
      Vbat 3.36       Perc 100
      0
      6658 MCO:SLP:MS=60000,SMS=0,I1=1,M1=1,I2=255,M2=255
      6662 TSF:TDI:TSL
      6664 MCO:SLP:WUP=1
      6666 TSF:TRI:TSB
      Vbat 3.35       Perc 100
      0
      6748 MCO:SLP:MS=60000,SMS=0,I1=1,M1=1,I2=255,M2=255
      6752 TSF:TDI:TSL
      
      6754 MCO:SLP:WUP=1
      6756 TSF:TRI:TSB
      Vbat 3.36       Perc 100
      6789 TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=0,pt=7,l=5,sg=0,ft=0,st=OK:22.0
      T: 22.00
      0
      6848 MCO:SLP:MS=60000,SMS=0,I1=1,M1=1,I2=255,M2=255
      6852 TSF:TDI:TSL```
      posted in My Project
      Terence Faul
      Terence Faul
    • RE: Interupt not waking sensor

      so I have the intercuts working now, but when I activate the interrupt the sensor wakes up and reports everything except the reed switch. What am I missing, surly when the interput triggers the void loop runs from start to finnish again?

      If I remove the Interupt then the reed switch reports but only when the sensor wakes up

      /**
       * The MySensors Arduino library handles the wireless radio link and protocol
       * between your home built sensors/actuators and HA controller of choice.
       * The sensors forms a self healing radio network with optional repeaters. Each
       * repeater and gateway builds a routing tables in EEPROM which keeps track of the
       * network topology allowing messages to be routed to nodes.
       *
       * Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
       * Copyright (C) 2013-2015 Sensnology AB
       * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
       *
       * Documentation: http://www.mysensors.org
       * Support Forum: http://forum.mysensors.org
       *
       * This program is free software; you can redistribute it and/or
       * modify it under the terms of the GNU General Public License
       * version 2 as published by the Free Software Foundation.
       *
       *******************************
       *
       * REVISION HISTORY
       * Version 1.0: Henrik EKblad
       * Version 1.1 - 2016-07-20: Converted to MySensors v2.0 and added various improvements - Torben Woltjen (mozzbozz)
       *
       * DESCRIPTION
       * This sketch provides an example of how to implement a humidity/temperature
       * sensor using a DHT11/DHT-22.
       *
       * For more information, please visit:
       * http://www.mysensors.org/build/humidity
       *
       */
      
      // Enable debug prints
      #define MY_DEBUG
      
      // Enable REPORT_BATTERY_LEVEL to measure battery level and send changes to gateway
      #define REPORT_BATTERY_LEVEL
      
      // Enable and select radio type attached
      #define MY_RADIO_RF24
      //#define MY_RADIO_RFM69
      //#define MY_RS485
      
      #include <SPI.h>
      #include <MySensors.h>
      #include <DHT.h>
      #include <Bounce2.h>
      
      // Set this to the pin you connected the DHT's data pin to
      #define DHT_DATA_PIN 4
      #define CHILD_ID 3
      #define BUTTON_PIN  3  // Arduino Digital I/O pin for button/reed switch
      
      // Set this offset if the sensor has a permanent small offset to the real temperatures.
      // In Celsius degrees (as measured by the device)
      #define SENSOR_TEMP_OFFSET 0
      
      // Sleep time between sensor updates (in milliseconds)
      // Must be >1000ms for DHT22 and >2000ms for DHT11
      static const uint64_t UPDATE_INTERVAL = 60000;
      
      // Force sending an update of the temperature after n sensor reads, so a controller showing the
      // timestamp of the last update doesn't show something like 3 hours in the unlikely case, that
      // the value didn't change since;
      // i.e. the sensor would force sending an update every UPDATE_INTERVAL*FORCE_UPDATE_N_READS [ms]
      static const uint8_t FORCE_UPDATE_N_READS = 10;
      
      #define CHILD_ID_HUM 0
      #define CHILD_ID_TEMP 1
      
      float lastTemp;
      float lastHum;
      uint8_t nNoUpdatesTemp;
      uint8_t nNoUpdatesHum;
      bool metric = true;
      
      MyMessage msgHum(CHILD_ID_HUM, V_HUM);
      MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP);
      DHT dht;
      
      Bounce debouncer = Bounce();
      int oldValue=-1;
      
      // Change to V_LIGHT if you use S_LIGHT in presentation below
      MyMessage msg(CHILD_ID,V_TRIPPED);
      
      #ifdef REPORT_BATTERY_LEVEL
      #include <Vcc.h>
      static uint8_t oldBatteryPcnt = 200;  // Initialize to 200 to assure first time value will be sent.
      const float VccMin        = 1.8;      // Minimum expected Vcc level, in Volts: Brownout at 1.8V    -> 0%
      const float VccMax        = 2.0*1.6;  // Maximum expected Vcc level, in Volts: 2xAA fresh Alkaline -> 100%
      const float VccCorrection = 1.0;      // Measured Vcc by multimeter divided by reported Vcc
      static Vcc vcc(VccCorrection);
      #endif
      
      void setup()
      {
        dht.setup(DHT_DATA_PIN); // set data pin of DHT sensor
        if (UPDATE_INTERVAL <= dht.getMinimumSamplingPeriod()) {
          Serial.println("Warning: UPDATE_INTERVAL is smaller than supported by the sensor!");
        }
        // Sleep for the time of the minimum sampling period to give the sensor time to power up
        // (otherwise, timeout errors might occure for the first reading)
        sleep(dht.getMinimumSamplingPeriod());
      
        // 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);
      }
      
      void presentation()
      {
        // Send the sketch version information to the gateway
        sendSketchInfo("DHT&Door", "1.1");
      
        // Register all sensors to gw (they will be created as child devices)
        present(CHILD_ID_HUM, S_HUM);
        present(CHILD_ID_TEMP, S_TEMP);
      
        metric = getControllerConfig().isMetric;
      
        // Register binary input sensor to gw (they will be created as child devices)
        // You can use S_DOOR, S_MOTION or S_LIGHT here depending on your usage.
        // If S_LIGHT is used, remember to update variable type you send in. See "msg" above.
        present(CHILD_ID, S_DOOR);
      }
      
      
      void loop()
      {
        #ifdef REPORT_BATTERY_LEVEL
        const uint8_t batteryPcnt = static_cast<uint8_t>(0.5 + vcc.Read_Perc(VccMin, VccMax));
      
      #ifdef MY_DEBUG
        Serial.print(F("Vbat "));
        Serial.print(vcc.Read_Volts());
        Serial.print(F("\tPerc "));
        Serial.println(batteryPcnt);
      #endif
      
        // Battery readout should only go down. So report only when new value is smaller than previous one.
        if ( batteryPcnt < oldBatteryPcnt )
        {
            sendBatteryLevel(batteryPcnt);
            oldBatteryPcnt = batteryPcnt;
        }
      #endif
      
        // Force reading sensor, so it works also after sleep()
        dht.readSensor(true);
      
        // Get temperature from DHT library
        float temperature = dht.getTemperature();
        if (isnan(temperature)) {
          Serial.println("Failed reading temperature from DHT!");
        } else if (temperature != lastTemp || nNoUpdatesTemp == FORCE_UPDATE_N_READS) {
          // Only send temperature if it changed since the last measurement or if we didn't send an update for n times
          lastTemp = temperature;
      
          // apply the offset before converting to something different than Celsius degrees
          temperature += SENSOR_TEMP_OFFSET;
      
          if (!metric) {
            temperature = dht.toFahrenheit(temperature);
          }
          // Reset no updates counter
          nNoUpdatesTemp = 0;
          send(msgTemp.set(temperature, 1));
      
          #ifdef MY_DEBUG
            Serial.print("T: ");
            Serial.println(temperature);
          #endif
        } else {
          // Increase no update counter if the temperature stayed the same
          nNoUpdatesTemp++;
        }
      
        // Get humidity from DHT library
        float humidity = dht.getHumidity();
        if (isnan(humidity)) {
          Serial.println("Failed reading humidity from DHT");
        } else if (humidity != lastHum || nNoUpdatesHum == FORCE_UPDATE_N_READS) {
          // Only send humidity if it changed since the last measurement or if we didn't send an update for n times
          lastHum = humidity;
          // Reset no updates counter
          nNoUpdatesHum = 0;
          send(msgHum.set(humidity, 1));
      
          #ifdef MY_DEBUG
            Serial.print("H: ");
            Serial.println(humidity);
          #endif
        } else {
          // Increase no update counter if the humidity stayed the same
          nNoUpdatesHum++;
        }
      
         debouncer.update();
          // Get the update value
         int value = debouncer.read();
      
         if (value != oldValue) {
            // Send in the new value
            send(msg.set(value==HIGH ? 1 : 0));
            oldValue = value;
          }
      
        // Sleep until interrupt comes in on motion sensor. Send update every two minute.
        sleep(digitalPinToInterrupt(BUTTON_PIN), CHANGE, UPDATE_INTERVAL);
        // Sleep for a while to save energy
        //sleep(UPDATE_INTERVAL);
      
      }
      

      When I close the reed switch

      Vbat 3.35       Perc 100
      Failed reading temperature from DHT!
      Failed reading humidity from DHT
      4765 MCO:SLP:MS=60000,SMS=0,I1=1,M1=1,I2=255,M2=255
      4775 TSF:TDI:TSL
      4777 MCO:SLP:WUP=1
      4780 TSF:TRI:TSB
      Vbat 3.35       Perc 100
      4812 TSF:MSG:SEND,1-1-0-0,s=0,c=1,t=1,pt=7,l=5,sg=0,ft=0,st=OK:34.0
      H: 34.00
      4820 MCO:SLP:MS=60000,SMS=0,I1=1,M1=1,I2=255,M2=255
      4827 TSF:TDI:TSL
      4827 MCO:SLP:WUP=1
      4829 TSF:TRI:TSB
      Vbat 3.35       Perc 100
      
      4861 TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=0,pt=7,l=5,sg=0,ft=0,st=OK:22.0
      T: 22.00
      4870 MCO:SLP:MS=60000,SMS=0,I1=1,M1=1,I2=255,M2=255
      4876 TSF:TDI:TSL
      4878 MCO:SLP:WUP=1
      4880 TSF:TRI:TSB
      Vbat 3.35       Perc 100
      4911 MCO:SLP:MS=60000,SMS=0,I1=1,M1=1,I2=255,M2=255
      4915 TSF:TDI:TSL
      4917 MCO:SLP:WUP=1
      4919 TSF:TRI:TSB
      Vbat 3.35       Perc 100
      4950 MCO:SLP:MS=60000,SMS=0,I1=1,M1=1,I2=255,M2=255
      4956 TSF:TDI:TSL```
      posted in My Project
      Terence Faul
      Terence Faul
    • RE: Multiple Gateways

      Thanks that was really useful, I think the only way would be to define the node ID.
      Would that require that the node have its EEPROM cleaned first?

      posted in General Discussion
      Terence Faul
      Terence Faul
    • RE: Interupt not waking sensor

      That would make alot of sense, sorry NOOB. I imagine then it is only reporting when the sensor wakes up from sleep.

      how do I go about including this. I was under the impression that this was automatic for pin 2 and 3

      posted in My Project
      Terence Faul
      Terence Faul
    • Interupt not waking sensor

      Hi

      For some reason the innterput is not waking my sensor, can you please see if you spot something in the sketch

      /**
       * The MySensors Arduino library handles the wireless radio link and protocol
       * between your home built sensors/actuators and HA controller of choice.
       * The sensors forms a self healing radio network with optional repeaters. Each
       * repeater and gateway builds a routing tables in EEPROM which keeps track of the
       * network topology allowing messages to be routed to nodes.
       *
       * Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
       * Copyright (C) 2013-2015 Sensnology AB
       * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
       *
       * Documentation: http://www.mysensors.org
       * Support Forum: http://forum.mysensors.org
       *
       * This program is free software; you can redistribute it and/or
       * modify it under the terms of the GNU General Public License
       * version 2 as published by the Free Software Foundation.
       *
       *******************************
       *
       * REVISION HISTORY
       * Version 1.0: Henrik EKblad
       * Version 1.1 - 2016-07-20: Converted to MySensors v2.0 and added various improvements - Torben Woltjen (mozzbozz)
       *
       * DESCRIPTION
       * This sketch provides an example of how to implement a humidity/temperature
       * sensor using a DHT11/DHT-22.
       *
       * For more information, please visit:
       * http://www.mysensors.org/build/humidity
       *
       */
      
      // Enable debug prints
      #define MY_DEBUG
      
      // Enable REPORT_BATTERY_LEVEL to measure battery level and send changes to gateway
      #define REPORT_BATTERY_LEVEL
      
      // Enable and select radio type attached
      #define MY_RADIO_RF24
      //#define MY_RADIO_RFM69
      //#define MY_RS485
      
      #include <SPI.h>
      #include <MySensors.h>
      #include <DHT.h>
      #include <Bounce2.h>
      
      // Set this to the pin you connected the DHT's data pin to
      #define DHT_DATA_PIN 4
      #define CHILD_ID 3
      #define BUTTON_PIN  3  // Arduino Digital I/O pin for button/reed switch
      
      // Set this offset if the sensor has a permanent small offset to the real temperatures.
      // In Celsius degrees (as measured by the device)
      #define SENSOR_TEMP_OFFSET 0
      
      // Sleep time between sensor updates (in milliseconds)
      // Must be >1000ms for DHT22 and >2000ms for DHT11
      static const uint64_t UPDATE_INTERVAL = 60000;
      
      // Force sending an update of the temperature after n sensor reads, so a controller showing the
      // timestamp of the last update doesn't show something like 3 hours in the unlikely case, that
      // the value didn't change since;
      // i.e. the sensor would force sending an update every UPDATE_INTERVAL*FORCE_UPDATE_N_READS [ms]
      static const uint8_t FORCE_UPDATE_N_READS = 10;
      
      #define CHILD_ID_HUM 0
      #define CHILD_ID_TEMP 1
      
      float lastTemp;
      float lastHum;
      uint8_t nNoUpdatesTemp;
      uint8_t nNoUpdatesHum;
      bool metric = true;
      
      MyMessage msgHum(CHILD_ID_HUM, V_HUM);
      MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP);
      DHT dht;
      
      Bounce debouncer = Bounce();
      int oldValue=-1;
      
      // Change to V_LIGHT if you use S_LIGHT in presentation below
      MyMessage msg(CHILD_ID,V_TRIPPED);
      
      #ifdef REPORT_BATTERY_LEVEL
      #include <Vcc.h>
      static uint8_t oldBatteryPcnt = 200;  // Initialize to 200 to assure first time value will be sent.
      const float VccMin        = 1.8;      // Minimum expected Vcc level, in Volts: Brownout at 1.8V    -> 0%
      const float VccMax        = 2.0*1.6;  // Maximum expected Vcc level, in Volts: 2xAA fresh Alkaline -> 100%
      const float VccCorrection = 1.0;      // Measured Vcc by multimeter divided by reported Vcc
      static Vcc vcc(VccCorrection);
      #endif
      
      void setup()
      {
        dht.setup(DHT_DATA_PIN); // set data pin of DHT sensor
        if (UPDATE_INTERVAL <= dht.getMinimumSamplingPeriod()) {
          Serial.println("Warning: UPDATE_INTERVAL is smaller than supported by the sensor!");
        }
        // Sleep for the time of the minimum sampling period to give the sensor time to power up
        // (otherwise, timeout errors might occure for the first reading)
        sleep(dht.getMinimumSamplingPeriod());
      
        // 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);
      }
      
      void presentation()
      {
        // Send the sketch version information to the gateway
        sendSketchInfo("DHT&Door", "1.1");
      
        // Register all sensors to gw (they will be created as child devices)
        present(CHILD_ID_HUM, S_HUM);
        present(CHILD_ID_TEMP, S_TEMP);
      
        metric = getControllerConfig().isMetric;
      
        // Register binary input sensor to gw (they will be created as child devices)
        // You can use S_DOOR, S_MOTION or S_LIGHT here depending on your usage.
        // If S_LIGHT is used, remember to update variable type you send in. See "msg" above.
        present(CHILD_ID, S_DOOR);
      }
      
      
      void loop()
      {
        // Force reading sensor, so it works also after sleep()
        dht.readSensor(true);
      
        // Get temperature from DHT library
        float temperature = dht.getTemperature();
        if (isnan(temperature)) {
          Serial.println("Failed reading temperature from DHT!");
        } else if (temperature != lastTemp || nNoUpdatesTemp == FORCE_UPDATE_N_READS) {
          // Only send temperature if it changed since the last measurement or if we didn't send an update for n times
          lastTemp = temperature;
      
          // apply the offset before converting to something different than Celsius degrees
          temperature += SENSOR_TEMP_OFFSET;
      
          if (!metric) {
            temperature = dht.toFahrenheit(temperature);
          }
          // Reset no updates counter
          nNoUpdatesTemp = 0;
          send(msgTemp.set(temperature, 1));
      
          #ifdef MY_DEBUG
            Serial.print("T: ");
            Serial.println(temperature);
          #endif
        } else {
          // Increase no update counter if the temperature stayed the same
          nNoUpdatesTemp++;
        }
      
        // Get humidity from DHT library
        float humidity = dht.getHumidity();
        if (isnan(humidity)) {
          Serial.println("Failed reading humidity from DHT");
        } else if (humidity != lastHum || nNoUpdatesHum == FORCE_UPDATE_N_READS) {
          // Only send humidity if it changed since the last measurement or if we didn't send an update for n times
          lastHum = humidity;
          // Reset no updates counter
          nNoUpdatesHum = 0;
          send(msgHum.set(humidity, 1));
      
          #ifdef MY_DEBUG
            Serial.print("H: ");
            Serial.println(humidity);
          #endif
        } else {
          // Increase no update counter if the humidity stayed the same
          nNoUpdatesHum++;
        }
      
         debouncer.update();
          // Get the update value
         int value = debouncer.read();
      
         if (value != oldValue) {
            // Send in the new value
            send(msg.set(value==HIGH ? 1 : 0));
            oldValue = value;
          }
      
        #ifdef REPORT_BATTERY_LEVEL
        const uint8_t batteryPcnt = static_cast<uint8_t>(0.5 + vcc.Read_Perc(VccMin, VccMax));
      
      #ifdef MY_DEBUG
        Serial.print(F("Vbat "));
        Serial.print(vcc.Read_Volts());
        Serial.print(F("\tPerc "));
        Serial.println(batteryPcnt);
      #endif
      
        // Battery readout should only go down. So report only when new value is smaller than previous one.
        if ( batteryPcnt < oldBatteryPcnt )
        {
            sendBatteryLevel(batteryPcnt);
            oldBatteryPcnt = batteryPcnt;
        }
      #endif
        // Sleep for a while to save energy
        sleep(UPDATE_INTERVAL);
      
      }
      
      posted in My Project
      Terence Faul
      Terence Faul
    • Multiple Gateways

      Hi

      I live on a high property and as such. have more than one gateway. I have not changed the channel of these gateways as they are not in wireless range of each other. and I want to have the nodes be interchangeable between gateways without the need to have to upload a new sketch each time they are moved between gateways.

      What are the implications of this setup, will each gateway remember the node if the nodes are move from one gateways range to the other, or does the gateway allocate a node id automatically each time the node presents itself to the gateway.

      How will this impact the controller (Home Assistant) will the controller be confused

      posted in General Discussion
      Terence Faul
      Terence Faul
    • Ethernet gateway

      Hi hope someone can assist

      I have a gateway with wiznet 5100 shield.
      I haver the sketch loaded and I get a IP address assigned

      Here is the sketch and I use Home assistant as a controller. The error is slow and just loops and loops

      /*
       * The MySensors Arduino library handles the wireless radio link and protocol
       * between your home built sensors/actuators and HA controller of choice.
       * The sensors forms a self healing radio network with optional repeaters. Each
       * repeater and gateway builds a routing tables in EEPROM which keeps track of the
       * network topology allowing messages to be routed to nodes.
       *
       * Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
       * Copyright (C) 2013-2019 Sensnology AB
       * Full contributor list: https://github.com/mysensors/MySensors/graphs/contributors
       *
       * Documentation: http://www.mysensors.org
       * Support Forum: http://forum.mysensors.org
       *
       * This program is free software; you can redistribute it and/or
       * modify it under the terms of the GNU General Public License
       * version 2 as published by the Free Software Foundation.
       *
       *******************************
       *
       * REVISION HISTORY
       * Version 1.0 - Henrik Ekblad
       * Contribution by a-lurker and Anticimex
       * Contribution by Norbert Truchsess <norbert.truchsess@t-online.de>
       * Contribution by Tomas Hozza <thozza@gmail.com>
       *
       *
       * DESCRIPTION
       * The EthernetGateway sends data received from sensors to the ethernet link.
       * The gateway also accepts input on ethernet interface, which is then sent out to the radio network.
       *
       * The GW code is designed for Arduino 328p / 16MHz.  ATmega168 does not have enough memory to run this program.
       *
       * LED purposes:
       * - To use the feature, uncomment MY_DEFAULT_xxx_LED_PIN in the sketch below
       * - RX (green) - blink fast on radio message received. In inclusion mode will blink fast only on presentation received
       * - TX (yellow) - blink fast on radio message transmitted. In inclusion mode will blink slowly
       * - ERR (red) - fast blink on error during transmission error or receive crc error
       *
       * See http://www.mysensors.org/build/ethernet_gateway for wiring instructions.
       *
       */
      
      // Enable debug prints to serial monitor
      #define MY_DEBUG
      #define MY_HOSTNAME "MySensorsEth"
      //#define MY_DEBUG_VERBOSE_RF24
      
      // Enable and select radio type attached
      #define MY_RADIO_RF24
      //#define MY_RADIO_NRF5_ESB
      //#define MY_RADIO_RFM69
      //#define MY_RADIO_RFM95
      
      // Enable gateway ethernet module type
      #define MY_GATEWAY_W5100
      
      // W5100 Ethernet module SPI enable (optional if using a shield/module that manages SPI_EN signal)
      //#define MY_W5100_SPI_EN 4
      
      // Enable Soft SPI for NRF radio (note different radio wiring is required)
      // The W5100 ethernet module seems to have a hard time co-operate with
      // radio on the same spi bus.
      #if !defined(MY_W5100_SPI_EN) && !defined(ARDUINO_ARCH_SAMD)
      #define MY_SOFTSPI
      #define MY_SOFT_SPI_SCK_PIN 14
      #define MY_SOFT_SPI_MISO_PIN 16
      #define MY_SOFT_SPI_MOSI_PIN 15
      #endif
      
      // When W5100 is connected we have to move CE/CSN pins for NRF radio
      #ifndef MY_RF24_CE_PIN
      #define MY_RF24_CE_PIN 5
      #endif
      #ifndef MY_RF24_CS_PIN
      #define MY_RF24_CS_PIN 6
      #endif
      
      // Enable UDP communication
      //#define MY_USE_UDP  // If using UDP you need to set MY_CONTROLLER_IP_ADDRESS or MY_CONTROLLER_URL_ADDRESS below
      
      // Enable MY_IP_ADDRESS here if you want a static ip address (no DHCP)
      //#define MY_IP_ADDRESS 192,168,168,92
      
      // If using static ip you can define Gateway and Subnet address as well
      //#define MY_IP_GATEWAY_ADDRESS 192,168,168,1
      //#define MY_IP_SUBNET_ADDRESS 255,255,255,0
      
      // Renewal period if using DHCP
      //#define MY_IP_RENEWAL_INTERVAL 60000
      
      // The port to keep open on node server mode / or port to contact in client mode
      #define MY_PORT 5003
      
      // Controller ip address. Enables client mode (default is "server" mode).
      // Also enable this if MY_USE_UDP is used and you want sensor data sent somewhere.
      //#define MY_CONTROLLER_IP_ADDRESS 192, 168, 178, 254
      //#define MY_CONTROLLER_URL_ADDRESS "my.controller.org"
      
      // The MAC address can be anything you want but should be unique on your network.
      // Newer boards have a MAC address printed on the underside of the PCB, which you can (optionally) use.
      // Note that most of the Arduino examples use  "DEAD BEEF FEED" for the MAC address.
      //#define MY_MAC_ADDRESS 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED
      
      
      // Enable inclusion mode
      #define MY_INCLUSION_MODE_FEATURE
      // Enable Inclusion mode button on gateway
      //#define MY_INCLUSION_BUTTON_FEATURE
      // Set inclusion mode duration (in seconds)
      #define MY_INCLUSION_MODE_DURATION 60
      // Digital pin used for inclusion mode button
      //#define MY_INCLUSION_MODE_BUTTON_PIN  3
      
      // Set blinking period
      #define MY_DEFAULT_LED_BLINK_PERIOD 300
      
      // Flash leds on rx/tx/err
      // Uncomment to override default HW configurations
      //#define MY_DEFAULT_ERR_LED_PIN 7  // Error led pin
      //#define MY_DEFAULT_RX_LED_PIN  8  // Receive led pin
      //#define MY_DEFAULT_TX_LED_PIN  9  // Transmit led pin
      
      #if defined(MY_USE_UDP)
      #include <EthernetUdp.h>
      #endif
      #include <Ethernet.h>
      #include <MySensors.h>
      
      void setup()
      {
          // Setup locally attached sensors
      }
      
      void presentation()
      {
          // Present locally attached sensors here
      }
      
      void loop()
      {
          // Send locally attached sensors data here
      }
      

      Looping error

      pio device monitor --port /dev/cu.usbserial-14320 --baud 115200
      Tmac:Gateway terencefaul$ pio device monitor --port /dev/cu.usbserial-14320 --baud 115200
      --- Miniterm on /dev/cu.usbserial-14320  115200,8,N,1 ---
      --- Quit: Ctrl+C | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---
      0 MCO:BGN:INIT GW,CP=RNNGA---,REL=255,VER=2.3.1
      4 TSM:INIT
      5 TSF:WUR:MS=0
      11 TSM:INIT:TSP OK
      13 TSM:INIT:GW MODE
      15 TSM:READY:ID=0,PAR=0,DIS=0
      17 MCO:REG:NOT NEEDED
      4706 GWT:TIN:IP=192.168.1.92
      5709 MCO:BGN:STP
      5711 MCO:BGN:INIT OK,TSP=1
      5713 GWT:TSA:ETH OK
      
      5716 !GWT:TSA:ETH FAIL
      5719 TSM:READY:NWD REQ
      5755 TSF:MSG:SEND,0-0-255-255,s=255,c=3,t=20,pt=0,l=0,sg=0,ft=0,st=OK:
      5762 GWT:TSA:ETH OK
      5765 !GWT:TSA:ETH FAIL
      5767 GWT:TSA:ETH OK
      5770 !GWT:TSA:ETH FAIL
      5772 GWT:TSA:ETH OK
      5775 !GWT:TSA:ETH FAIL
      5777 GWT:TSA:ETH OK```
      posted in My Project
      Terence Faul
      Terence Faul
    • RE: DHT and DOOR sensor

      Thanks so much for the help, what is the next step then? create two sensors?

      posted in My Project
      Terence Faul
      Terence Faul
    • RE: DHT and DOOR sensor
      /**
       * The MySensors Arduino library handles the wireless radio link and protocol
       * between your home built sensors/actuators and HA controller of choice.
       * The sensors forms a self healing radio network with optional repeaters. Each
       * repeater and gateway builds a routing tables in EEPROM which keeps track of the
       * network topology allowing messages to be routed to nodes.
       *
       * Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
       * Copyright (C) 2013-2015 Sensnology AB
       * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
       *
       * Documentation: http://www.mysensors.org
       * Support Forum: http://forum.mysensors.org
       *
       * This program is free software; you can redistribute it and/or
       * modify it under the terms of the GNU General Public License
       * version 2 as published by the Free Software Foundation.
       *
       *******************************
       *
       * REVISION HISTORY
       * Version 1.0: Henrik EKblad
       * Version 1.1 - 2016-07-20: Converted to MySensors v2.0 and added various improvements - Torben Woltjen (mozzbozz)
       *
       * DESCRIPTION
       * This sketch provides an example of how to implement a humidity/temperature
       * sensor using a DHT11/DHT-22.
       *
       * For more information, please visit:
       * http://www.mysensors.org/build/humidity
       *
       */
      
      // Enable debug prints
      #define MY_DEBUG
      
      // Enable and select radio type attached
      #define MY_RADIO_NRF24
      //#define MY_RADIO_RFM69
      //#define MY_RS485
      
      #include <SPI.h>
      #include <MySensors.h>
      #include <DHT.h>
      
      // Set this to the pin you connected the DHT's data pin to
      #define DHT_DATA_PIN 4
      
      // Set this offset if the sensor has a permanent small offset to the real temperatures.
      // In Celsius degrees (as measured by the device)
      #define SENSOR_TEMP_OFFSET 0
      
      // Sleep time between sensor updates (in milliseconds)
      // Must be >1000ms for DHT22 and >2000ms for DHT11
      static const uint64_t UPDATE_INTERVAL = 60000;
      
      // Force sending an update of the temperature after n sensor reads, so a controller showing the
      // timestamp of the last update doesn't show something like 3 hours in the unlikely case, that
      // the value didn't change since;
      // i.e. the sensor would force sending an update every UPDATE_INTERVAL*FORCE_UPDATE_N_READS [ms]
      static const uint8_t FORCE_UPDATE_N_READS = 10;
      
      #define CHILD_ID_HUM 0
      #define CHILD_ID_TEMP 1
      
      float lastTemp;
      float lastHum;
      uint8_t nNoUpdatesTemp;
      uint8_t nNoUpdatesHum;
      bool metric = true;
      
      MyMessage msgHum(CHILD_ID_HUM, V_HUM);
      MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP);
      DHT dht;
      
      
      void presentation()
      {
        // Send the sketch version information to the gateway
        sendSketchInfo("TemperatureAndHumidity", "1.1");
      
        // Register all sensors to gw (they will be created as child devices)
        present(CHILD_ID_HUM, S_HUM);
        present(CHILD_ID_TEMP, S_TEMP);
      
        metric = getControllerConfig().isMetric;
      }
      
      
      void setup()
      {
        dht.setup(DHT_DATA_PIN); // set data pin of DHT sensor
        if (UPDATE_INTERVAL <= dht.getMinimumSamplingPeriod()) {
          Serial.println("Warning: UPDATE_INTERVAL is smaller than supported by the sensor!");
        }
        // Sleep for the time of the minimum sampling period to give the sensor time to power up
        // (otherwise, timeout errors might occure for the first reading)
          sleep(dht.getMinimumSamplingPeriod());
      }
      
      
      void loop()
      {
        // Force reading sensor, so it works also after sleep()
        dht.readSensor(true);
      
        // Get temperature from DHT library
        float temperature = dht.getTemperature();
        if (isnan(temperature)) {
          Serial.println("Failed reading temperature from DHT!");
        } else if (temperature != lastTemp || nNoUpdatesTemp == FORCE_UPDATE_N_READS) {
          // Only send temperature if it changed since the last measurement or if we didn't send an update for n times
          lastTemp = temperature;
      
          // apply the offset before converting to something different than Celsius degrees
          temperature += SENSOR_TEMP_OFFSET;
      
          if (!metric) {
            temperature = dht.toFahrenheit(temperature);
          }
          // Reset no updates counter
          nNoUpdatesTemp = 0;
          send(msgTemp.set(temperature, 1));
      
          #ifdef MY_DEBUG
          Serial.print("T: ");
          Serial.println(temperature);
          #endif
        } else {
          // Increase no update counter if the temperature stayed the same
          nNoUpdatesTemp++;
        }
      
        // Get humidity from DHT library
        float humidity = dht.getHumidity();
        if (isnan(humidity)) {
          Serial.println("Failed reading humidity from DHT");
        } else if (humidity != lastHum || nNoUpdatesHum == FORCE_UPDATE_N_READS) {
          // Only send humidity if it changed since the last measurement or if we didn't send an update for n times
          lastHum = humidity;
          // Reset no updates counter
          nNoUpdatesHum = 0;
          send(msgHum.set(humidity, 1));
      
          #ifdef MY_DEBUG
          Serial.print("H: ");
          Serial.println(humidity);
          #endif
        } else {
          // Increase no update counter if the humidity stayed the same
          nNoUpdatesHum++;
        }
      
        // Sleep for a while to save energy
        sleep(UPDATE_INTERVAL);
      }
      
      posted in My Project
      Terence Faul
      Terence Faul
    • RE: DHT and DOOR sensor

      Will give that a go. But if I load the DHT only sketch on the same node it reads fine.

      Could you check my sketch I’m a bit of a noob with code

      posted in My Project
      Terence Faul
      Terence Faul
    • RE: DHT and DOOR sensor

      Hi

      I have sorted the pins and library problems, but now I get failed to read errors

      Updated Sketch

      /**
       * The MySensors Arduino library handles the wireless radio link and protocol
       * between your home built sensors/actuators and HA controller of choice.
       * The sensors forms a self healing radio network with optional repeaters. Each
       * repeater and gateway builds a routing tables in EEPROM which keeps track of the
       * network topology allowing messages to be routed to nodes.
       *
       * Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
       * Copyright (C) 2013-2015 Sensnology AB
       * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
       *
       * Documentation: http://www.mysensors.org
       * Support Forum: http://forum.mysensors.org
       *
       * This program is free software; you can redistribute it and/or
       * modify it under the terms of the GNU General Public License
       * version 2 as published by the Free Software Foundation.
       *
       *******************************
       *
       * REVISION HISTORY
       * Version 1.0: Henrik EKblad
       * Version 1.1 - 2016-07-20: Converted to MySensors v2.0 and added various improvements - Torben Woltjen (mozzbozz)
       *
       * DESCRIPTION
       * This sketch provides an example of how to implement a humidity/temperature
       * sensor using a DHT11/DHT-22.
       *
       * For more information, please visit:
       * http://www.mysensors.org/build/humidity
       *
       */
      
      // Enable debug prints
      #define MY_DEBUG
      
      #define MY_RX_MESSAGE_BUFFER_FEATURE
      #define MY_RF24_IRQ_PIN 2
      
      // Enable and select radio type attached
      #define MY_RADIO_RF24
      //#define MY_RADIO_RFM69
      //#define MY_RS485
      
      #include <SPI.h>
      #include <MySensors.h>
      #include <DHT.h>
      #include <Bounce2.h>
      
      // Set this to the pin you connected the DHT's data pin to
      #define DHT_DATA_PIN 4
      
      #define BUTTON_PIN  3  // Arduino Digital I/O pin for button/reed switch
      
      // Set this offset if the sensor has a permanent small offset to the real temperatures.
      // In Celsius degrees (as measured by the device)
      #define SENSOR_TEMP_OFFSET 0
      
      // Sleep time between sensor updates (in milliseconds)
      // Must be >1000ms for DHT22 and >2000ms for DHT11
      static const uint64_t UPDATE_INTERVAL = 60000;
      
      // Force sending an update of the temperature after n sensor reads, so a controller showing the
      // timestamp of the last update doesn't show something like 3 hours in the unlikely case, that
      // the value didn't change since;
      // i.e. the sensor would force sending an update every UPDATE_INTERVAL*FORCE_UPDATE_N_READS [ms]
      static const uint8_t FORCE_UPDATE_N_READS = 10;
      
      #define CHILD_ID 3
      #define CHILD_ID_HUM 0
      #define CHILD_ID_TEMP 1
      
      
      float lastTemp;
      float lastHum;
      uint8_t nNoUpdatesTemp;
      uint8_t nNoUpdatesHum;
      bool metric = true;
      
      MyMessage msgHum(CHILD_ID_HUM, V_HUM);
      MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP);
      DHT dht;
      
      Bounce debouncer = Bounce();
      int oldValue=-1;
      
      // Change to V_LIGHT if you use S_LIGHT in presentation below
      MyMessage msg(CHILD_ID,V_TRIPPED);
      
      
      void presentation()
      {
        // Send the sketch version information to the gateway
        sendSketchInfo("Door/DHT", "1.1");
      
        // Register all sensors to gw (they will be created as child devices)
        present(CHILD_ID_HUM, S_HUM);
        present(CHILD_ID_TEMP, S_TEMP);
      
      	// Register binary input sensor to gw (they will be created as child devices)
      // You can use S_DOOR, S_MOTION or S_LIGHT here depending on your usage.
      // If S_LIGHT is used, remember to update variable type you send in. See "msg" above.
        present(CHILD_ID, S_DOOR);
      
        metric = getControllerConfig().isMetric;
      }
      
      
      void setup()
      {
        dht.setup(DHT_DATA_PIN); // set data pin of DHT sensor
        if (UPDATE_INTERVAL <= dht.getMinimumSamplingPeriod()) {
          Serial.println("Warning: UPDATE_INTERVAL is smaller than supported by the sensor!");
        }
        // Sleep for the time of the minimum sampling period to give the sensor time to power up
        // (otherwise, timeout errors might occure for the first reading)
        sleep(dht.getMinimumSamplingPeriod());
      	// 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);
      }
      
      
      void loop()
      {
        // Force reading sensor, so it works also after sleep()
        dht.readSensor(true);
      
        // Get temperature from DHT library
        float temperature = dht.getTemperature();
        if (isnan(temperature)) {
          Serial.println("Failed reading temperature from DHT!");
        } else if (temperature != lastTemp || nNoUpdatesTemp == FORCE_UPDATE_N_READS) {
          // Only send temperature if it changed since the last measurement or if we didn't send an update for n times
          lastTemp = temperature;
      
          // apply the offset before converting to something different than Celsius degrees
          temperature += SENSOR_TEMP_OFFSET;
      
          if (!metric) {
            temperature = dht.toFahrenheit(temperature);
          }
          // Reset no updates counter
          nNoUpdatesTemp = 0;
          send(msgTemp.set(temperature, 1));
      
          #ifdef MY_DEBUG
          Serial.print("T: ");
          Serial.println(temperature);
          #endif
        } else {
          // Increase no update counter if the temperature stayed the same
          nNoUpdatesTemp++;
        }
      
        // Get humidity from DHT library
        float humidity = dht.getHumidity();
        if (isnan(humidity)) {
          Serial.println("Failed reading humidity from DHT");
        } else if (humidity != lastHum || nNoUpdatesHum == FORCE_UPDATE_N_READS) {
          // Only send humidity if it changed since the last measurement or if we didn't send an update for n times
          lastHum = humidity;
          // Reset no updates counter
          nNoUpdatesHum = 0;
          send(msgHum.set(humidity, 1));
      
          #ifdef MY_DEBUG
          Serial.print("H: ");
          Serial.println(humidity);
          #endif
        } else {
          // Increase no update counter if the humidity stayed the same
          nNoUpdatesHum++;
      
      		debouncer.update();
        // Get the update value
        int value = debouncer.read();
      
        if (value != oldValue) {
           // Send in the new value
           send(msg.set(value==HIGH ? 1 : 0));
           oldValue = value;
        }
      
      
        // Sleep for a while to save energy
        sleep(UPDATE_INTERVAL);
      }}
      
      

      and error snippet

      3534 TSF:MSG:SEND,1-1-0-0,s=2,c=1,t=16,pt=0,l=1,sg=0,ft=0,st=OK:1
      Failed reading temperature from DHT!
      Failed reading humidity from DHT
      3545 MCO:SLP:MS=60000,SMS=0,I1=1,M1=1,I2=255,M2=255
      3553 TSF:TDI:TSL
      3555 MCO:SLP:WUP=1
      3557 TSF:TRI:TSB
      1
      3584 TSF:MSG:SEND,1-1-0-0,s=2,c=1,t=16,pt=0,l=1,sg=0,ft=0,st=OK:1
      Failed reading temperature from DHT!
      Failed reading humidity from DHT
      3592 MCO:SLP:MS=60000,SMS=0,I1=1,M1=1,I2=255,M2=255
      3602 TSF:TDI:TSL
      3604 MCO:SLP:WUP=1
      3606 TSF:TRI:TSB
      
      posted in My Project
      Terence Faul
      Terence Faul
    • DHT and DOOR sensor

      Hi

      Please assist, I am trying to combine the default straight from the examples, but the DHT give an error on compile

      /**
       * The MySensors Arduino library handles the wireless radio link and protocol
       * between your home built sensors/actuators and HA controller of choice.
       * The sensors forms a self healing radio network with optional repeaters. Each
       * repeater and gateway builds a routing tables in EEPROM which keeps track of the
       * network topology allowing messages to be routed to nodes.
       *
       * Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
       * Copyright (C) 2013-2015 Sensnology AB
       * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
       *
       * Documentation: http://www.mysensors.org
       * Support Forum: http://forum.mysensors.org
       *
       * This program is free software; you can redistribute it and/or
       * modify it under the terms of the GNU General Public License
       * version 2 as published by the Free Software Foundation.
       *
       *******************************
       *
       * REVISION HISTORY
       * Version 1.0: Henrik EKblad
       * Version 1.1 - 2016-07-20: Converted to MySensors v2.0 and added various improvements - Torben Woltjen (mozzbozz)
       *
       * DESCRIPTION
       * This sketch provides an example of how to implement a humidity/temperature
       * sensor using a DHT11/DHT-22.
       *
       * For more information, please visit:
       * http://www.mysensors.org/build/humidity
       *
       */
      
      // Enable debug prints
      #define MY_DEBUG
      
      // Enable and select radio type attached
      #define MY_RADIO_RF24
      //#define MY_RADIO_RFM69
      //#define MY_RS485
      
      #include <SPI.h>
      #include <MySensors.h>
      #include <DHT.h>
      #include <Bounce2.h>
      
      // Set this to the pin you connected the DHT's data pin to
      #define DHT_DATA_PIN 3
      
      #define BUTTON_PIN  3  // Arduino Digital I/O pin for button/reed switch
      
      // Set this offset if the sensor has a permanent small offset to the real temperatures.
      // In Celsius degrees (as measured by the device)
      #define SENSOR_TEMP_OFFSET 0
      
      // Sleep time between sensor updates (in milliseconds)
      // Must be >1000ms for DHT22 and >2000ms for DHT11
      static const uint64_t UPDATE_INTERVAL = 60000;
      
      // Force sending an update of the temperature after n sensor reads, so a controller showing the
      // timestamp of the last update doesn't show something like 3 hours in the unlikely case, that
      // the value didn't change since;
      // i.e. the sensor would force sending an update every UPDATE_INTERVAL*FORCE_UPDATE_N_READS [ms]
      static const uint8_t FORCE_UPDATE_N_READS = 10;
      
      #define CHILD_ID 3
      #define CHILD_ID_HUM 0
      #define CHILD_ID_TEMP 1
      
      
      float lastTemp;
      float lastHum;
      uint8_t nNoUpdatesTemp;
      uint8_t nNoUpdatesHum;
      bool metric = true;
      
      MyMessage msgHum(CHILD_ID_HUM, V_HUM);
      MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP);
      DHT dht;
      
      Bounce debouncer = Bounce();
      int oldValue=-1;
      
      // Change to V_LIGHT if you use S_LIGHT in presentation below
      MyMessage msg(CHILD_ID,V_TRIPPED);
      
      
      void presentation()
      {
        // Send the sketch version information to the gateway
        sendSketchInfo("TemperatureAndHumidity", "1.1");
      
        // Register all sensors to gw (they will be created as child devices)
        present(CHILD_ID_HUM, S_HUM);
        present(CHILD_ID_TEMP, S_TEMP);
      
      	// Register binary input sensor to gw (they will be created as child devices)
      // You can use S_DOOR, S_MOTION or S_LIGHT here depending on your usage.
      // If S_LIGHT is used, remember to update variable type you send in. See "msg" above.
        present(CHILD_ID, S_DOOR);
      
        metric = getControllerConfig().isMetric;
      }
      
      
      void setup()
      {
        dht.setup(DHT_DATA_PIN); // set data pin of DHT sensor
        if (UPDATE_INTERVAL <= dht.getMinimumSamplingPeriod()) {
          Serial.println("Warning: UPDATE_INTERVAL is smaller than supported by the sensor!");
        }
        // Sleep for the time of the minimum sampling period to give the sensor time to power up
        // (otherwise, timeout errors might occure for the first reading)
        sleep(dht.getMinimumSamplingPeriod());
      	// 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);
      }
      
      
      void loop()
      {
        // Force reading sensor, so it works also after sleep()
        dht.readSensor(true);
      
        // Get temperature from DHT library
        float temperature = dht.getTemperature();
        if (isnan(temperature)) {
          Serial.println("Failed reading temperature from DHT!");
        } else if (temperature != lastTemp || nNoUpdatesTemp == FORCE_UPDATE_N_READS) {
          // Only send temperature if it changed since the last measurement or if we didn't send an update for n times
          lastTemp = temperature;
      
          // apply the offset before converting to something different than Celsius degrees
          temperature += SENSOR_TEMP_OFFSET;
      
          if (!metric) {
            temperature = dht.toFahrenheit(temperature);
          }
          // Reset no updates counter
          nNoUpdatesTemp = 0;
          send(msgTemp.set(temperature, 1));
      
          #ifdef MY_DEBUG
          Serial.print("T: ");
          Serial.println(temperature);
          #endif
        } else {
          // Increase no update counter if the temperature stayed the same
          nNoUpdatesTemp++;
        }
      
        // Get humidity from DHT library
        float humidity = dht.getHumidity();
        if (isnan(humidity)) {
          Serial.println("Failed reading humidity from DHT");
        } else if (humidity != lastHum || nNoUpdatesHum == FORCE_UPDATE_N_READS) {
          // Only send humidity if it changed since the last measurement or if we didn't send an update for n times
          lastHum = humidity;
          // Reset no updates counter
          nNoUpdatesHum = 0;
          send(msgHum.set(humidity, 1));
      
          #ifdef MY_DEBUG
          Serial.print("H: ");
          Serial.println(humidity);
          #endif
        } else {
          // Increase no update counter if the humidity stayed the same
          nNoUpdatesHum++;
      
      		debouncer.update();
        // Get the update value
        int value = debouncer.read();
      
        if (value != oldValue) {
           // Send in the new value
           send(msg.set(value==HIGH ? 1 : 0));
           oldValue = value;
        }
      
      
        // Sleep for a while to save energy
        sleep(UPDATE_INTERVAL);
      }
      
      

      The error is below

      /Users/terencefaul/Documents/PlatformIO/Projects/Mysensors DHT and Door/src/BinarySwitchSleepSensor.ino.ino: In function 'void loop()':
      /Users/terencefaul/Documents/PlatformIO/Projects/Mysensors DHT and Door/src/BinarySwitchSleepSensor.ino.ino:129:22: error: no matching function for call to 
      'DHT::readSensor(bool)'
      dht.readSensor(true);```
      posted in My Project
      Terence Faul
      Terence Faul
    • Battery reporting

      Hi

      is it possible to implement battery reporting as in

      https://github.com/mysensors/MySensorsArduinoExamples/blob/master/examples/Si7021TemperatureAndHumiditySensor/Si7021TemperatureAndHumiditySensor.ino

      in other sketches so one does not need the resisters as in the battery reporting section

      posted in General Discussion
      Terence Faul
      Terence Faul
    • RE: MQTT Gateway

      That is great thanks

      Last question, will it also function as a normal ethernet gateway. I currently use that with Domoticz

      posted in Hardware
      Terence Faul
      Terence Faul
    • MQTT Gateway

      Hi

      Can anybody tell me the difference between a MQTT Gateway and a Ethenet Gateway?

      Does a MQTT function the same as a ethernet gateway?

      posted in Hardware
      Terence Faul
      Terence Faul
    • Nani/mini shields

      Hi

      Does anyone know of a shield for nano and mini that has a nrf24l01 radio header and terminal blocks.

      I'm looking something on Ali or eBay as opposed to custom

      posted in Hardware
      Terence Faul
      Terence Faul
    • Nano vs uno

      Screen Shot 2015-12-19 at 13.46.46.png Screen Shot 2015-12-19 at 13.39.07.png

      Please help. I have been working with the relay sketch and uploaded to the nano and had no problem. That is the first image.

      Then uploaded to the uno and could not get it to work. The second image is the serial output.

      Domotiz detects the sensor perfect on the nano, but not the uno. Am I missing something

      posted in Troubleshooting
      Terence Faul
      Terence Faul
    • Monitor a irrigation status

      Hi

      I have a hunter irrigation controller. I was thinking of building a binaryswitch as per the example with four switches to monitor the status of the valves. ie on/off.

      The valves operate on 24v would this be posible without damaging the promini

      posted in My Project
      Terence Faul
      Terence Faul
    • Distance sensor with Display

      Would it be possible to attach a display to the distance sensor, to show the distance for example in the garage as the car approaches

      posted in Hardware
      Terence Faul
      Terence Faul
    • RE: IR Sketch

      Sending is possible from the controller, I have tested it, It is just the loop that is the problem

      posted in Hardware
      Terence Faul
      Terence Faul
    • IR Sketch

      Hi

      I am using the IR sketch and trying to send IR commands.

      I have the device added in jeedom, and then after capturing the IR code making it send the code.
      It seems to be sending the code, however the sensor seems to get into a loop and send the same code over and over. I suspect that it may have something to do with the if statement in the stretch. Below is the sketch and the output from the serial monitor

      // Example sketch showing how to control ir devices
      // An IR LED must be connected to Arduino PWM pin 3.
      // An optional ir receiver can be connected to PWM pin 8. 
      // All receied ir signals will be sent to gateway device stored in VAR_1.
      // When binary light on is clicked - sketch will send volume up ir command
      // When binary light off is clicked - sketch will send volume down ir command
      
      #include <MySensor.h>
      #include <SPI.h>
      #include <IRLib.h>
      
      int RECV_PIN = 8;
      
      #define CHILD_1  3  // childId
      
      IRsend irsend;
      IRrecv irrecv(RECV_PIN);
      IRdecode decoder;
      //decode_results results;
      unsigned int Buffer[RAWBUF];
      MySensor gw;
      MyMessage msg(CHILD_1, V_VAR1);
      
      void setup()  
      {  
        irrecv.enableIRIn(); // Start the ir receiver
        decoder.UseExtnBuf(Buffer);
        gw.begin(incomingMessage);
      
        // Send the sketch version information to the gateway and Controller
        gw.sendSketchInfo("IR Sensor", "1.0");
      
        // Register a sensors to gw. Use binary light for test purposes.
        gw.present(CHILD_1, S_LIGHT);
      }
      
      
      void loop() 
      {
        gw.process();
        if (irrecv.GetResults(&decoder)) {
          irrecv.resume(); 
          decoder.decode();
          decoder.DumpResults();
              
          char buffer[10];
          sprintf(buffer, "%08lx", decoder.value);
          // Send ir result to gw
          gw.send(msg.set(buffer));
        }
      }
      
      
      
      void incomingMessage(const MyMessage &message) {
        // We only expect one type of message from controller. But we better check anyway.
        if (message.type==V_LIGHT) {
           int incomingRelayStatus = message.getInt();
           if (incomingRelayStatus == 1) {
            irsend.send(NEC, 0000000000, 32); // Vol up yamaha ysp-900
           } else {
            irsend.send(NEC, 0000000000, 32); // Vol down yamaha ysp-900
           }
           // Start receiving ir again...
          irrecv.enableIRIn(); 
        }
      }
          
      // Dumps out the decode_results structure.
      // Call this after IRrecv::decode()
      // void * to work around compiler issue
      //void dump(void *v) {
      //  decode_results *results = (decode_results *)v
      /*void dump(decode_results *results) {
        int count = results->rawlen;
        if (results->decode_type == UNKNOWN) {
          Serial.print("Unknown encoding: ");
        } 
        else if (results->decode_type == NEC) {
          Serial.print("Decoded NEC: ");
        } 
        else if (results->decode_type == SONY) {
          Serial.print("Decoded SONY: ");
        } 
        else if (results->decode_type == RC5) {
          Serial.print("Decoded RC5: ");
        } 
        else if (results->decode_type == RC6) {
          Serial.print("Decoded RC6: ");
        }
        else if (results->decode_type == PANASONIC) {	
          Serial.print("Decoded PANASONIC - Address: ");
          Serial.print(results->panasonicAddress,HEX);
          Serial.print(" Value: ");
        }
        else if (results->decode_type == JVC) {
           Serial.print("Decoded JVC: ");
        }
        Serial.print(results->value, HEX);
        Serial.print(" (");
        Serial.print(results->bits, DEC);
        Serial.println(" bits)");
        Serial.print("Raw (");
        Serial.print(count, DEC);
        Serial.print("): ");
      
        for (int i = 0; i < count; i++) {
          if ((i % 2) == 1) {
            Serial.print(results->rawbuf[i]*USECPERTICK, DEC);
          } 
          else {
            Serial.print(-(int)results->rawbuf[i]*USECPERTICK, DEC);
          }
          Serial.print(" ");
        }
        Serial.println("");
      }
      */
      
      end: 60-60-0-0 s=3,c=1,t=2,pt=0,l=10,st=ok:0x77e13adc
      read: 0-1-60 s=3,c=1,t=2,pt=0,l=10:0x77e13adc
      send: 60-60-0-0 s=3,c=1,t=2,pt=0,l=10,st=ok:0x77e13adc
      read: 0-1-60 s=3,c=1,t=2,pt=0,l=10:0x77e13adc
      send: 60-60-0-0 s=3,c=1,t=2,pt=0,l=10,st=ok:0x77e13adc
      read: 0-1-60 s=3,c=1,t=2,pt=0,l=10:0x77e13adc
      send: 60-60-0-0 s=3,c=1,t=2,pt=0,l=10,st=ok:0x77e13adc
      read: 0-1-60 s=3,c=1,t=2,pt=0,l=10:0x77e13adc
      send: 60-60-0-0 s=3,c=1,t=2,pt=0,l=10,st=ok:0x77e13adc
      read: 0-1-60 s=3,c=1,t=2,pt=0,l=10:0x77e13adc
      send: 60-60-0-0 s=3,c=1,t=2,pt=0,l=10,st=ok:0x77e13adc
      read: 0-1-60 s=3,c=1,t=2,pt=0,l=10:0x77e13adc
      send: 60-60-0-0 s=3,c=1,t=2,pt=0,l=10,st=ok:0x77e13adc
      read: 0-1-60 s=3,c=1,t=2,pt=0,l=10:0x77e13adc
      send: 60-60-0-0 s=3,c=1,t=2,pt=0,l=10,st=ok:0x77e13adc
      read: 0-1-60 s=3,c=1,t=2,pt=0,l=10:0x77e13adc
      send: 60-60-0-0 s=3,c=1,t=2,pt=0,l=10,st=ok:0x77e13adc
      read: 0-1-60 s=3,c=1,t=2,pt=0,l=10:0x77e13adc
      send: 60-60-0-0 s=3,c=1,t=2,pt=0,l=10,st=ok:0x77e13adc
      read: 0-1-60 s=3,c=1,t=2,pt=0,l=10:0x77e13adc
      send: 60-60-0-0 s=3,c=1,t=2,pt=0,l=10,st=ok:0x77e13adc
      read: 0-1-60 s=3,c=1,t=2,pt=0,l=10:0x77e13adc
      send: 60-60-0-0 s=3,c=1,t=2,pt=0,l=10,st=ok:0x77e13adc
      read: 0-1-60 s=3,c=1,t=2,pt=0,l=10:0x77e13adc
      send: 60-60-0-0 s=3,c=1,t=2,pt=0,l=10,st=ok:0x77e13adc
      read: 0-1-60 s=3,c=1,t=2,pt=0,l=10:0x77e13adc
      send: 60-60-0-0 s=3,c=1,t=2,pt=0,l=10,st=ok:0x77e13adc
      read: 0-1-60 s=3,c=1,t=2,pt=0,l=10:0x77e13adc
      send: 60-60-0-0 s=3,c=1,t=2,pt=0,l=10,st=ok:0x77e13adc
      read: 0-1-60 s=3,c=1,t=2,pt=0,l=10:0x77e13adc
      send: 60-60-0-0 s=3,c=1,t=2,pt=0,l=10,st=ok:0x77e13adc
      read: 0-1-60 s=3,c=1,t=2,pt=0,l=10:0x77e13adc
      send: 60-60-0-0 s=3,c=1,t=2,pt=0,l=10,st=ok:0x77e13adc
      read: 0-1-60 s=3,c=1,t=2,pt=0,l=10:0x77e13adc
      send: 60-60-0-0 s=3,c=1,t=2,pt=0,l=10,st=ok:0x77e13adc
      read: 0-1-60 s=3,c=1,t=2,pt=0,l=10:0x77e13adc
      send: 60-60-0-0 s=3,c=1,t=2,pt=0,l=10,st=ok:0x77e13adc
      read: 0-1-60 s=3,c=1,t=2,pt=0,l=10:0x77e13adc
      send: 60-60-0-0 s=3,c=1,t=2,pt=0,l=10,st=ok:0x77e13adc
      read: 0-1-60 s=3,c=1,t=2,pt=0,l=10:0x77e13adc
      send: 60-60-0-0 s=3,c=1,t=2,pt=0,l=10,st=ok:0x77e13adc
      read: 0-1-60 s=3,c=1,t=2,pt=0,l=10:0x77e13adc
      send: 60-60-0-0 s=3,c=1,t=2,pt=0,l=10,st=ok:0x77e13adc
      read: 0-1-60 s=3,c=1,t=2,pt=0,l=10:0x77e13adc
      send: 60-60-0-0 s=3,c=1,t=2,pt=0,l=10,st=ok:0x77e13adc
      read: 0-1-60 s=3,c=1,t=2,pt=0,l=10:0x77e13adc
      send: 60-60-0-0 s=3,c=1,t=2,pt=0,l=10,st=ok:0x77e13adc
      read: 0-1-60 s=3,c=1,t=2,pt=0,l=10:0x77e13adc
      send: 60-60-0-0 s=3,c=1,t=2,pt=0,l=10,st=ok:0x77e13adc
      read: 0-1-60 s=3,c=1,t=2,pt=0,l=10:0x77e13adc
      send: 60-60-0-0 s=3,c=1,t=2,pt=0,l=10,st=ok:0x77e13adc
      read: 0-1-60 s=3,c=1,t=2,pt=0,l=10:0x77e13adc
      send: 60-60-0-0 s=3,c=1,t=2,pt=0,l=10,st=ok:0x77e13adc
      read: 0-1-60 s=3,c=1,t=2,pt=0,l=10:0x77e13adc
      send: 60-60-0-0 s=3,c=1,t=2,pt=0,l=10,st=ok:0x77e13adc
      read: 0-1-60 s=3,c=1,t=2,pt=0,l=10:0x77e13adc
      send: 60-60-0-0 s=3,c=1,t=2,pt=0,l=10,st=ok:0x77e13adc
      read: 0-1-60 s=3,c=1,t=2,pt=0,l=10:0x77e13adc
      send: 60-60-0-0 s=3,c=1,t=2,pt=0,l=10,st=ok:0x77e13adc
      read: 0-1-60 s=3,c=1,t=2,pt=0,l=10:0x77e13adc
      send: 60-60-0-0 s=3,c=1,t=2,pt=0,l=10,st=ok:0x77e13adc
      read: 0-1-60 s=3,c=1,t=2,pt=0,l=10:0x77e13adc
      send: 60-60-0-0 s=3,c=1,t=2,pt=0,l=10,st=ok:0x77e13adc
      read: 0-1-60 s=3,c=1,t=2,pt=0,l=10:0x77e13adc
      send: 60-60-0-0 s=3,c=1,t=2,pt=0,l=10,st=ok:0x77e13adc
      read: 0-1-60 s=3,c=1,t=2,pt=0,l=10:0x77e13adc
      send: 60-60-0-0 s=3,c=1,t=2,pt=0,l=10,st=ok:0x77e13adc
      read: 0-1-60 s=3,c=1,t=2,pt=0,l=10:0x77e13adc
      send: 60-60-0-0 s=3,c=1,t=2,pt=0,l=10,st=ok:0x77e13adc
      read: 0-1-60 s=3,c=1,t=2,pt=0,l=10:0x77e13adc
      send: 60-60-0-0 s=3,c=1,t=2,pt=0,l=10,st=ok:0x77e13adc
      read: 0-1-60 s=3,c=1,t=2,pt=0,l=10:0x77e13adc
      send: 60-60-0-0 s=3,c=1,t=2,pt=0,l=10,st=ok:0x77e13adc
      read: 0-1-60 s=3,c=1,t=2,pt=0,l=10:0x77e13adc
      send: 60-60-0-0 s=3,c=1,t=2,pt=0,l=10,st=ok:0x77e13adc
      read: 0-1-60 s=3,c=1,t=2,pt=0,l=10:0x77e13adc
      send: 60-60-0-0 s=3,c=1,t=2,pt=0,l=10,st=ok:0x77e13adc
      read: 0-1-60 s=3,c=1,t=2,pt=0,l=10:0x77e13adc
      send: 60-60-0-0 s=3,c=1,t=2,pt=0,l=10,st=ok:0x77e13adc
      read: 0-1-60 s=3,c=1,t=2,pt=0,l=10:0x77e13adc
      send: 60-60-0-0 s=3,c=1,t=2,pt=0,l=10,st=ok:0x77e13adc
      read: 0-1-60 s=3,c=1,t=2,pt=0,l=10:0x77e13adc
      send: 60-60-0-0 s=3,c=1,t=2,pt=0,l=10,st=ok:0x77e13adc
      read: 0-1-60 s=3,c=1,t=2,pt=0,l=10:0x77e13adc
      send: 60-60-0-0 s=3,c=1,t=2,pt=0,l=10,st=ok:0x77e13adc
      read: 0-1-60 s=3,c=1,t=2,pt=0,l=10:0x77e13adc
      send: 60-60-0-0 s=3,c=1,t=2,pt=0,l=10,st=ok:0x77e13adc
      read: 0-1-60 s=3,c=1,t=2,pt=0,l=10:0x77e13adc
      send: 60-60-0-0 s=3,c=1,t=2,pt=0,l=10,st=ok:0x77e13adc
      read: 0-1-60 s=3,c=1,t=2,pt=0,l=10:0x77e13adc
      send: 60-60-0-0 s=3,c=1,t=2,pt=0,l=10,st=ok:0x77e13adc
      read: 0-1-60 s=3,c=1,t=2,pt=0,l=10:0x77e13adc
      send: 60-60-0-0 s=3,c=1,t=2,pt=0,l=10,st=ok:0x77e13adc
      read: 0-1-60 s=3,c=1,t=2,pt=0,l=10:0x77e13adc
      send: 60-60-0-0 s=3,c=1,t=2,pt=0,l=10,st=ok:0x77e13adc
      read: 0-1-60 s=3,c=1,t=2,pt=0,l=10:0x77e13adc
      

      Can anybody shed some light

      posted in Hardware
      Terence Faul
      Terence Faul
    • RE: RF433MHZ sensor

      I am not sure, I bought some relays from Ebay.

      If I use the MySensors 433RF Sketch, the receiver recognises the remotes.

      /*
       * This sketch demonstrates how to use InterruptChain to receive and
       * decode remote switches (old and new) and remote sensors.
       *
       * Basically, this sketch combines the features of the ShowReceivedCode
       * and ShowReceivedCodeNewKaku examples of RemoteSwitch and the
       * ThermoHygroReceiver of RemoteSensor all at the same time!
       *
       * After uploading, enable the serial monitor at 115200 baud.
       * When you press buttons on a 433MHz remote control, as supported by 
       * RemoteSwitch or NewRemoteSwitch, the code will be echoed.
       * At the same time, if data of a remote thermo/hygro-sensor is
       * received, as supported by RemoteSensor, it will be echoed as well.
       *
       * Setup:
       * - connect a 433MHz receiver on digital pin 2.
       *
       *
       * MySensor note: This example has not yet been adopted but can be used as an example
       * of receiving 433Mhz stuff. 
       * 
       * One idea could be to echo received 433 codes back to gateway to be able to pick up and
       * handle data over there.
       *
       */
      
      #include <RemoteReceiver.h>
      #include <NewRemoteReceiver.h>
      #include <SensorReceiver.h>
      #include <InterruptChain.h>
      
      void setup() {
        Serial.begin(115200);
      
        // Interrupt -1 to indicate you will call the interrupt handler with InterruptChain
        RemoteReceiver::init(-1, 2, showOldCode);
        
        // Again, interrupt -1 to indicate you will call the interrupt handler with InterruptChain
        NewRemoteReceiver::init(-1, 2, showNewCode);
      
        // And once more, interrupt -1 to indicate you will call the interrupt handler with InterruptChain
        SensorReceiver::init(-1, showTempHumi);
      
        // On interrupt, call the interrupt handlers of remote and sensor receivers
        InterruptChain::addInterruptCallback(0, RemoteReceiver::interruptHandler);
        InterruptChain::addInterruptCallback(0, NewRemoteReceiver::interruptHandler);
        InterruptChain::addInterruptCallback(0, SensorReceiver::interruptHandler);
      }
      
      void loop() {
         // You can do other stuff here!
      }
      
      // shows the received code sent from an old-style remote switch
      void showOldCode(unsigned long receivedCode, unsigned int period) {
        // Print the received code.
        Serial.print("Code: ");
        Serial.print(receivedCode);
        Serial.print(", period: ");
        Serial.print(period);
        Serial.println("us.");
      }
      
      // Shows the received code sent from an new-style remote switch
      void showNewCode(NewRemoteCode receivedCode) {
        // Print the received code.
        Serial.print("Addr ");
        Serial.print(receivedCode.address);
        
        if (receivedCode.groupBit) {
          Serial.print(" group");
        } else {
          Serial.print(" unit ");
          Serial.print(receivedCode.unit);
        }
        
        switch (receivedCode.switchType) {
          case NewRemoteCode::off:
            Serial.print(" off");
            break;
          case NewRemoteCode::on:
            Serial.print(" on");
            break;
          case NewRemoteCode::dim:
            Serial.print(" dim level ");
            Serial.print(receivedCode.dimLevel);
            break;
          case NewRemoteCode::on_with_dim:
            Serial.print(" on with dim level ");
            Serial.print(receivedCode.dimLevel);
            break;
        }
        
        Serial.print(", period: ");
        Serial.print(receivedCode.period);
        Serial.println("us.");
      }
      
      // Shows the received sensor data
      void showTempHumi(byte *data) {
        // is data a ThermoHygro-device?
        if ((data[3] & 0x1f) == 0x1e) {
          // Yes!
          byte channel, randomId;
          int temp;
          byte humidity;
      
          // Decode the data
          SensorReceiver::decodeThermoHygro(data, channel, randomId, temp, humidity);
        
          // Print temperature. Note: temp is 10x the actual temperature!
          Serial.print("Temperature: ");
          Serial.print(temp / 10); // units
          Serial.print('.');
          Serial.println(temp % 10); // decimal
        }
      }
      
      posted in Hardware
      Terence Faul
      Terence Faul
    • RE: RF433MHZ sensor

      does it need a specific library?
      Are codes held in the controller or the sketch?

      on compile I get

      sketch_feb24a:13: error: 'HomeEasyEUSwitch' does not name a type
      sketch_feb24a.ino: In function 'void incomingMessage(const MyMessage&)':
      sketch_feb24a:56: error: 'homeeasySwitch' was not declared in this scope

      posted in Hardware
      Terence Faul
      Terence Faul
    • RE: RF 433 MHz sensor to control RF sockets.

      Did you ever get this working?

      What pins did you attache the transmitter to and what pin did you attach the receiver to?

      Is that the latest code?

      posted in Hardware
      Terence Faul
      Terence Faul
    • RF433MHZ sensor

      Hi I found this sketch in the MySensors library, if does great to sniff 433 codes, can anybody assist in having it create devices that are able to transmit a 433 code to allow control of these devices?

      /*
       * This sketch demonstrates how to use InterruptChain to receive and
       * decode remote switches (old and new) and remote sensors.
       *
       * Basically, this sketch combines the features of the ShowReceivedCode
       * and ShowReceivedCodeNewKaku examples of RemoteSwitch and the
       * ThermoHygroReceiver of RemoteSensor all at the same time!
       *
       * After uploading, enable the serial monitor at 115200 baud.
       * When you press buttons on a 433MHz remote control, as supported by 
       * RemoteSwitch or NewRemoteSwitch, the code will be echoed.
       * At the same time, if data of a remote thermo/hygro-sensor is
       * received, as supported by RemoteSensor, it will be echoed as well.
       *
       * Setup:
       * - connect a 433MHz receiver on digital pin 2.
       *
       *
       * MySensor note: This example has not yet been adopted but can be used as an example
       * of receiving 433Mhz stuff. 
       * 
       * One idea could be to echo received 433 codes back to gateway to be able to pick up and
       * handle data over there.
       *
       */
      
      #include <RemoteReceiver.h>
      #include <NewRemoteReceiver.h>
      #include <SensorReceiver.h>
      #include <InterruptChain.h>
      
      void setup() {
        Serial.begin(115200);
      
        // Interrupt -1 to indicate you will call the interrupt handler with InterruptChain
        RemoteReceiver::init(-1, 2, showOldCode);
        
        // Again, interrupt -1 to indicate you will call the interrupt handler with InterruptChain
        NewRemoteReceiver::init(-1, 2, showNewCode);
      
        // And once more, interrupt -1 to indicate you will call the interrupt handler with InterruptChain
        SensorReceiver::init(-1, showTempHumi);
      
        // On interrupt, call the interrupt handlers of remote and sensor receivers
        InterruptChain::addInterruptCallback(0, RemoteReceiver::interruptHandler);
        InterruptChain::addInterruptCallback(0, NewRemoteReceiver::interruptHandler);
        InterruptChain::addInterruptCallback(0, SensorReceiver::interruptHandler);
      }
      
      void loop() {
         // You can do other stuff here!
      }
      
      // shows the received code sent from an old-style remote switch
      void showOldCode(unsigned long receivedCode, unsigned int period) {
        // Print the received code.
        Serial.print("Code: ");
        Serial.print(receivedCode);
        Serial.print(", period: ");
        Serial.print(period);
        Serial.println("us.");
      }
      
      // Shows the received code sent from an new-style remote switch
      void showNewCode(NewRemoteCode receivedCode) {
        // Print the received code.
        Serial.print("Addr ");
        Serial.print(receivedCode.address);
        
        if (receivedCode.groupBit) {
          Serial.print(" group");
        } else {
          Serial.print(" unit ");
          Serial.print(receivedCode.unit);
        }
        
        switch (receivedCode.switchType) {
          case NewRemoteCode::off:
            Serial.print(" off");
            break;
          case NewRemoteCode::on:
            Serial.print(" on");
            break;
          case NewRemoteCode::dim:
            Serial.print(" dim level ");
            Serial.print(receivedCode.dimLevel);
            break;
          case NewRemoteCode::on_with_dim:
            Serial.print(" on with dim level ");
            Serial.print(receivedCode.dimLevel);
            break;
        }
        
        Serial.print(", period: ");
        Serial.print(receivedCode.period);
        Serial.println("us.");
      }
      
      // Shows the received sensor data
      void showTempHumi(byte *data) {
        // is data a ThermoHygro-device?
        if ((data[3] & 0x1f) == 0x1e) {
          // Yes!
          byte channel, randomId;
          int temp;
          byte humidity;
      
          // Decode the data
          SensorReceiver::decodeThermoHygro(data, channel, randomId, temp, humidity);
        
          // Print temperature. Note: temp is 10x the actual temperature!
          Serial.print("Temperature: ");
          Serial.print(temp / 10); // units
          Serial.print('.');
          Serial.println(temp % 10); // decimal
        }
      }
      

      Regards

      posted in Hardware
      Terence Faul
      Terence Faul
    • RE: Multi Button Relay switch

      Thanks a stack, it is slow.

      If I did want to restore the relay state how would I change the code?

      At the moment if I leave that code in when the arduino boots it cycles each relay on and then off, instead of just restoring the previous state

      posted in Hardware
      Terence Faul
      Terence Faul
    • RE: Multi Button Relay switch

      Bulldog

      So this is as far as I got.

      Managed to get the relays to start in the off position by Changing LOW for the defined RELAY_OFF.

      Commented out the EEPROM Section and now when the sensor reboots is starts with all relays in off position.

      I do not know how to change the EEPROM section I am sur I need to maybe include the RELAY_OFF somewhere in that line.

      #include <MySensor.h>
      #include <SPI.h>
      #include <Bounce2.h>
      
      #define RELAY_ON 0  //switch around for realy HIGH/LOW state
      #define RELAY_OFF 1
      
      //
      MySensor gw;
      const int relayPin[] = {7, 8, A0, A1};
      const int buttonPin[sizeof(relayPin) / sizeof(relayPin[0])] = {3, 4, 5, 6};
      byte oldValue[sizeof(relayPin) / sizeof(relayPin[0])];
      boolean relayState[sizeof(relayPin) / sizeof(relayPin[0])];
      
      Bounce debouncer[sizeof(relayPin) / sizeof(relayPin[0])];
      
      MyMessage msg[sizeof(relayPin) / sizeof(relayPin[0])];//(sensor,type);
      
      void setup()  
      {  
        Serial.begin(115200);
        gw.begin(incomingMessage, AUTO, false);
        //
        // or you can try:
        // gw.begin(incomingMessage, <Your_Node_ID>, false); // where Your_Node_ID is a number from 1 to 254
        //
        delay(250);
        gw.sendSketchInfo("MultiRelayButton", "0.9b");// <<<<<<<<<<<<<<<<<<< I forgot this, here
        //
        delay(250);
        for (int i = 0; i < sizeof(relayPin) / sizeof(relayPin[0]); i++)
        {
          msg[i].sensor = i;
          msg[i].type = V_LIGHT;
          debouncer[i] = Bounce();
          debouncer[i].attach(buttonPin[i]);
          debouncer[i].interval(5);
          pinMode(buttonPin[i], INPUT_PULLUP);
          digitalWrite(relayPin[i], RELAY_OFF); //Start State of Relays
          pinMode(relayPin[i], OUTPUT);
          gw.present(i, S_LIGHT); // <<<<<<<<<<<<<<<<<<<<<<< I fixed this too...
          delay(250);
        }
        //retreive from EEPROM last states
      //  for (int i = 0; i < sizeof(relayPin) / sizeof(relayPin[0]); i++)//>>>>>>> I'm sure that this is causing all relays to turn on and off at startup
      //  {
      //    relayState[i] = gw.loadState(i);
      //    digitalWrite(relayPin[i], relayState[i]? RELAY_ON:RELAY_OFF);
      //    gw.send(msg[i].set(relayState[i]? true : false), true);
      //    delay(250);
      //  }
      //  
      }
      //
      void loop() 
      {
        gw.process();
        for (byte i = 0; i < sizeof(relayPin) / sizeof(relayPin[0]); i++)
        {
          debouncer[i].update();
          byte value = debouncer[i].read();
          if (value != oldValue[i] && value == 0)
          {
            relayState[i] = !relayState[i];
            digitalWrite(relayPin[i], relayState[i]);
            gw.send(msg[i].set(relayState[i]? true : false), true);
          }
          oldValue[i] = value;
        }
      }
      //
      void incomingMessage(const MyMessage &message)
      {
        if (message.isAck()) 
        {
          Serial.println(F("This is an ack from gateway"));
        }
        for (byte i = 0; i< sizeof(relayPin) / sizeof(relayPin[0]); i++)
        {
          if (message.sensor == i)
          {
            if (message.type == V_LIGHT)
            {
              relayState[i] = message.getBool();
              digitalWrite(relayPin[i], relayState[i]? RELAY_ON : RELAY_OFF); 
              gw.saveState(relayPin[i], relayState[i]);
            }
          }
        }
      }
      
      posted in Hardware
      Terence Faul
      Terence Faul
    • RE: Multi Button Relay switch

      @Terence-Faul
      Only one other thing.

      I notice that when the sensor starts up, each of the relays turn on and then off.

      This ia all good and well, however i assume in practice this would mean what ever is connected to them will turn on and off as well in the initialisation phase.

      Also I assume that retrieve from EEPROM means that if the sensor loses power while a relay is on, when it powers up this relay will return to the on state?

      Can you point me to to code that controls this, if these are lights and the power goes out a better option may be to have the relays all start in the off position so that the lights do not come on in the middle of the night

      Is this correct?

      posted in Hardware
      Terence Faul
      Terence Faul
    • RE: Multi Button Relay switch

      @BulldogLowell

      This new one had the relays correct, but the buttons did not work. I compared the old with the new and below now works.

      Thanks again a million for all the help

      #include <MySensor.h>
      #include <SPI.h>
      #include <Bounce2.h>
      
      #define RELAY_ON 0
      #define RELAY_OFF 1
      
      //
      MySensor gw;
      const int relayPin[] = {7, 8, A0, A1};
      const int buttonPin[sizeof(relayPin) / sizeof(relayPin[0])] = {3, 4, 5, 6};
      byte oldValue[sizeof(relayPin) / sizeof(relayPin[0])];
      boolean relayState[sizeof(relayPin) / sizeof(relayPin[0])];
      
      Bounce debouncer[sizeof(relayPin) / sizeof(relayPin[0])];
      
      MyMessage msg[sizeof(relayPin) / sizeof(relayPin[0])];//(sensor,type);
      
      void setup()  
      {  
        Serial.begin(115200);
        gw.begin(incomingMessage, AUTO, false);
        //
        // or you can try:
        // gw.begin(incomingMessage, <Your_Node_ID>, false); // where Your_Node_ID is a number from 1 to 254
        //
        delay(250);
        gw.sendSketchInfo("MultiRelayButton", "0.9b");// <<<<<<<<<<<<<<<<<<< I forgot this, here
        //
        delay(250);
        for (int i = 0; i < sizeof(relayPin) / sizeof(relayPin[0]); i++)
        {
          msg[i].sensor = i;
          msg[i].type = V_LIGHT;
          debouncer[i] = Bounce();
          debouncer[i].attach(buttonPin[i]);
          debouncer[i].interval(5);
          pinMode(buttonPin[i], INPUT_PULLUP);
          digitalWrite(relayPin[i], LOW);
          pinMode(relayPin[i], OUTPUT);
          gw.present(i, S_LIGHT); // <<<<<<<<<<<<<<<<<<<<<<< I fixed this too...
          delay(250);
        }
        //retreive from EEPROM last states
        for (int i = 0; i < sizeof(relayPin) / sizeof(relayPin[0]); i++)
        {
          relayState[i] = gw.loadState(i);
          digitalWrite(relayPin[i], relayState[i]? RELAY_ON : RELAY_OFF);
          gw.send(msg[i].set(relayState[i]? true : false), true);
          delay(250);
        }
      }
      //
      void loop() 
      {
        gw.process();
        for (byte i = 0; i < sizeof(relayPin) / sizeof(relayPin[0]); i++)
        {
          debouncer[i].update();
          byte value = debouncer[i].read();
          if (value != oldValue[i] && value == 0)
          {
            relayState[i] = !relayState[i];
            digitalWrite(relayPin[i], relayState[i]);
            gw.send(msg[i].set(relayState[i]? true : false), true);
          }
          oldValue[i] = value;
        }
      }
      //
      void incomingMessage(const MyMessage &message)
      {
        if (message.isAck()) 
        {
          Serial.println(F("This is an ack from gateway"));
        }
        for (byte i = 0; i< sizeof(relayPin) / sizeof(relayPin[0]); i++)
        {
          if (message.sensor == i)
          {
            if (message.type == V_LIGHT)
            {
              relayState[i] = message.getBool();
              digitalWrite(relayPin[i], relayState[i]? RELAY_ON : RELAY_OFF); 
              gw.saveState(relayPin[i], relayState[i]);
            }
          }
        }
      }
      
      posted in Hardware
      Terence Faul
      Terence Faul
    • RE: IR Sensor

      Jeedom on Raspberry Pi

      Using Serial gateway

      posted in Hardware
      Terence Faul
      Terence Faul
    • RE: Multi Button Relay switch
        // Example sketch för a "light switch" where you can control light or something 
        // else from both vera and a local physical button (connected between digital
        // pin 3 and GND).
        // This node also works as a repeader for other nodes
        
        #include <MySensor.h>
        #include <SPI.h>
        #include <Bounce2.h>
        
        #define RELAY_PIN  4  // Arduino Digital I/O pin number for relay 
        #define BUTTON_PIN  3  // Arduino Digital I/O pin number for button 
        #define CHILD_ID 1   // Id of the sensor child
        #define RELAY_ON 1
        #define RELAY_OFF 0
        
        Bounce debouncer = Bounce(); 
        int oldValue=0;
        bool state;
        MySensor gw;
        MyMessage msg(CHILD_ID,V_LIGHT);
        
        void setup()  
        {  
          gw.begin(incomingMessage, AUTO, true);
        
          // Send the sketch version information to the gateway and Controller
          gw.sendSketchInfo("Relay & Button", "1.0");
        
         // 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);
        
          // Register all sensors to gw (they will be created as child devices)
          gw.present(CHILD_ID, S_LIGHT);
        
          // Make sure relays are off when starting up
          digitalWrite(RELAY_PIN, RELAY_OFF);
          // Then set relay pins in output mode
          pinMode(RELAY_PIN, OUTPUT);   
              
          // Set relay to last known state (using eeprom storage) 
          state = gw.loadState(CHILD_ID);
          digitalWrite(RELAY_PIN, state?RELAY_ON:RELAY_OFF);
        }
        
        
        /*
        *  Example on how to asynchronously check for new messages from gw
        */
        void loop() 
        {
          gw.process();
          debouncer.update();
          // Get the update value
          int value = debouncer.read();
          if (value != oldValue && value==0) {
              gw.send(msg.set(state?false:true), true); // Send new state and request ack back
          }
          oldValue = value;
        } 
         
        void incomingMessage(const MyMessage &message) {
          // We only expect one type of message from controller. But we better check anyway.
          if (message.isAck()) {
             Serial.println("This is an ack from gateway");
          }
        
          if (message.type == V_LIGHT) {
             // Change relay state
             state = message.getBool();
             digitalWrite(RELAY_PIN, state?RELAY_ON:RELAY_OFF);
             // Store state in eeprom
             gw.saveState(CHILD_ID, state);
            
             // Write some debug info
             Serial.print("Incoming change for sensor:");
             Serial.print(message.sensor);
             Serial.print(", New status: ");
             Serial.println(message.getBool());
           } 
        }
      
      
      posted in Hardware
      Terence Faul
      Terence Faul
    • IR Sensor

      Hi

      Is it possible to add buttons to this sensor, the example only does Volume up/down, but would you be able to add all the buttons of your settop box for instance.

      If so how would you go about altering the sketch, or is this something for the controller?

      posted in Hardware
      Terence Faul
      Terence Faul
    • FTDI Programer board

      Does anybody have any experience with this chip?

      I have installed drivers for it. (Not sure if they are the correct drivers) but arduino software does pickup the port.

      http://www.tinyosshop.com/index.php?route=product/product&path=74_126&product_id=600

      When I try and upload a sketch I get a programer not responding error

      Using Arduino 1.6 on Mac OS X yosemite

      posted in Hardware
      Terence Faul
      Terence Faul
    • RE: Multi Button Relay switch

      hek

      Do you have an example sketch, I am a newby and would not have any idea how to alter the sketch to include buttons and move the relay pins

      posted in Hardware
      Terence Faul
      Terence Faul
    • Multi Button Relay switch

      Hi

      Is is possible to attached 4 relays to a node and also control each with a button?

      posted in Hardware
      Terence Faul
      Terence Faul
    • Pro Mini Adjustable

      Has anyone used one of these?

      http://www.ebay.com/itm/Pro-Mini-Enhancement-3-3V-or-5V-adjustable-16MHz-MEGA328P-Arduino-compatible-/230795578198?pt=LH_DefaultDomain_0&hash=item35bc7d0b56

      posted in Hardware
      Terence Faul
      Terence Faul
    • UNO3 with ATMEGA8A-PU

      Hi

      I have an above clone and was trying to upload the sketch for the relay module.
      In the compiling it tells me that I need to

      Please ensure chosen MCU is either 328P, 32U4 or 2560

      Is it not possible to use that chip?

      posted in Hardware
      Terence Faul
      Terence Faul
    • MySensors Controller

      Hi

      Has anyone tried the MySensors controller?
      Is it available in a Pi image that can simply be flashed to the card?

      Regards

      posted in Controllers
      Terence Faul
      Terence Faul
    • RE: Dimable Light relays

      Hek

      Thanks for the reply, I take it there is currently no Sketch for this module just yet?
      Also is it not possible to use the existing physical switch and in wall dimmer along with som clever code and a replay module?

      posted in Hardware
      Terence Faul
      Terence Faul
    • Dimable Light relays

      Hi

      Switching a light on and off can be easily achieved by the relay build.

      What about being able to dim a light?
      Is it posible to use the same build with the existing in wall dimmer?
      What about down lights and Led lights?

      Regards

      posted in Hardware
      Terence Faul
      Terence Faul
    • RE: 433Mhz devices

      Hek

      Does your team have any intention of creating the code in the sensors and gateways to support 433mhz?

      I think developing it myself may be out of my league and I am not familiar with code.

      Regards

      posted in Hardware
      Terence Faul
      Terence Faul
    • 433Mhz devices

      Is it possible to a 433mhz transmitter and receiver to communicate with my existing 433mhz devices? Do you have a tutorial on how to do this?
      When do you think your range of sensors will be on the market?
      If you want to turn any sensor into a repeater do you need to add some code to the sketch or does the code exist in each sketch already?

      posted in Hardware
      Terence Faul
      Terence Faul