Navigation

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

    Posts made by Chakkie

    • RE: NRF24l01+ vs. NRF24l01+ pa + lna

      @meju25

      Unfortunately I have the exact same problem with the amplified version. I have two of them and tried all the mentioned solutions (power, shielding etc) on both modules but none of them work. On the contrary the amplifier version works much worst then the normal version. So I have just given up on this module and put some of the normal NRF as repeater.

      May be as one has mentioned, the Chinese module does not work properly. However the normal NRF module are all from China.

      posted in Troubleshooting
      Chakkie
      Chakkie
    • RE: Adjust / change total energy (kwh) and water (liter) value of the controller or GW

      @mfalkvidd Thanks

      The idea of changing the pulseCount is correct. However I had set the value at the wrong place without realizing the pulseCount is reset at the Void setup() section.

       // Water Reset pulsecount
        pulseCountW = oldPulseCountW = 0;
      
        // Zonnepanelen Reset pulsecount
        pulseCountZ = oldPulseCountZ = 0;
      

      The solution is

      Change the 0 to : Value (meter) - Value (Controller)

      Upload the sketch. wait until the first pulse is sent to the gateway.

      If successed the controller (domoticz in my case) will show the total value matching the value on the physical meter.

      Now change the value in the sketch back to 0. (Otherwise each time you reset the sensor or the gateway the value wil be added to the total value.) Upload the sketch to the sensor.

      You are done. There is no need to Modify the Domoticz database with SQL tool.

      You will get the value you've just added to the total value in the day value log. If you find this ignoring you can delete this value the next day. This only applies to Energy meter. Do not apply this to the water meter as the result the total value of the water meter will be gone too.

      posted in General Discussion
      Chakkie
      Chakkie
    • Adjust / change total energy (kwh) and water (liter) value of the controller or GW

      I use the following script to log my energy and water meter. I have tried to change the total value to match the actual value on my energy & water meter by changing the pulseCount.

      Does anyone if this is possibleow to do it and h. Thanks

      ![alt text](0_1464972474986_upload-9c76a914-cceb-49b6-bc74-cbe6cf6d008e image url)

      /**
       * based on the pulsecounter sketches form www.mysensors.org
       * changed for S0 ports and working without interrupts which
       * make ghost pulsecounts disappear with the use of S0 ports
       *
       * Combined and changed by Mediacj september/okt/nov 2015
       *
       */
      
      #include <SPI.h>
      #include <MySensor.h>
      
      //water
      #define DIGITAL_INPUT_SENSORW 3  // The digital input for the S0 bus wire
      #define PULSE_FACTORW 1000       // Nummber of rotations per m3 of your meter
      #define CHILD_IDW 10             // Id of the sensor child
      
      //zonnepanelen
      #define DIGITAL_INPUT_SENSORZ 5  // The digital input for the S0 bus wire
      #define PULSE_FACTORZ 1000       // Nummber of blinks per KWH of your meter
      #define MAX_WATT 10000            // Max watt value to report. This filetrs outliers.
      #define CHILD_IDZ 11             // Id of the sensor child
      
      MySensor gw;
      //Water
      double ppwhW = ((double)PULSE_FACTORW) / 1000; // Pulses per watt hour
      boolean pcReceivedW = false;
      volatile unsigned long pulseCountW = 0;
      volatile double volume = 0;
      unsigned long oldPulseCountW = 0;
      double oldVolume;
      unsigned long lastSendW;
      unsigned long nulw;//tijd sinds de laatste 0 waarde
      
      //Zonnepanelen
      double ppwhZ = ((double)PULSE_FACTORZ) / 1000; // Pulses per watt hour
      boolean pcReceivedZ = false;
      volatile unsigned long pulseCountZ = 0;
      unsigned long oldPulseCountZ = 0;
      volatile unsigned long watt = 0;
      unsigned long oldWatt = 0;
      double kwh;
      double oldKwh = 0;
      unsigned long lastSendZ;
      unsigned long nulz;//tijd sinds de laatste 0 waarde
      
      //Water
      MyMessage volumeMsg(CHILD_IDW, V_VOLUME);
      MyMessage pcMsgw(CHILD_IDW, V_VAR1);
      volatile unsigned long pulseLengthW = 0;
      volatile unsigned long lastMillisW = 0;
      boolean timeReceivedW = false;
      boolean sensorIsOnW = false;
      
      //Zonnepanelen
      MyMessage wattMsg(CHILD_IDZ, V_WATT);
      MyMessage kwhMsg(CHILD_IDZ, V_KWH);
      MyMessage pcMsgz(CHILD_IDZ, V_VAR2);
      volatile unsigned long pulseLengthZ = 0;
      volatile unsigned long lastMillisZ = 0;
      boolean timeReceivedZ = false;
      boolean sensorIsOnZ = false;
      int tellerkwh = 0;
      
      void setup()
      {
        gw.begin(incomingMessage);
      
        // Send the sketch version information to the gateway and Controller
        gw.sendSketchInfo("Water en Energie Meter", "10.0");
        delay(1000);
      
        // Register this device as watersensor
        gw.present(CHILD_IDW, S_WATER);
        // Register this device as power sensor
        delay(1000);
        gw.present(CHILD_IDZ, S_POWER);
      
        // Water Reset pulsecount
        pulseCountW = oldPulseCountW = 0;
      
        // Zonnepanelen Reset pulsecount
        pulseCountZ = oldPulseCountZ = 0;
      
        pinMode(DIGITAL_INPUT_SENSORW, INPUT_PULLUP);       // Enable internal pull-up resistor on pin 3
        pinMode(DIGITAL_INPUT_SENSORZ, INPUT_PULLUP);       // Enable internal pull-up resistor on pin 5
        lastSendW = millis();
        lastSendZ = millis();
      
        // Fetch last known pulses value from gw
        gw.request(CHILD_IDW, V_VAR1);
        gw.request(CHILD_IDZ, V_VAR2);
      
      }
      
      
      void loop()
      {
        gw.process();
        unsigned long now = millis();
      
        //Zonnepanelen#############################
        // read the digital input
        bool solarInput = digitalRead(DIGITAL_INPUT_SENSORZ);
        // rising edge?
        if(solarInput && sensorIsOnZ == false)
        {
          sensorIsOnZ = true;
        }
        // falling edge?
        if(!solarInput && sensorIsOnZ == true)
        {
          pulseLengthZ = micros() - lastMillisZ;
          //store the time for the next pulse
          lastMillisZ = micros();
          // update counters and send to gateway
          pulseCountZ++;
      
          //Last Pulsecount not yet received from controller, request it again
          if (!pcReceivedZ)
          {
            gw.request(CHILD_IDZ, V_VAR2);
            return;
          }
          gw.send(pcMsgz.set(pulseCountZ)); // Send zppulsecount value to gw in VAR2
          watt = (((3600000000.0 / pulseLengthZ) / ppwhZ)); //was 1.0118 personal multiply factor not necessary (1.0115)
          if(watt != oldWatt && watt < ((unsigned long)MAX_WATT))
          {
            Serial.println(watt);
            gw.send(wattMsg.set(watt));
          }; // Send watt value to gw
          oldWatt = watt;
          lastSendZ = now;
          sensorIsOnZ = false;
          tellerkwh++;
          if (tellerkwh == 2)
          {
            double kwh = ((double)pulseCountZ / ((double)PULSE_FACTORZ)); //was 1.0118 personal multiply factor not necessary
            oldKwh = kwh;
            tellerkwh  = 0;
            Serial.println(kwh);
            gw.send(kwhMsg.set(kwh, 4));// Send kwh value to gw. 4 mean 4 digits before the comma
          };
        }
      
      
        // Watermeter###########################
        // read the digital input
        bool waterInput = digitalRead(DIGITAL_INPUT_SENSORW);
        // rising edge?
        if(waterInput && sensorIsOnW == false)
        {
          sensorIsOnW = true;
        }
        // falling edge?
        if(!waterInput && sensorIsOnW == true)
        {
          //controle
          if ((micros() - lastMillisW) < 3000000L)
          {
            return;   //Sometimes we get interrupt on RISING, = 3 sek debounce
          }
          // store the time between the last two pulses
          pulseLengthW = micros() - lastMillisW;
          //store the time for the next pulse
          lastMillisW = micros();
          // update counters
          pulseCountW++;
          //Last Pulsecount not yet received from controller, request it again
          if (!pcReceivedW)
          {
            gw.request(CHILD_IDW, V_VAR1);
            return;
          }
          gw.send(pcMsgw.set(pulseCountW)); // Send waterpulsecount value to gw in VAR2
          sensorIsOnW = false;
          double volume = ((double)pulseCountW / ((double)PULSE_FACTORW));
          oldPulseCountW = pulseCountW;
          Serial.println(volume);
          gw.send(volumeMsg.set(volume, 3));  // Send volume value to gw. 3 mean 3 digits before the comma
          oldVolume = volume;
          lastSendW = now;
        }
      
        //Water na 10 minuten geen pulse laatste waarde herhalen
      //  if ((now - lastSendW) > 600000)
      //  {
      //    gw.send(volumeMsg.set(oldVolume, 3));
      //    
      //    lastSendW = now;
      //    nulw = millis();
      //  }
      //
      //  //Zonnepanelen na 12 minuten geen pulse 0 waarde sturen
      //  if ((now - lastSendZ) > 720000)
      //  {
      //    watt = 0;
      //    gw.send(wattMsg.set(watt));
      //    lastSendZ = now;
      //    nulz = millis();
      //    gw.send(kwhMsg.set(oldKwh, 4));
      //  }
      }
      
      void incomingMessage(const MyMessage &message)
      {
        if (message.type == V_VAR1)
        {
          unsigned long gwPulseCountW = message.getULong();
          pulseCountW += gwPulseCountW;
          volume = oldVolume = 0;
          Serial.print("Received last water pulse count from gw:");
          Serial.println(pulseCountW);
          pcReceivedW = true;
        }
      
        if (message.type == V_VAR2)
        {
          unsigned long gwPulseCountZ = message.getULong();
          pulseCountZ += gwPulseCountZ;
          kwh = oldKwh = 0;
          Serial.print("Received last zon pulse count from gw:");
          Serial.println(pulseCountZ);
          pcReceivedZ = true;
        }
      }
      
      posted in General Discussion
      Chakkie
      Chakkie
    • RE: Buzzer when door opened longer than X seconds

      @Boots33 Thanks for the help. The main problem was how to set the time when the doors are opened. I have tried several attempts and everytime the timer is reset. Therefore the buzzer will never be triggered because the timer and the current time is always the same.

      I have solved this problem. The working script is here below:

      
      #include <MySensor.h>
      #include <SPI.h>
      #include <Bounce2.h>
      
      #define CHILD_ID_Koel 31
      #define CHILD_ID_Vries 32
      #define BUTTON_PIN_Koel  7  // Arduino Digital I/O pin for button/reed switch
      #define BUTTON_PIN_Vries  8  // Arduino Digital I/O pin for button/reed switch
      #define INTERRUPT BUTTON_PIN_Koel -2 // Usually the interrupt = pin -2 (on uno/nano anyway)
      #define INTERRUPT BUTTON_PIN_Vries -2 // Usually the interrupt = pin -2 (on uno/nano anyway)
      #define buzzPin 2 // I/O-pin from buzzer connects here
      
      unsigned long currentMillisKoel;
      unsigned long currentMillisVries;
      
      MySensor gw;
      Bounce debouncerKoel = Bounce();
      Bounce debouncerVries = Bounce();
      int oldValueKoel = -1;
      int oldValueVries = -1;
      int KoelBuzz = 0;
      int VriesBuzz = 0;
      
      unsigned long DoorDelay = 5000UL;
      unsigned long KoelTimer = 0UL;
      unsigned long VriesTimer = 0UL;
      
      MyMessage msgKoel(CHILD_ID_Koel, V_TRIPPED);
      MyMessage msgVries(CHILD_ID_Vries, V_TRIPPED);
      
      void setup()
      {
        gw.begin(NULL, 204, false, 0);
      
        // Setup the button
        pinMode(BUTTON_PIN_Koel, INPUT);
        pinMode(BUTTON_PIN_Vries, INPUT);
      
        //Buzz pin
        pinMode(buzzPin, OUTPUT);
        digitalWrite(buzzPin, HIGH);
      
        // Activate internal pull-up
        digitalWrite(BUTTON_PIN_Koel, HIGH);
        digitalWrite(BUTTON_PIN_Vries, HIGH);
        // After setting up the button, setup debouncer
        debouncerKoel.attach(BUTTON_PIN_Koel);
        debouncerVries.attach(BUTTON_PIN_Vries);
        debouncerKoel.interval(5);
        debouncerVries.interval(5);
      
        // 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.
        gw.present(CHILD_ID_Koel, S_DOOR);
        gw.present(CHILD_ID_Vries, S_DOOR);
      }
      
      
      //  Check if digital input has changed and send in new value
      void loop()
      {
      
        // Fridge door script
        debouncerKoel.update();
        // Get the update value
        int valueKoel = debouncerKoel.read();
      
        if (valueKoel != oldValueKoel) {
          // Send in the new value
          gw.send(msgKoel.set(valueKoel == HIGH ? 0 : 1)); // change this value to if NC then 0 : 1; if NO then 1 : 0
          oldValueKoel = valueKoel;
          KoelBuzz = digitalRead(BUTTON_PIN_Koel);
          Serial.println(KoelBuzz);
          if (KoelBuzz == LOW) { //Door is open.
            KoelTimer = millis(); //  Set the time. 
            Serial.println(KoelTimer);
          }
        }
      
        // check how long the doors are opened
        unsigned long currentMillisKoel = millis();
        if ((currentMillisKoel - KoelTimer) >= DoorDelay && KoelBuzz == LOW) {
      //    Serial.println("Counter start");
      //    Serial.println(KoelTimer);
      //    Serial.println(currentMillisKoel);
          digitalWrite(buzzPin, KoelBuzz); // Tone ON
      //    Serial.println("Buzzer triggerd");
      
        }
      
      
      // Freezer door script
        debouncerVries.update();
        // Get the update value
        int valueVries = debouncerVries.read();
      
      
        if (valueVries != oldValueVries) {
          // Send in the new value
          gw.send(msgVries.set(valueVries == HIGH ? 0 : 1)); // change this value to if NC then 0 : 1; if NO then 1 : 0
          oldValueVries = valueVries;
          VriesBuzz = digitalRead(BUTTON_PIN_Vries);
          Serial.println(VriesBuzz);
          if (VriesBuzz == LOW) { //Door is open.
            VriesTimer = millis(); //  Set the time. 
            Serial.println(VriesTimer);
          }
        }
        if (VriesBuzz && KoelBuzz == HIGH) {
          digitalWrite(buzzPin, VriesBuzz); // Tone OFF
        }
        
        // check how long the doors are opened
        unsigned long currentMillisVries = millis();
        if ((currentMillisVries - VriesTimer) >= DoorDelay && VriesBuzz == LOW) {
      //    Serial.println("Counter start");
      //    Serial.println(VriesTimer);
      //    Serial.println(currentMillisVries);
          digitalWrite(buzzPin, VriesBuzz); // Tone ON
      //    Serial.println("Buzzer triggerd");
      
        }
      
      // Sleep until interrupt comes in on motion sensor. Send update every two minute.
      //  gw.sleep(INTERRUPT,CHANGE, SLEEP_TIME);
      //  Serial.println("sleep");
      }
      
      posted in General Discussion
      Chakkie
      Chakkie
    • Buzzer when door opened longer than X seconds

      Hi All,

      I have got the buzzer module today and I want to use it on my exist frigde door contact sensor. What I want to do is when one of the fridge door is open more than 30 seconds the buzzer will turn on. And when door is closed the buzz stops.

      The full code is here below:

      
      #include <MySensor.h>
      #include <SPI.h>
      #include <Bounce2.h>
      
      #define CHILD_ID_Koel 31
      #define CHILD_ID_Vries 32
      #define BUTTON_PIN_Koel  7  // Arduino Digital I/O pin for button/reed switch
      #define BUTTON_PIN_Vries  8  // Arduino Digital I/O pin for button/reed switch
      #define INTERRUPT BUTTON_PIN_Koel -2 // Usually the interrupt = pin -2 (on uno/nano anyway)
      #define INTERRUPT BUTTON_PIN_Vries -2 // Usually the interrupt = pin -2 (on uno/nano anyway)
      #define buzzPin 2 // I/O-pin from buzzer connects here
      
      unsigned long currentMillis = millis();
      
      MySensor gw;
      Bounce debouncerKoel = Bounce();
      Bounce debouncerVries = Bounce();
      int oldValueKoel = -1;
      int oldValueVries = -1;
      int buzz = 0;
      
      unsigned long DoorDelay = 30000;
      unsigned long DoorMillis;
      
      MyMessage msgKoel(CHILD_ID_Koel, V_TRIPPED);
      MyMessage msgVries(CHILD_ID_Vries, V_TRIPPED);
      
      void setup()
      {
        gw.begin(NULL, 204, false, 0);
      
        // Setup the button
        pinMode(BUTTON_PIN_Koel, INPUT);
        pinMode(BUTTON_PIN_Vries, INPUT);
      
        //Buzz pin
        pinMode(buzzPin, OUTPUT);
        digitalWrite(buzzPin, HIGH);
      
        // Activate internal pull-up
        digitalWrite(BUTTON_PIN_Koel, HIGH);
        digitalWrite(BUTTON_PIN_Vries, HIGH);
        // After setting up the button, setup debouncer
        debouncerKoel.attach(BUTTON_PIN_Koel);
        debouncerVries.attach(BUTTON_PIN_Vries);
        debouncerKoel.interval(5);
        debouncerVries.interval(5);
      
        // 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.
        gw.present(CHILD_ID_Koel, S_DOOR);
        gw.present(CHILD_ID_Vries, S_DOOR);
      }
      
      
      //  Check if digital input has changed and send in new value
      void loop()
      {
        debouncerKoel.update();
        // Get the update value
        int valueKoel = debouncerKoel.read();
      
        if (valueKoel != oldValueKoel) {
          // Send in the new value
          gw.send(msgKoel.set(valueKoel == HIGH ? 0 : 1)); // change this value to if NC then 0 : 1; if NO then 1 : 0
          oldValueKoel = valueKoel;
      
        }
      
      
      
        debouncerVries.update();
        // Get the update value
        int valueVries = debouncerVries.read();
      
        if (valueVries != oldValueVries) {
          // Send in the new value
          gw.send(msgVries.set(valueVries == HIGH ? 0 : 1)); // change this value to if NC then 0 : 1; if NO then 1 : 0
          oldValueVries = valueVries;
          buzz = digitalRead(BUTTON_PIN_Vries);
          Serial.println(buzz);
      
          if (buzz == HIGH) {
            digitalWrite(buzzPin, buzz); // Tone OFF
            Serial.println("Buzzer off");
          }
          if (buzz == LOW) {
            DoorMillis = millis();
            Serial.println("Counter start");
            Serial.println(DoorMillis);
          }
      
          if ((millis() - DoorMillis) > DoorDelay) {
            digitalWrite(buzzPin, buzz); // Tone ON
            Serial.println("Buzzer triggerd");
      
          }
      
        }
      
        // Sleep until interrupt comes in on motion sensor. Send update every two minute.
        //  gw.sleep(INTERRUPT,CHANGE, SLEEP_TIME);
        //  Serial.println("sleep");
      }
      

      Below is part of the code where I tired to get the code work. I think I am doing something wrong.

      debouncerVries.update();
        // Get the update value
        int valueVries = debouncerVries.read();
      
        if (valueVries != oldValueVries) {
          // Send in the new value
          gw.send(msgVries.set(valueVries == HIGH ? 0 : 1)); // change this value to if NC then 0 : 1; if NO then 1 : 0
          oldValueVries = valueVries;
          buzz = digitalRead(BUTTON_PIN_Vries);
          Serial.println(buzz);
      
          if (buzz == HIGH) {
            digitalWrite(buzzPin, buzz); // Tone OFF
            Serial.println("Buzzer off");
          }
          if (buzz == LOW) {
            DoorMillis = millis();
            Serial.println("Counter start");
            Serial.println(DoorMillis);
          }
      
          if ((millis() - DoorMillis) > DoorDelay) {
            digitalWrite(buzzPin, buzz); // Tone ON
            Serial.println("Buzzer triggerd");
      
          }
      

      Does anyone know how the code should look like

      Thanks

      posted in General Discussion
      Chakkie
      Chakkie
    • RE: gw.sleep on battery powered magnet door switch

      @AWI

      Thanks for the info. I thought you always have to add the sleep time to the gw.sleep. I will disable the a wake timer by removing the 86400000.

      @siod I use one switch for the letterbox and one for the door.

      posted in My Project
      Chakkie
      Chakkie
    • RE: Motion Sensor triggering on its own

      I have the same issue first when I tried to power the PIR with the VCC from the arduino mini pro 3.3V. It seems like the PIR does not work with 3.3V. Now I power the PIR directly from the 9V battery. Problem solved.

      posted in Troubleshooting
      Chakkie
      Chakkie
    • RE: gw.sleep on battery powered magnet door switch

      @AWI thanks. this looks like more promising.

      posted in My Project
      Chakkie
      Chakkie
    • RE: gw.sleep on battery powered magnet door switch

      @AWI Thanks this clear thinks up but at the same time also confusing too.

      So "-2" activates both 0 and 1 on pin 2 or pin 3 as you mentioned earlier. I always though it represents a pin number.

      posted in My Project
      Chakkie
      Chakkie
    • RE: gw.sleep on battery powered magnet door switch

      @mfalkvidd Thanks for the info. Does DigitalPinTolnterrupt works better?

      posted in My Project
      Chakkie
      Chakkie
    • RE: gw.sleep on battery powered magnet door switch

      @AWI Thanks. By the way would you care to explain the interrupt index number? or may be a link for explanation?

      posted in My Project
      Chakkie
      Chakkie
    • RE: Magnetic Door Switch with Buzzer

      @knipex Hi can you please post your working script?? I want the same functionality too. Thanks

      posted in Troubleshooting
      Chakkie
      Chakkie
    • RE: gw.sleep on battery powered magnet door switch

      @AWI Thank you so much. Yes I have came to the conclusion that the debouncer does not seems to work fine with sleep function. So I have used a method other than debouncer.

      Here the working script below:

      #include <MySensor.h>
      #include <SPI.h>
      
      
      #define CHILD_ID_Deur 11
      #define CHILD_ID_Post 12
      #define BUTTON_PIN_Deur  2  // Arduino Digital I/O pin for button/reed switch
      #define BUTTON_PIN_Post  3  // Arduino Digital I/O pin for button/reed switch
      
      MySensor gw;
      
      
      // Change to V_LIGHT if you use S_LIGHT in presentation below
      MyMessage msgDeur(CHILD_ID_Deur,V_TRIPPED);
      MyMessage msgPost(CHILD_ID_Post,V_TRIPPED);
      
      void setup()  
      {  
        gw.begin();
      gw.sendSketchInfo("Voordeur contacts", "1.0");
       // Setup the button
        pinMode(BUTTON_PIN_Deur,INPUT);
        pinMode(BUTTON_PIN_Post,INPUT);
        // Activate internal pull-up
        digitalWrite(BUTTON_PIN_Deur,HIGH);
        digitalWrite(BUTTON_PIN_Post,HIGH);
      
        // 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.
        gw.present(CHILD_ID_Deur, S_DOOR);
        gw.present(CHILD_ID_Post, S_DOOR);   
      }
      
      
      //  Check if digital input has changed and send in new value
      void loop() 
      {
        uint8_t value;
        static uint8_t sentValue = 2;
        static uint8_t sentValue2 = 2;
      
        // Short delay to allow buttons to properly settle
        gw.sleep(5);
      
        value = digitalRead(BUTTON_PIN_Deur);
      
        if (value != sentValue) {
          // Value has changed from last transmission, send the updated value
          gw.send(msgDeur.set(value == HIGH ? 1 : 0));
          sentValue = value;
        }
      
        value = digitalRead(BUTTON_PIN_Post);
      
        if (value != sentValue2) {
          // Value has changed from last transmission, send the updated value
          gw.send(msgPost.set(value == HIGH ? 1 : 0));
          sentValue2 = value;
        }
      
      
        // Sleep until something happens with the sensor
        gw.sleep(BUTTON_PIN_Deur - 2, CHANGE, BUTTON_PIN_Post - 2, CHANGE, 86400000);// changing Secondary button to correct pin (-3) does not work. So keep it on (-2)
        Serial.println("Sleep");
      
      }
      
      

      Notice that the script does not work properly when I set BUTTON_PIN_Post - 3. The button pin post will not trigger. But when I change it to -2, both switches will work

      gw.sleep(BUTTON_PIN_Deur - 2, CHANGE, BUTTON_PIN_Post - 2, CHANGE, 86400000);
      
      posted in My Project
      Chakkie
      Chakkie
    • RE: gw.sleep on battery powered magnet door switch

      @sundberg84 I have debugged a several times. I am now sure it is not a hardware failure.

      posted in My Project
      Chakkie
      Chakkie
    • RE: gw.sleep on battery powered magnet door switch

      @mfalkvidd Hi thanks

      Changing the sleep time to 0 does not help. When I open and close the contact the status will not be sent. That's weird

      posted in My Project
      Chakkie
      Chakkie
    • RE: gw.sleep on battery powered magnet door switch

      @sundberg84

      I have added some print to debugged. It seems like the code with sleep does not verify and send the high 1 or low 0 when I open and close the contact. See the serial debug log. The repeated sleep in the log is when i open and close the contact. Normally it will send 1 or 0 " send: 204-204-0-0 s=3,c=1,t=16,pt=2,l=2,sg=0,st=ok:0"

      void loop() 
      {
        debouncer.update();
        // Get the update value
        int value = debouncer.read();
      
        if (value != oldValue) {
           // Send in the new value
           Serial.println("Trigger");
           gw.send(msg.set(value==HIGH ? 1 : 0));
           oldValue = value;
        }     
        gw.sleep(INTERRUPT,CHANGE, SLEEP_TIME);
        Serial.println("Sleep");
      
      send: 204-204-0-0 s=255,c=3,t=15,pt=2,l=2,sg=0,st=ok:0
      send: 204-204-0-0 s=255,c=0,t=17,pt=0,l=5,sg=0,st=ok:1.5.4
      send: 204-204-0-0 s=255,c=3,t=6,pt=1,l=1,sg=0,st=ok:0
      read: 0-0-204 s=255,c=3,t=6,pt=0,l=1,sg=0:M
      sensor started, id=204, parent=0, distance=1
      send: 204-204-0-0 s=3,c=0,t=0,pt=0,l=0,sg=0,st=ok:
      Trigger
      send: 204-204-0-0 s=3,c=1,t=16,pt=2,l=2,sg=0,st=ok:0
      Sleep
      Sleep
      Sleep
      Sleep
      Sleep
      Sleep
      Sleep
      Sleep
      
      posted in My Project
      Chakkie
      Chakkie
    • gw.sleep on battery powered magnet door switch

      Hi all,

      I have made a magnet door contact using a Arduino mini Pro 3v3 powered with 2 coin cells battery. To save battery life, I want to use gw.sleep to let the Arduino mini to sleep and trigger when the door is open.

      Unfortunately, the arduino is not trigger when contact is open or closed due to gw.sleep. I was wonder how to use the sleep comment and still making the debounce action works. I have tried to use INTERRUPT but with no luck.

      Thanks

      /**
       * 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.
       *
       *******************************
       *
       * DESCRIPTION
       *
       * Simple binary switch example 
       * Connect button or door/window reed switch between 
       * digitial I/O pin 3 (BUTTON_PIN below) and GND.
       * http://www.mysensors.org/build/binary
       */
      
      
      #include <MySensor.h>
      #include <SPI.h>
      #include <Bounce2.h>
      
      #define CHILD_ID 3
      #define BUTTON_PIN  3  // Arduino Digital I/O pin for button/reed switch
      #define INTERRUPT BUTTON_PIN -2 // Usually the interrupt = pin -2 (on uno/nano anyway)
      unsigned long SLEEP_TIME = 120000; // Sleep time between reports (in milliseconds)
      
      MySensor gw;
      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 setup()  
      {  
        gw.begin();
      
       // 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 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.
        gw.present(CHILD_ID, S_DOOR);  
      }
      
      
      //  Check if digital input has changed and send in new value
      void loop() 
      {
        debouncer.update();
        // Get the update value
        int value = debouncer.read();
       
        if (value != oldValue) {
           // Send in the new value
           gw.send(msg.set(value==HIGH ? 1 : 0));
           oldValue = value;
        }
       
        gw.sleep(INTERRUPT,CHANGE, SLEEP_TIME);
        
        
      } 
      
      
      posted in My Project
      Chakkie
      Chakkie
    • RE: RFID Garage door opener

      @BartE

      I've just solved the issue regarding tags lost after power off.

      Simply add the line "StoreEeprom();" after the program mode function

        if (programmode && ((timer % (ONE_SEC / HEARTBEAT)) == 0 ))  {
                  ledon = !ledon;
                  digitalWrite(LED_PIN, ledon);
                  programTimer++;
      
                  // Stop program mode after 20 sec inactivity
                  if (programTimer > PROG_WAIT)  {
                     programmode = false;
                     digitalWrite(LED_PIN, false);
                     Serial.println(F("Program expired"));  
      
                     storeEeprom();
                     Serial.println(F("Store Card to EEPROM"));  ```
      posted in My Project
      Chakkie
      Chakkie
    • RE: RFID Garage door opener

      @BartE

      Hi BartE, I have the same issue regarding tags lost after power off. I run the debug instruction using Serial print as you mentioned. I found out that the storeEeprom line did not run after closing the program mode. I think this is why the tags are lost after power cycle.

      send: 210-210-0-0 s=255,c=3,t=15,pt=2,l=2,sg=0,st=ok:0
      send: 210-210-0-0 s=255,c=0,t=17,pt=0,l=5,sg=0,st=ok:1.5.4
      send: 210-210-0-0 s=255,c=3,t=6,pt=1,l=1,sg=0,st=ok:0
      read: 0-0-210 s=255,c=3,t=6,pt=0,l=1,sg=0:M
      sensor started, id=210, parent=0, distance=1
      send: 210-210-0-0 s=255,c=3,t=11,pt=0,l=9,sg=0,st=ok:RFID Lock
      send: 210-210-0-0 s=255,c=3,t=12,pt=0,l=3,sg=0,st=ok:1.1
      send: 210-210-0-0 s=2,c=0,t=19,pt=0,l=0,sg=0,st=ok:
      send: 210-210-0-0 s=1,c=0,t=1,pt=0,l=0,sg=0,st=ok:
      RecallEeprom
      MFRC522 Software Version: 0x92 = v2.0
      send: 210-210-0-0 s=1,c=1,t=15,pt=2,l=2,sg=0,st=ok:1
      Init done...
      Switch 1
      Card UID: 26 13 80 41
      Invalid card
      send: 210-210-0-0 s=1,c=1,t=16,pt=2,l=2,sg=0,st=ok:1
      send: 210-210-0-0 s=1,c=1,t=16,pt=2,l=2,sg=0,st=ok:0
      release
      Card UID: xx xx xx xx
      Program mode
      release
      Card UID: xx xx xx xx
      new card
      release
      Program expired
      

      Thanks

      posted in My Project
      Chakkie
      Chakkie
    • RE: RGB LED strip amplifier gives inverted RGB value

      Hi TheoL,

      I have changed the value from 0 to 255 as shown below and now the LED strip turn off when I click the off button in domoticz.

      Now the dimming part has yet to be solved 🙂

      ![alt text](0_1459697790250_upload-deea4aa9-4d91-4afa-af88-b87a342aed1e image url)

      Was

       if (message.type == V_LIGHT) {
          if (message.getInt() == 0) {
            digitalWrite(RED_PIN, 255);
            digitalWrite(GREEN_PIN, 255);
            digitalWrite(BLUE_PIN, 255);```
      posted in Domoticz
      Chakkie
      Chakkie
    • RE: RGB LED strip amplifier gives inverted RGB value

      @TheoL

      Hi TheoL, When I turn off the RGB, the ArduinoIDE serial Monitor gives a sg=0:0. See image below. And as you mentioned. I don't see the V_Light respond. See image.

      ![alt text](0_1459696736731_upload-84afe10a-7f2a-475e-bafb-fe84a4dc7049 0_1459696705265_upload-4c5475c9-23db-4517-8c2c-aae77d081a57 image url)

      ![alt text](0_1459696766153_upload-743804b2-8e2f-4d66-992d-12f433216cfa image url)

      ![alt text](0_1459696825659_upload-3ed10e3f-4f2e-4b21-84ee-c4d3cb6cdd21 image url)

      posted in Domoticz
      Chakkie
      Chakkie
    • RE: RGB LED strip amplifier gives inverted RGB value

      @TheoL

      Thank you so much TheoL. With your help I have added the 254 value as you told me. Once uploaded I can see that the color is closer to color I picked. So I have changed 254 to 255 and yes I 've got the right color. Now comes the next problem. I can no longer dim or turn off the led strip. When ever I choose the white ffffff or black 000000. The led stays at it full brightness. I guess we are close but only a little more tweak.

      Thanks you so much

      posted in Domoticz
      Chakkie
      Chakkie
    • RGB LED strip amplifier gives inverted RGB value

      Hi all

      Insteads of using three Mosfet, I have connected my RGB led strip with my arduino using a RGB mini amplifier (see below). Since it is smaller and you don't have to solder any wires. I am able to control the led strip in Domoticz but the only problem is the RGB value is inverted. So when you choose blue in the colorpicker the led turns yellow. When you dim the light to 10% it is at its full brightness and when you set the level to 100% it turns off. (So the values are inverts). I have tested with a single dimmable led strip and it gave me the same result. It looks like that this module works as an inverted Mosfet.

      alt text

      Anyway I was wondering if you can solve this problem by modifying the script I am using. Like may be inverting the value.

      This is the script I am using

      #include <MySensor.h>
      #include <SPI.h>
      
      #define RED_PIN 3
      #define GREEN_PIN 5
      #define BLUE_PIN 6
      
      #define NODE_ID 70
      #define CHILD_ID 0
      #define SKETCH_NAME "RGB_STRIP "
      #define SKETCH_VERSION "1.0.0"
      #define NODE_REPEAT false
      
      MySensor gw;
      
      long RGB_values[3] = {0, 0, 0};
      float dimmer;
      
      void setup() {
      
      
        pinMode(RED_PIN, OUTPUT);
        pinMode(GREEN_PIN, OUTPUT);
        pinMode(BLUE_PIN, OUTPUT);
      
        gw.begin(incomingMessage, NODE_ID, NODE_REPEAT, 0);
        gw.sendSketchInfo(SKETCH_NAME, SKETCH_VERSION);
        gw.present(CHILD_ID, S_RGB_LIGHT, "RGB Strip", false);
        gw.request(CHILD_ID, V_RGB);
      }
      
      void loop() {
        gw.process();
      }
      
      void incomingMessage(const MyMessage &message) {
      
        if (message.type == V_RGB) {
      
          String hexstring = message.getString();
          long number = (long) strtol( &hexstring[0], NULL, 16);
          RGB_values[0] = number >> 16;
          RGB_values[1] = number >> 8 & 0xFF;
          RGB_values[2] = number & 0xFF;
        }
        if (message.type == V_DIMMER) {
          dimmer = message.getInt();
          analogWrite(RED_PIN, int(RGB_values[0] * (dimmer / 100)));
          analogWrite(GREEN_PIN, int(RGB_values[1] * (dimmer / 100)));
          analogWrite(BLUE_PIN, int(RGB_values[2] * (dimmer / 100)));
        }
      
        if (message.type == V_LIGHT) {
          if (message.getInt() == 0) {
            digitalWrite(RED_PIN, 0);
            digitalWrite(GREEN_PIN, 0);
            digitalWrite(BLUE_PIN, 0);
      
          }
          if (message.getInt() == 1) {
            analogWrite(RED_PIN, int(RGB_values[0] * (dimmer / 100)));
            analogWrite(GREEN_PIN, int(RGB_values[1] * (dimmer / 100)));
            analogWrite(BLUE_PIN, int(RGB_values[2] * (dimmer / 100)));
          }
        }
      }
      

      Thanks

      posted in Domoticz
      Chakkie
      Chakkie
    • RE: District Heating / City Heating (Stadsverwarming) Mysensor IR sender/Receiver

      @tbowmo

      Wowww I did not know that this is a very nice info. I will definitely tried using a couple of magnets. Thank you so much for this info. Any the website you provides is pretty solide too. I've been looking on the internet for while and did not come across a hack like this one before.

      I am a step further thanks

      posted in Domoticz
      Chakkie
      Chakkie
    • RE: District Heating / City Heating (Stadsverwarming) Mysensor IR sender/Receiver

      @DavidZH
      Yes thank you so much. This a really nice tip. I have already tried using my phone camera to see if I'll get any response from the meter. Unfortunately no IR feeback.

      Via the M-Bus is not possible because the meter is sealed by the provider and opening the seal may get me in to trouble :).

      ThANKS

      posted in Domoticz
      Chakkie
      Chakkie
    • RE: District Heating / City Heating (Stadsverwarming) Mysensor IR sender/Receiver

      Hi @TheoL

      Thank you so much for your quick reply and pointing out that the IR port of the meter may not be active. Now I only have to find out if the IR port is active :).

      You mentioned that there is another sketch for reading the Kamstrup meter. May be I have to look around on internet. If you happen to know where I can find this sketch then it would be nice :). I will try to modify the sketch according to your advise. Hope this is going to work.

      Thanks again TheoL

      posted in Domoticz
      Chakkie
      Chakkie
    • District Heating / City Heating (Stadsverwarming) Mysensor IR sender/Receiver

      Hi guys,

      I've been looking for a while on internet to find a way to log the heating usage (District Heating) on my Kamstrup Multical 401. I have come across this thread https://www.domoticz.com/forum/viewtopic.php?f=31&t=5390&hilit=Stadsverwarming. This thread mentions the use of an IR convertor cable (25 euro see image below) and python script.

      alt text
      [img]http://www.smartmeterdashboard.nl/_/rsrc/1355181399073/webshop/IR Convertercable.jpg?height=181&width=200[/img]

      Since I've already been logging my energy and water usage using Mysensor pulse sensor, I though this might also work with the Kamstrup meter (Although I have not find any one on internet using Mysensor to log).

      So I bought this IR Transmitter and receiver [img]https://www.mysensors.org/light/ir.png[/img].

      Uploaded the script found on this url [url]http://frack.nl/wiki/Stadsverwarming[/url] to my arduino. Note that there is no Mysensors components in this script. I only use serial monitor of the ArduinoIDE to test if this works.

      I have set the baudrate to 300 and 1200. Unfortunately I did not get any feedback from the Kamstrup meter. I was wondering if anyone know if this IR transmitter will acturally communicate with the Kamstrup meter. Or am I really stuck with the IR converter cable.

      Thanks everyone.

      Controller: Domoticz
      Server: Raspberry Pi

      [code]
      #include <SoftwareSerial.h>
       
      const int LEDPIN   = 5;
      const int DIODEPIN = A1;
       
      SoftwareSerial mySerial(DIODEPIN, LEDPIN); // RX, TX
       
      long d;
       
      void setup() {
        pinMode(LEDPIN, OUTPUT);
        pinMode(DIODEPIN, INPUT);
        digitalWrite(DIODEPIN, LOW);
        Serial.begin(9600);
        d = millis() + 5000;
      }
       
      char ch;
      boolean rx;
       
      void rx300() {
        boolean done=false;
        mySerial.begin(300);
        mySerial.println("/?!");
        while (!done) {
          if (mySerial.available()) {
            ch = mySerial.read() & 0x7F;
            if (ch == 2) rx = true;
            else if (ch == 3) {
               rx = false;
               done = true;
            }
            else if (rx == true) 
              Serial.print(ch);
              //Serial.write(ch);
          }
        }
      }
       
      void rx1200(char k, long* val, char n) {
        boolean done=false;
        char str[12];
        char i=0, j=0;
        String req = "/#";
        req += k;
        mySerial.begin(300);
        mySerial.println(req);
        mySerial.begin(1200);
        while (n>0) {
          if (mySerial.available()) {
            ch = mySerial.read() & 0x7F;
            if (ch != 0x7F) {
              if (ch == 13) ch == 32;
              //Serial.print(ch);
              if (ch == 32) {
                 str[j] = 0;
                 *val = atol(str);
                 j = 0;
                 val++;
                 i++;
                 n--;
              } else str[j++] = ch;
            }
          }
        }
      }
       
      void loop() {
        long vala[10];
        if (d < millis()) {
          rx300();
          rx1200('1', vala, 10);
          Serial.print("energy [GJ]: ");
          Serial.println(vala[0]/100.0);
          Serial.print("water [m3]: ");
          Serial.println(vala[1]/100.0);
          Serial.print("hourcounter [j]: ");
          Serial.println(vala[2]);
          Serial.print("Tin [.C]: ");
          Serial.println(vala[3]/100.0);
          Serial.print("Tout [.C]: ");
          Serial.println(vala[4]/100.0);
          Serial.print("deltaT [.C]: ");
          Serial.println(vala[5]/100.0);
          Serial.print("power [kW]: ");
          Serial.println(vala[6]/10.0);
          Serial.print("flow [l/h]: ");
          Serial.println(vala[7]);
          Serial.print("peak power/flow [?]: ");
          Serial.println(vala[8]);
          Serial.print("info: ");
          Serial.println(vala[9]);
          while(1);
        }
      }[/code]```
      posted in Domoticz
      Chakkie
      Chakkie
    • RE: How does serial gateway include nodes????

      @ahmedadelhosni Awesome. Thanks for the info. It is starting to get clear how things work here 🙂

      posted in General Discussion
      Chakkie
      Chakkie
    • RE: How does serial gateway include nodes????

      @sundberg84 I am using Domotciz. I think the include process is like once the GW sees some nodes then Go to the Device and click add. If I am correct.

      posted in General Discussion
      Chakkie
      Chakkie
    • RE: How does serial gateway include nodes????

      Thanks for quick reply.

      It's clear now. It's ok if just using Mysensors for measurements. It is a whole different story when you use it to switch the light or heaters or even worst for security purpose. You mentioned "there you include them". Does it mean you have to perform some actions like phyiscally press the reset button on the arduino (Sensors or GW)??? or It is fully auto???

      posted in General Discussion
      Chakkie
      Chakkie
    • How does serial gateway include nodes????

      I've been with Mysensors for just a 3 weeks. Still I haven't been able to make a sensor work because I've got a "blob version of the NRF24 chip". It just very frustrating that it seems very difficult to find a working NRF24L01+ chip. I've been wondering the whole time the blob version does not work with mysensor. Since the blob version shows communication using the "Gettingstarted.pde" sketch. Anyway, my question is HOW DOES THE SERIAL GATEWAY INCLUDE NODES????

      If I am correct, the GW and nodes will automatically look for each other and connect to each other without any confirmation from the user. Does this mean that if my neigbour also has a Mysensor GW, he or she will be able to pick up my nodes???

      Sorry for the stupid questions

      posted in General Discussion
      Chakkie
      Chakkie