Navigation

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

    Terence Faul

    @Terence Faul

    3
    Reputation
    48
    Posts
    986
    Profile views
    0
    Followers
    0
    Following
    Joined Last Online

    Terence Faul Follow

    Best posts made by 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
    • 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: 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

    Latest 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