Navigation

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

    Chakkie

    @Chakkie

    2
    Reputation
    31
    Posts
    641
    Profile views
    0
    Followers
    0
    Following
    Joined Last Online

    Chakkie Follow

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

    Latest 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