Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. Announcements
  3. 💬 Power Meter Pulse Sensor

💬 Power Meter Pulse Sensor

Scheduled Pinned Locked Moved Announcements
183 Posts 40 Posters 45.0k Views 37 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C cstewy

    @user2684 I had the same issue when I built this with a standalone atmega328p running on 2x AA's. I set it up with wake on interrupt from the It was constantly drawing 1.6mA to power the tsl257 to detect the flashes. My target was 1+ years on 2 x AA's. My solution to achieve this was to sleep for 125ms, wake up, send power to tsl257 to check light state (on/off), if it changed from previous reading then there was a pulse (well half pulse). By measuring every 125ms I can guarantee to capture fast pulses up to 14.4kW. (3600000/125)/2. It is 20kW max draw for residential in my country. Now:
    Average mA Consumption Sleep 0.1
    Average mA Consumption Wake 0.064516129
    Average mA Consumption Transmit 0.002916667
    Battery Life (2xAAs) = 1.7 years

    U Offline
    U Offline
    user2684
    Contest Winner
    wrote on last edited by
    #144

    @cstewy many thanks and very interesting. You basically saying it consumes less by waking up every 125ms rather than being asleep but with the sensor eating up current continuously. Definitely worth trying thanks! Meanwhile I've reduced the number of radio transmission and the batteries lasted for a couple of months but still is not ideal. Thanks! I'll try and report back

    1 Reply Last reply
    0
    • A Offline
      A Offline
      artipi
      wrote on last edited by
      #145

      Hello, i'm stuck with this sensor, because no Interrupt is really working. I've cut down the code to this:

      /**
       * 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
       *
       * DESCRIPTION
       * This sketch provides an example how to implement a LM393 PCB
       * Use this sensor to measure kWh and Watt of your house meter
       * You need to set the correct pulsefactor of your meter (blinks per kWh).
       * The sensor starts by fetching current kWh value from gateway.
       * Reports both kWh and Watt back to gateway.
       *
       * Unfortunately millis() won't increment when the Arduino is in
       * sleepmode. So we cannot make this sensor sleep if we also want
       * to calculate/report watt value.
       * http://www.mysensors.org/build/pulse_power
       */
      
      // Enable debug prints
      #define MY_DEBUG
      
      // Enable and select radio type attached
      //#define MY_RADIO_NRF24
      //#define MY_RADIO_NRF5_ESB
      //#define MY_RADIO_RFM69
      //#define MY_RADIO_RFM95
      
      //#include <MySensors.h>
      
      #define DIGITAL_INPUT_SENSOR 2  // The digital input you attached your light sensor.  (Only 2 and 3 generates interrupt!)
      #define PULSE_FACTOR 500       // Number of blinks per of your meter
      #define SLEEP_MODE false        // Watt value can only be reported when sleep mode is false.
      #define MAX_WATT 1000000          // Max watt value to report. This filters outliers.
      #define CHILD_ID 10             // Id of the sensor child
      
      uint32_t SEND_FREQUENCY =
          15000; // Minimum time between send (in milliseconds). We don't want to spam the gateway.
      double ppwh = ((double)PULSE_FACTOR)/1000; // Pulses per watt hour
      bool pcReceived = true;
      volatile uint32_t pulseCount = 0;
      volatile uint32_t lastBlink = 0;
      volatile uint32_t watt = 0;
      uint32_t oldPulseCount = 0;
      uint32_t oldWatt = 0;
      double oldkWh;
      uint32_t lastSend;
      //MyMessage wattMsg(CHILD_ID,V_WATT);
      //MyMessage kWhMsg(CHILD_ID,V_KWH);
      //MyMessage pcMsg(CHILD_ID,V_VAR1);
      
      
      void setup()
      {
        Serial.begin(9600);
        Serial.println("Start setup");
        // Fetch last known pulse count value from gw
        //request(CHILD_ID, V_VAR1);
      
        // Use the internal pullup to be able to hook up this sketch directly to an energy meter with S0 output
        // If no pullup is used, the reported usage will be too high because of the floating pin
        pinMode(DIGITAL_INPUT_SENSOR,INPUT_PULLUP);
      
        attachInterrupt(digitalPinToInterrupt(DIGITAL_INPUT_SENSOR), onPulse, RISING);
        lastSend=millis();
        Serial.println("Start setup: last sent: ");
        pinMode(LED_BUILTIN, OUTPUT);
        digitalWrite(LED_BUILTIN, LOW);
      }
      
      void presentation()
      {
        // Send the sketch version information to the gateway and Controller
        //sendSketchInfo("Energy Meter", "1.3");
      
        // Register this device as power sensor
        //present(CHILD_ID, S_POWER);
      }
      
      void loop()
      {
        
      }
      
      
      
      void onPulse()
      {
        Serial.println("onPulse:");
        digitalWrite(LED_BUILTIN, HIGH);   // turn the LED on (HIGH is the voltage level)
        delay(1000);                       // wait for a second
        digitalWrite(LED_BUILTIN, LOW);    // turn the LED off by making the voltage LOW
        delay(1000);      
        pulseCount++;
        Serial.println("pulseCount:");
      }
      

      The Problem ist, that only on Start the interrupt ist working once, but no LED blinks.

      Can someone help?

      Thanks.

      mfalkviddM 1 Reply Last reply
      0
      • A artipi

        Hello, i'm stuck with this sensor, because no Interrupt is really working. I've cut down the code to this:

        /**
         * 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
         *
         * DESCRIPTION
         * This sketch provides an example how to implement a LM393 PCB
         * Use this sensor to measure kWh and Watt of your house meter
         * You need to set the correct pulsefactor of your meter (blinks per kWh).
         * The sensor starts by fetching current kWh value from gateway.
         * Reports both kWh and Watt back to gateway.
         *
         * Unfortunately millis() won't increment when the Arduino is in
         * sleepmode. So we cannot make this sensor sleep if we also want
         * to calculate/report watt value.
         * http://www.mysensors.org/build/pulse_power
         */
        
        // Enable debug prints
        #define MY_DEBUG
        
        // Enable and select radio type attached
        //#define MY_RADIO_NRF24
        //#define MY_RADIO_NRF5_ESB
        //#define MY_RADIO_RFM69
        //#define MY_RADIO_RFM95
        
        //#include <MySensors.h>
        
        #define DIGITAL_INPUT_SENSOR 2  // The digital input you attached your light sensor.  (Only 2 and 3 generates interrupt!)
        #define PULSE_FACTOR 500       // Number of blinks per of your meter
        #define SLEEP_MODE false        // Watt value can only be reported when sleep mode is false.
        #define MAX_WATT 1000000          // Max watt value to report. This filters outliers.
        #define CHILD_ID 10             // Id of the sensor child
        
        uint32_t SEND_FREQUENCY =
            15000; // Minimum time between send (in milliseconds). We don't want to spam the gateway.
        double ppwh = ((double)PULSE_FACTOR)/1000; // Pulses per watt hour
        bool pcReceived = true;
        volatile uint32_t pulseCount = 0;
        volatile uint32_t lastBlink = 0;
        volatile uint32_t watt = 0;
        uint32_t oldPulseCount = 0;
        uint32_t oldWatt = 0;
        double oldkWh;
        uint32_t lastSend;
        //MyMessage wattMsg(CHILD_ID,V_WATT);
        //MyMessage kWhMsg(CHILD_ID,V_KWH);
        //MyMessage pcMsg(CHILD_ID,V_VAR1);
        
        
        void setup()
        {
          Serial.begin(9600);
          Serial.println("Start setup");
          // Fetch last known pulse count value from gw
          //request(CHILD_ID, V_VAR1);
        
          // Use the internal pullup to be able to hook up this sketch directly to an energy meter with S0 output
          // If no pullup is used, the reported usage will be too high because of the floating pin
          pinMode(DIGITAL_INPUT_SENSOR,INPUT_PULLUP);
        
          attachInterrupt(digitalPinToInterrupt(DIGITAL_INPUT_SENSOR), onPulse, RISING);
          lastSend=millis();
          Serial.println("Start setup: last sent: ");
          pinMode(LED_BUILTIN, OUTPUT);
          digitalWrite(LED_BUILTIN, LOW);
        }
        
        void presentation()
        {
          // Send the sketch version information to the gateway and Controller
          //sendSketchInfo("Energy Meter", "1.3");
        
          // Register this device as power sensor
          //present(CHILD_ID, S_POWER);
        }
        
        void loop()
        {
          
        }
        
        
        
        void onPulse()
        {
          Serial.println("onPulse:");
          digitalWrite(LED_BUILTIN, HIGH);   // turn the LED on (HIGH is the voltage level)
          delay(1000);                       // wait for a second
          digitalWrite(LED_BUILTIN, LOW);    // turn the LED off by making the voltage LOW
          delay(1000);      
          pulseCount++;
          Serial.println("pulseCount:");
        }
        

        The Problem ist, that only on Start the interrupt ist working once, but no LED blinks.

        Can someone help?

        Thanks.

        mfalkviddM Offline
        mfalkviddM Offline
        mfalkvidd
        Mod
        wrote on last edited by mfalkvidd
        #146

        @artipi using Serial.print and delay from within an interrupt service routine will mess things up. Interrupt service routines must be executed quickly.

        From https://www.arduino.cc/reference/en/language/functions/external-interrupts/attachinterrupt/:

        Since delay() requires interrupts to work, it will not work if called inside an ISR.

        You need to do the blinking inside loop().

        1 Reply Last reply
        0
        • A Offline
          A Offline
          artipi
          wrote on last edited by
          #147

          Ah, this explains many things. Thank you, now its working:)!

          1 Reply Last reply
          1
          • alowhumA Offline
            alowhumA Offline
            alowhum
            Plugin Developer
            wrote on last edited by
            #148

            @artipi can you share your code?

            1 Reply Last reply
            0
            • A Offline
              A Offline
              artipi
              wrote on last edited by
              #149

              @alowhum: Its the original code. Nothing changed. I've only made some tests with my version...

              1 Reply Last reply
              0
              • P Offline
                P Offline
                patrikr76
                wrote on last edited by patrikr76
                #150

                Hey guys

                So i am trying to use this sketch with the sleep mode set to true 'cause i need to run it on battery.
                It works fine running with usb power on it and sleep mode on false.
                But with sleep mode true i am getting nothing in myscontroller after the initial startup.
                All i changed is the sleep mode from false to true.
                Running it on a clone nano with some chinese "flame detector" sensor.
                Been trying to figure out if it has something to do with how it reports when in sleep mode but it should still report whatever the send frequency is set to right?
                I was using a tv remote to fake impulses, with seems to work on usb power, but not on battery.
                Any suggestions?

                Best regards
                Patrik

                mfalkviddM 1 Reply Last reply
                0
                • P patrikr76

                  Hey guys

                  So i am trying to use this sketch with the sleep mode set to true 'cause i need to run it on battery.
                  It works fine running with usb power on it and sleep mode on false.
                  But with sleep mode true i am getting nothing in myscontroller after the initial startup.
                  All i changed is the sleep mode from false to true.
                  Running it on a clone nano with some chinese "flame detector" sensor.
                  Been trying to figure out if it has something to do with how it reports when in sleep mode but it should still report whatever the send frequency is set to right?
                  I was using a tv remote to fake impulses, with seems to work on usb power, but not on battery.
                  Any suggestions?

                  Best regards
                  Patrik

                  mfalkviddM Offline
                  mfalkviddM Offline
                  mfalkvidd
                  Mod
                  wrote on last edited by mfalkvidd
                  #151

                  @patrikr76 just to make sure we are on the same page, could you clarify which sketch you are using? This thread has discussed lots of sketches and it would be a pity if we’re looking at different code :)

                  In any case, the debug log from the node will give the best information on what is happening.

                  It could also be useful to only change one thing. Right now you change sleep mode and switch to battery, right? How does the node behave with sleep mode on, but still running on usb power? How does the node behave with sleep mode off, but running on battery?

                  1 Reply Last reply
                  0
                  • P Offline
                    P Offline
                    patrikr76
                    wrote on last edited by patrikr76
                    #152

                    @mfalkvidd , you are absolutely right. Let me clarify.
                    I am using the example code that is under build and power meter pulse sensor, updated may 1st, 2018.
                    Running it with "sleep mode = false" it works fine with both usb and battery power, just drains the battery quite fast.
                    Setting it to "sleep mode = true" it doesn't work either on usb or battery power.

                    Here's how the serial monitor looks for the startup phase with sleep mode as true.

                    23:21:24.219 ->  __  __       ____
                    23:21:24.219 -> |  \/  |_   _/ ___|  ___ _ __  ___  ___  _ __ ___
                    23:21:24.219 -> | |\/| | | | \___ \ / _ \ `_ \/ __|/ _ \| `__/ __|
                    23:21:24.219 -> | |  | | |_| |___| |  __/ | | \__ \  _  | |  \__ \
                    23:21:24.219 -> |_|  |_|\__, |____/ \___|_| |_|___/\___/|_|  |___/
                    23:21:24.219 ->         |___/                      2.3.0
                    23:21:24.219 -> 
                    23:21:24.219 -> 16 MCO:BGN:INIT NODE,CP=RNNNA---,VER=2.3.0
                    23:21:24.254 -> 25 TSM:INIT
                    23:21:24.254 -> 26 TSF:WUR:MS=0
                    23:21:24.254 -> 33 TSM:INIT:TSP OK
                    23:21:24.254 -> 35 TSF:SID:OK,ID=2
                    23:21:24.254 -> 37 TSM:FPAR
                    73 TSF:MSG:SEND,2-2-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
                    201 TSF:MSG:READ,0-0-2,s=255,c=3,t=8,pt=1,l=1,sg=0:0
                    23:21:24.428 -> 205 TSF:MSG:FPAR OK,ID=0,D=1
                    2080 TSM:FPAR:OK
                    23:21:26.306 -> 2081 TSM:ID
                    23:21:26.306 -> 2082 TSM:ID:OK
                    23:21:26.306 -> 2084 TSM:UPL
                    23:21:26.306 -> 2087 TSF:MSG:SEND,2-2-0-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=OK:1
                    23:21:26.306 -> 2095 TSF:MSG:READ,0-0-2,s=255,c=3,t=25,pt=1,l=1,sg=0:1
                    23:21:26.306 -> 2100 TSF:MSG:PONG RECV,HP=1
                    23:21:26.306 -> 2103 TSM:UPL:OK
                    23:21:26.306 -> 2104 TSM:READY:ID=2,PAR=0,DIS=1
                    23:21:26.306 -> 2109 TSF:MSG:SEND,2-2-0-0,s=255,c=3,t=15,pt=6,l=2,sg=0,ft=0,st=OK:0100
                    23:21:26.341 -> 2118 TSF:MSG:READ,0-0-2,s=255,c=3,t=15,pt=6,l=2,sg=0:0100
                    23:21:26.341 -> 2125 TSF:MSG:SEND,2-2-0-0,s=255,c=0,t=17,pt=0,l=5,sg=0,ft=0,st=OK:2.3.0
                    23:21:26.341 -> 2134 TSF:MSG:SEND,2-2-0-0,s=255,c=3,t=6,pt=1,l=1,sg=0,ft=0,st=OK:0
                    2203 TSF:MSG:READ,0-0-2,s=255,c=3,t=6,pt=0,l=1,sg=0:M
                    23:21:26.410 -> 2210 TSF:MSG:SEND,2-2-0-0,s=255,c=3,t=11,pt=0,l=12,sg=0,ft=0,st=OK:Energy Meter
                    23:21:26.445 -> 2220 TSF:MSG:SEND,2-2-0-0,s=255,c=3,t=12,pt=0,l=3,sg=0,ft=0,st=OK:1.0
                    23:21:26.445 -> 2228 TSF:MSG:SEND,2-2-0-0,s=1,c=0,t=13,pt=0,l=0,sg=0,ft=0,st=OK:
                    23:21:26.445 -> 2234 MCO:REG:REQ
                    23:21:26.445 -> 2237 TSF:MSG:SEND,2-2-0-0,s=255,c=3,t=26,pt=1,l=1,sg=0,ft=0,st=OK:2
                    2252 TSF:MSG:READ,0-0-2,s=255,c=3,t=27,pt=1,l=1,sg=0:1
                    23:21:26.480 -> 2257 MCO:PIM:NODE REG=1
                    23:21:26.480 -> 2259 MCO:BGN:STP
                    23:21:26.480 -> 2263 TSF:MSG:SEND,2-2-0-0,s=1,c=2,t=24,pt=0,l=0,sg=0,ft=0,st=OK:
                    23:21:26.480 -> 2269 MCO:BGN:INIT OK,TSP=1
                    23:21:26.480 -> 2272 MCO:SLP:MS=20000,SMS=0,I1=255,M1=255,I2=255,M2=255
                    23:21:26.480 -> 2277 TSF:TDI:TSL
                    

                    As far as i can see it seems fine and also shows up in myscontroller.

                    And here is an example how it looks after 20 seconds sleep.

                    2414 MCO:SLP:WUP=-1
                    23:26:36.346 -> 2416 TSF:TRI:TSB
                    23:26:36.346 -> 2418 MCO:SLP:MS=20000,SMS=0,I1=255,M1=255,I2=255,M2=255
                    23:26:36.346 -> 2423 TSF:TDI:TSL
                    

                    I don't see any connection attempts with my gateway, or shouldn't there by any if the sensor is not triggered?

                    Here i can show how it looks when tricking the sensor with the ir on the mouse.

                    2456 MCO:SLP:WUP=-1
                    23:27:48.785 -> 2458 TSF:TRI:TSB
                    23:27:48.785 -> 2460 MCO:SLP:MS=20000,SMS=0,I1=255,M1=255,I2=255,M2=255
                    23:27:48.785 -> 2465 TSF:TDI:TSL
                    2467 MCO:SLP:WUP=-1
                    23:27:48.924 -> 2468 TSF:TRI:TSB
                    23:27:48.959 -> 2470 MCO:SLP:MS=20000,SMS=0,I1=255,M1=255,I2=255,M2=255
                    23:27:48.959 -> 2476 TSF:TDI:TSL
                    2478 MCO:SLP:WUP=-1
                    23:27:49.098 -> 2480 TSF:TRI:TSB
                    23:27:49.098 -> 2481 MCO:SLP:MS=20000,SMS=0,I1=255,M1=255,I2=255,M2=255
                    23:27:49.098 -> 2486 TSF:TDI:TSL
                    2488 MCO:SLP:WUP=-1
                    23:27:49.235 -> 2490 TSF:TRI:TSB
                    23:27:49.235 -> 2492 MCO:SLP:MS=20000,SMS=0,I1=255,M1=255,I2=255,M2=255
                    23:27:49.270 -> 2497 TSF:TDI:TSL
                    2498 MCO:SLP:WUP=-1
                    23:27:49.408 -> 2500 TSF:TRI:TSB
                    23:27:49.408 -> 2502 MCO:SLP:MS=20000,SMS=0,I1=255,M1=255,I2=255,M2=255
                    23:27:49.408 -> 2507 TSF:TDI:TSL
                    2509 MCO:SLP:WUP=-1
                    23:27:49.546 -> 2510 TSF:TRI:TSB
                    23:27:49.546 -> 2512 MCO:SLP:MS=20000,SMS=0,I1=255,M1=255,I2=255,M2=255
                    23:27:49.546 -> 2518 TSF:TDI:TSL
                    

                    Interrupt is triggered and it wakes up, but nothing is sent to the gateway.

                    Have i missed something?

                    mfalkviddM 1 Reply Last reply
                    1
                    • P patrikr76

                      @mfalkvidd , you are absolutely right. Let me clarify.
                      I am using the example code that is under build and power meter pulse sensor, updated may 1st, 2018.
                      Running it with "sleep mode = false" it works fine with both usb and battery power, just drains the battery quite fast.
                      Setting it to "sleep mode = true" it doesn't work either on usb or battery power.

                      Here's how the serial monitor looks for the startup phase with sleep mode as true.

                      23:21:24.219 ->  __  __       ____
                      23:21:24.219 -> |  \/  |_   _/ ___|  ___ _ __  ___  ___  _ __ ___
                      23:21:24.219 -> | |\/| | | | \___ \ / _ \ `_ \/ __|/ _ \| `__/ __|
                      23:21:24.219 -> | |  | | |_| |___| |  __/ | | \__ \  _  | |  \__ \
                      23:21:24.219 -> |_|  |_|\__, |____/ \___|_| |_|___/\___/|_|  |___/
                      23:21:24.219 ->         |___/                      2.3.0
                      23:21:24.219 -> 
                      23:21:24.219 -> 16 MCO:BGN:INIT NODE,CP=RNNNA---,VER=2.3.0
                      23:21:24.254 -> 25 TSM:INIT
                      23:21:24.254 -> 26 TSF:WUR:MS=0
                      23:21:24.254 -> 33 TSM:INIT:TSP OK
                      23:21:24.254 -> 35 TSF:SID:OK,ID=2
                      23:21:24.254 -> 37 TSM:FPAR
                      73 TSF:MSG:SEND,2-2-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
                      201 TSF:MSG:READ,0-0-2,s=255,c=3,t=8,pt=1,l=1,sg=0:0
                      23:21:24.428 -> 205 TSF:MSG:FPAR OK,ID=0,D=1
                      2080 TSM:FPAR:OK
                      23:21:26.306 -> 2081 TSM:ID
                      23:21:26.306 -> 2082 TSM:ID:OK
                      23:21:26.306 -> 2084 TSM:UPL
                      23:21:26.306 -> 2087 TSF:MSG:SEND,2-2-0-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=OK:1
                      23:21:26.306 -> 2095 TSF:MSG:READ,0-0-2,s=255,c=3,t=25,pt=1,l=1,sg=0:1
                      23:21:26.306 -> 2100 TSF:MSG:PONG RECV,HP=1
                      23:21:26.306 -> 2103 TSM:UPL:OK
                      23:21:26.306 -> 2104 TSM:READY:ID=2,PAR=0,DIS=1
                      23:21:26.306 -> 2109 TSF:MSG:SEND,2-2-0-0,s=255,c=3,t=15,pt=6,l=2,sg=0,ft=0,st=OK:0100
                      23:21:26.341 -> 2118 TSF:MSG:READ,0-0-2,s=255,c=3,t=15,pt=6,l=2,sg=0:0100
                      23:21:26.341 -> 2125 TSF:MSG:SEND,2-2-0-0,s=255,c=0,t=17,pt=0,l=5,sg=0,ft=0,st=OK:2.3.0
                      23:21:26.341 -> 2134 TSF:MSG:SEND,2-2-0-0,s=255,c=3,t=6,pt=1,l=1,sg=0,ft=0,st=OK:0
                      2203 TSF:MSG:READ,0-0-2,s=255,c=3,t=6,pt=0,l=1,sg=0:M
                      23:21:26.410 -> 2210 TSF:MSG:SEND,2-2-0-0,s=255,c=3,t=11,pt=0,l=12,sg=0,ft=0,st=OK:Energy Meter
                      23:21:26.445 -> 2220 TSF:MSG:SEND,2-2-0-0,s=255,c=3,t=12,pt=0,l=3,sg=0,ft=0,st=OK:1.0
                      23:21:26.445 -> 2228 TSF:MSG:SEND,2-2-0-0,s=1,c=0,t=13,pt=0,l=0,sg=0,ft=0,st=OK:
                      23:21:26.445 -> 2234 MCO:REG:REQ
                      23:21:26.445 -> 2237 TSF:MSG:SEND,2-2-0-0,s=255,c=3,t=26,pt=1,l=1,sg=0,ft=0,st=OK:2
                      2252 TSF:MSG:READ,0-0-2,s=255,c=3,t=27,pt=1,l=1,sg=0:1
                      23:21:26.480 -> 2257 MCO:PIM:NODE REG=1
                      23:21:26.480 -> 2259 MCO:BGN:STP
                      23:21:26.480 -> 2263 TSF:MSG:SEND,2-2-0-0,s=1,c=2,t=24,pt=0,l=0,sg=0,ft=0,st=OK:
                      23:21:26.480 -> 2269 MCO:BGN:INIT OK,TSP=1
                      23:21:26.480 -> 2272 MCO:SLP:MS=20000,SMS=0,I1=255,M1=255,I2=255,M2=255
                      23:21:26.480 -> 2277 TSF:TDI:TSL
                      

                      As far as i can see it seems fine and also shows up in myscontroller.

                      And here is an example how it looks after 20 seconds sleep.

                      2414 MCO:SLP:WUP=-1
                      23:26:36.346 -> 2416 TSF:TRI:TSB
                      23:26:36.346 -> 2418 MCO:SLP:MS=20000,SMS=0,I1=255,M1=255,I2=255,M2=255
                      23:26:36.346 -> 2423 TSF:TDI:TSL
                      

                      I don't see any connection attempts with my gateway, or shouldn't there by any if the sensor is not triggered?

                      Here i can show how it looks when tricking the sensor with the ir on the mouse.

                      2456 MCO:SLP:WUP=-1
                      23:27:48.785 -> 2458 TSF:TRI:TSB
                      23:27:48.785 -> 2460 MCO:SLP:MS=20000,SMS=0,I1=255,M1=255,I2=255,M2=255
                      23:27:48.785 -> 2465 TSF:TDI:TSL
                      2467 MCO:SLP:WUP=-1
                      23:27:48.924 -> 2468 TSF:TRI:TSB
                      23:27:48.959 -> 2470 MCO:SLP:MS=20000,SMS=0,I1=255,M1=255,I2=255,M2=255
                      23:27:48.959 -> 2476 TSF:TDI:TSL
                      2478 MCO:SLP:WUP=-1
                      23:27:49.098 -> 2480 TSF:TRI:TSB
                      23:27:49.098 -> 2481 MCO:SLP:MS=20000,SMS=0,I1=255,M1=255,I2=255,M2=255
                      23:27:49.098 -> 2486 TSF:TDI:TSL
                      2488 MCO:SLP:WUP=-1
                      23:27:49.235 -> 2490 TSF:TRI:TSB
                      23:27:49.235 -> 2492 MCO:SLP:MS=20000,SMS=0,I1=255,M1=255,I2=255,M2=255
                      23:27:49.270 -> 2497 TSF:TDI:TSL
                      2498 MCO:SLP:WUP=-1
                      23:27:49.408 -> 2500 TSF:TRI:TSB
                      23:27:49.408 -> 2502 MCO:SLP:MS=20000,SMS=0,I1=255,M1=255,I2=255,M2=255
                      23:27:49.408 -> 2507 TSF:TDI:TSL
                      2509 MCO:SLP:WUP=-1
                      23:27:49.546 -> 2510 TSF:TRI:TSB
                      23:27:49.546 -> 2512 MCO:SLP:MS=20000,SMS=0,I1=255,M1=255,I2=255,M2=255
                      23:27:49.546 -> 2518 TSF:TDI:TSL
                      

                      Interrupt is triggered and it wakes up, but nothing is sent to the gateway.

                      Have i missed something?

                      mfalkviddM Offline
                      mfalkviddM Offline
                      mfalkvidd
                      Mod
                      wrote on last edited by
                      #153

                      @patrikr76 great info, thanks!

                      The -1 in Wup=-1 indicates that the node was waken up by timer and not by interrupt. That’s very strange, since the time stamps clearly show that 20 seconds has not passed.

                      Could you add

                      Serial.println(pulseCount);
                      

                      after

                      sleep(SEND_FREQUENCY);
                      

                      to see if pulseCount is increased?

                      1 Reply Last reply
                      0
                      • P Offline
                        P Offline
                        patrikr76
                        wrote on last edited by patrikr76
                        #154

                        @mfalkvidd , Here's the serial monitor after adding the serial print.

                        2269 MCO:SLP:WUP=-1
                        14:15:15.125 -> 2270 TSF:TRI:TSB
                        14:15:15.125 -> 0
                        14:15:15.125 -> 2272 MCO:SLP:MS=20000,SMS=0,I1=255,M1=255,I2=255,M2=255
                        14:15:15.125 -> 2277 TSF:TDI:TSL
                        2279 MCO:SLP:WUP=-1
                        14:15:37.264 -> 2281 TSF:TRI:TSB
                        14:15:37.264 -> 0
                        14:15:37.264 -> 2282 MCO:SLP:MS=20000,SMS=0,I1=255,M1=255,I2=255,M2=255
                        14:15:37.264 -> 2287 TSF:TDI:TSL
                        2289 MCO:SLP:WUP=-1
                        14:15:59.354 -> 2291 TSF:TRI:TSB
                        14:15:59.354 -> 0
                        14:15:59.354 -> 2293 MCO:SLP:MS=20000,SMS=0,I1=255,M1=255,I2=255,M2=255
                        14:15:59.389 -> 2298 TSF:TDI:TSL
                        

                        As you see, it sleeps about 22 secs with no pulse on it.

                        Moving the mouse over it gives this.

                        2353 MCO:SLP:WUP=-1
                        14:18:09.982 -> 2355 TSF:TRI:TSB
                        14:18:09.982 -> 4
                        14:18:09.982 -> 2357 MCO:SLP:MS=20000,SMS=0,I1=255,M1=255,I2=255,M2=255
                        14:18:09.982 -> 2362 TSF:TDI:TSL
                        2363 MCO:SLP:WUP=-1
                        14:18:23.059 -> 2365 TSF:TRI:TSB
                        14:18:23.059 -> 5
                        14:18:23.059 -> 2367 MCO:SLP:MS=20000,SMS=0,I1=255,M1=255,I2=255,M2=255
                        14:18:23.059 -> 2372 TSF:TDI:TSL
                        

                        Looking through the code, this one raises a flag.

                        if (pcReceived && (SLEEP_MODE || sendTime))
                        

                        The pulseCount send is within that if statement which is not fullfilled because it doesn't receive pcReceived.
                        Or am i wrong?

                        1 Reply Last reply
                        0
                        • P Offline
                          P Offline
                          patrikr76
                          wrote on last edited by
                          #155

                          Found a solution, which is not ideal.
                          I was having similar problem with a motion sensor not being able to send, adding a delay after sleep helped on that one, but it was just a 5ms delay needed.

                          On this one i had to add a 1 sec delay in the begining of the loop. I tried smaller but then it didn't work.
                          I am starting to think it is the nano clone that has crappy components.

                          mfalkviddM 1 Reply Last reply
                          0
                          • P patrikr76

                            Found a solution, which is not ideal.
                            I was having similar problem with a motion sensor not being able to send, adding a delay after sleep helped on that one, but it was just a 5ms delay needed.

                            On this one i had to add a 1 sec delay in the begining of the loop. I tried smaller but then it didn't work.
                            I am starting to think it is the nano clone that has crappy components.

                            mfalkviddM Offline
                            mfalkviddM Offline
                            mfalkvidd
                            Mod
                            wrote on last edited by
                            #156

                            @patrikr76 nice work.
                            Sounds very similar to https://forum.mysensors.org/topic/9655/delay-after-tsf-tri-tsb/14

                            1 Reply Last reply
                            0
                            • S Offline
                              S Offline
                              StKilda
                              wrote on last edited by
                              #157

                              I have two meters I would like to measure: One that the LED is off most of the time and briefly pulses on per increment (at 3200 pulses per Kwh - so I adjusted the pulse factor accordingly). This works fine. The second meter, the LED pulses off (meaning the led it lit most of the time, and pulses off briefly). Do I need to adjust the code in any way to deal with this meter? Thanks. Really impressed it works virtually out of the box.

                              mfalkviddM 1 Reply Last reply
                              0
                              • S StKilda

                                I have two meters I would like to measure: One that the LED is off most of the time and briefly pulses on per increment (at 3200 pulses per Kwh - so I adjusted the pulse factor accordingly). This works fine. The second meter, the LED pulses off (meaning the led it lit most of the time, and pulses off briefly). Do I need to adjust the code in any way to deal with this meter? Thanks. Really impressed it works virtually out of the box.

                                mfalkviddM Offline
                                mfalkviddM Offline
                                mfalkvidd
                                Mod
                                wrote on last edited by
                                #158

                                Great work @stkilda
                                I think the sketch will work without modification. The easiest way to find out is probably to try it.

                                1 Reply Last reply
                                0
                                • gohanG Offline
                                  gohanG Offline
                                  gohan
                                  Mod
                                  wrote on last edited by
                                  #159

                                  you may need to change the interrupt behavior, but try it first

                                  1 Reply Last reply
                                  0
                                  • bjornhallbergB Offline
                                    bjornhallbergB Offline
                                    bjornhallberg
                                    Hero Member
                                    wrote on last edited by
                                    #160

                                    Is there a suggested replacement for the TSL250? While it can still be found, it seems to be discontinued for the most part.

                                    I've had no luck with the LM393 solution for my new power meter. Just can't tune it to pick up the led impulses. What sort of diode solution is everyone else using? I'm aware of the possibility of IR communication (https://wiki.hal9k.dk/projects/kamstrup) but it seems a little over the top.

                                    1 Reply Last reply
                                    0
                                    • gohanG Offline
                                      gohanG Offline
                                      gohan
                                      Mod
                                      wrote on last edited by
                                      #161

                                      I used these https://www.aliexpress.com/item/5-pcs-LM393-Light-Sensor-Photosensitive-Sensitivity-light-Sensor-Module-For-Arduino-Smart-Car/1729424221.html

                                      1 Reply Last reply
                                      0
                                      • F Offline
                                        F Offline
                                        FullMetal
                                        wrote on last edited by
                                        #162

                                        Hello
                                        my skectch works very well, only I have a double pricing, I manage to recover the information. but I have to modify the code in order to have my exact consumption.
                                        but my code sends me information always on the same IDs.
                                        thank you

                                        mfalkviddM 1 Reply Last reply
                                        0
                                        • F FullMetal

                                          Hello
                                          my skectch works very well, only I have a double pricing, I manage to recover the information. but I have to modify the code in order to have my exact consumption.
                                          but my code sends me information always on the same IDs.
                                          thank you

                                          mfalkviddM Offline
                                          mfalkviddM Offline
                                          mfalkvidd
                                          Mod
                                          wrote on last edited by mfalkvidd
                                          #163

                                          Hi @fullmetal, welcome to the forum :-)

                                          Could you explain what double pricing means?

                                          1 Reply Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          13

                                          Online

                                          11.7k

                                          Users

                                          11.2k

                                          Topics

                                          113.1k

                                          Posts


                                          Copyright 2025 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
                                          • Login

                                          • Don't have an account? Register

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • MySensors
                                          • OpenHardware.io
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular