Water pulse meter value not reported automatically



  • I've successfully used NodeManager to set up thermo-/hygrometers and the next step is to use it for my water and power meters. However, I'm running into problems.

    I have used the template sketch and changed/added very little code:

    #define NODEMANAGER_DEBUG OFF       // Default ON
    #define NODEMANAGER_SLEEP OFF       // Default ON
       /* snip */
    #include <sensors/SensorWaterMeter.h>
    SensorWaterMeter waterMeter(2);
    

    The problem is that V_VOLUME is only sent at startup. But not when pulses are counted and the value has changed.

    When I request the value manually with a C_REQ message the node reports it twice. First the correct count based on pulse counting and then immediately after 0.0000. (See end of debug log below.)
    So it seems the value is reset.

    This does not seem like the expected behaviour.
    Am I missing something in the configuration or what else could be the problem?

    For testing I tried adding a nodeManager.setReportIntervalSeconds(30); but with no success. The node clearly does not report every 30 seconds.

    The node is a 3.3V Pro mini (EasyPCB) and I'm using MySensors 2.3.1 and NodeManager 1.8.0 libraries on Platformio/VS Code. Gateway is ESP8266 with MySensors 2.2.
    I use MYSController as my testing controller and see the same behaviour in OpenHAB.

    The full debug from the node:

    16 MCO:BGN:INIT NODE,CP=RNNNA---,REL=255,VER=2.3.1
    26 MCO:BGN:BFR
    28 TSM:INIT
    30 TSF:WUR:MS=0
    36 TSM:INIT:TSP OK
    38 TSM:INIT:STATID=11
    40 TSF:SID:OK,ID=11
    43 TSM:FPAR
    79 TSF:MSG:SEND,11-11-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    718 TSF:MSG:READ,0-0-11,s=255,c=3,t=8,pt=1,l=1,sg=0:0
    724 TSF:MSG:FPAR OK,ID=0,D=1
    2091 TSM:FPAR:OK
    2091 TSM:ID
    2093 TSM:ID:OK
    2095 TSM:UPL
    2099 TSF:MSG:SEND,11-11-0-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=OK:1
    2207 TSF:MSG:READ,0-0-11,s=255,c=3,t=25,pt=1,l=1,sg=0:1
    2213 TSF:MSG:PONG RECV,HP=1
    2217 TSM:UPL:OK
    2220 TSM:READY:ID=11,PAR=0,DIS=1
    2224 TSF:MSG:SEND,11-11-0-0,s=255,c=3,t=15,pt=6,l=2,sg=0,ft=0,st=OK:0100
    2359 TSF:MSG:READ,0-0-11,s=255,c=3,t=15,pt=6,l=2,sg=0:0100
    2367 TSF:MSG:SEND,11-11-0-0,s=255,c=0,t=17,pt=0,l=5,sg=0,ft=0,st=OK:2.3.1
    2377 TSF:MSG:SEND,11-11-0-0,s=255,c=3,t=6,pt=1,l=1,sg=0,ft=0,st=OK:0
    2689 TSF:MSG:READ,0-0-11,s=255,c=3,t=6,pt=0,l=1,sg=0:M
    2701 TSF:MSG:SEND,11-11-0-0,s=255,c=3,t=11,pt=0,l=23,sg=0,ft=0,st=OK:EasyPCB Water Meter #11
    2713 TSF:MSG:SEND,11-11-0-0,s=255,c=3,t=12,pt=0,l=22,sg=0,ft=0,st=OK:Jan  3 2019 - 21:07:14
    2725 TSF:MSG:SEND,11-11-0-0,s=1,c=0,t=21,pt=0,l=5,sg=0,ft=0,st=OK:WATER
    2734 MCO:REG:REQ
    2770 !TSF:MSG:SEND,11-11-0-0,s=255,c=3,t=26,pt=1,l=1,sg=0,ft=0,st=NACK:2
    4780 TSF:MSG:SEND,11-11-0-0,s=255,c=3,t=26,pt=1,l=1,sg=0,ft=1,st=OK:2
    4853 TSF:MSG:READ,0-0-11,s=255,c=3,t=27,pt=1,l=1,sg=0:1
    4859 MCO:PIM:NODE REG=1
    4861 MCO:BGN:STP
    4864 MCO:BGN:INIT OK,TSP=1
    4868 TSF:MSG:SEND,11-11-0-0,s=1,c=1,t=35,pt=7,l=5,sg=0,ft=0,st=OK:0.0000
    
    255883 TSF:MSG:READ,0-0-11,s=1,c=2,t=35,pt=0,l=0,sg=0:
    255891 TSF:MSG:SEND,11-11-0-0,s=1,c=1,t=35,pt=7,l=5,sg=0,ft=0,st=OK:0.0920
    255901 TSF:MSG:SEND,11-11-0-0,s=1,c=1,t=35,pt=7,l=5,sg=0,ft=0,st=OK:0.0000
    271042 TSF:MSG:READ,0-0-11,s=1,c=2,t=35,pt=0,l=0,sg=0:
    271050 TSF:MSG:SEND,11-11-0-0,s=1,c=1,t=35,pt=7,l=5,sg=0,ft=0,st=OK:0.0000
    271060 TSF:MSG:SEND,11-11-0-0,s=1,c=1,t=35,pt=7,l=5,sg=0,ft=0,st=OK:0.0000
    ```

  • Contest Winner

    @fredswed definitely not the expected behaviour 🙂 Can you please set NODEMANAGER_DEBUG to ON and share NodeManager's logs as well. This can help me debugging the issue on NodeManager's side.
    Only thing I can see from you code is the use of pin 2. If the Pro Mini is using the radio for transmission, that pin is already used by the radio. Try using pin 3. Thanks



  • @user2684 Many thanks - somtimes it is hard to see the obvious! Pin 2 is definitely connected to the radio which is more than likely a problem. Note to self: do not connect keyboard to ethernet port 🙂
    Have not had the time to fix it and check yet but will do asap.

    Btw, Is the reportInterval required, or will the sensor report on every pulse if an interval is not specified?


  • Contest Winner

    @fredswed if not specified, sensor will report every hour (https://github.com/mysensors/NodeManager/blob/master/sensors/SensorPulseMeter.h#L45). The sensor itself will take care of summing up the accumulated value along the timeframe



  • @user2684 Thanks!
    Finally had the time to try again. Unfortunately no success. Even worse - I can't find the problem 🙂 I'd really appreciate any advice on the code or how to troubleshoot.

    I changed the pulse pin to 3 and recompiled just before the run.

    After startup, pulses were simulated by quickly connecting pin 3 to ground starting at 141883
    I expected values to be sent every 30 seconds but none were sent.
    I did a C_REQ request at 1452361
    Automatic reports were sent from the node around 1 hour (3600000) and 2 hours (7200000), so the reporting interval seems to be at the default 1 hour, not 30 seconds as stated in the code. It's either strange or I have missed something basic...

    Code for the node below. Verbose debug log follows further down.

    /**************************
    *This DC-driven EasyPCB board reads pulses from a water meter and reports water consumption
    */
    
    /**********************************
    * MySensors node configuration
    */
    
    // General settings
    #define SKETCH_NAME "EasyPCB Water Meter #11"
    #define SKETCH_VERSION __DATE__ " - " __TIME__
    // Default baudrate 115200
    #define MY_BAUD_RATE 115200
    #define MY_DEBUG
    
    #define MY_NODE_ID 11
    
    // NRF24 radio settings
    #define MY_RADIO_RF24
    
    /***********************************
     * NodeManager configuration
     */
    
    #define NODEMANAGER_DEBUG ON       // Default ON
    #define NODEMANAGER_INTERRUPTS ON
    #define NODEMANAGER_SLEEP OFF       // Default ON
    #define NODEMANAGER_RECEIVE ON
    #define NODEMANAGER_DEBUG_VERBOSE ON
    #define NODEMANAGER_POWER_MANAGER OFF
    #define NODEMANAGER_CONDITIONAL_REPORT OFF
    #define NODEMANAGER_EEPROM OFF
    #define NODEMANAGER_TIME OFF
    #define NODEMANAGER_RTC OFF
    #define NODEMANAGER_SD OFF
    #define NODEMANAGER_HOOKING OFF
    #define NODEMANAGER_OTA_CONFIGURATION OFF
    #define NODEMANAGER_SERIAL_INPUT OFF
    
    // import NodeManager library (a nodeManager object will be then made available)
    #include <MySensors_NodeManager.h>
    
    /***********************************
     * Add your sensors
     */
    
    #include <sensors/SensorWaterMeter.h>
    SensorWaterMeter waterMeter(3);
    
    /***********************************
     * Main Sketch
     */
    
    // before
    void before() {
    	
      /***********************************
       * Configure your sensors
       */
    
      nodeManager.setReportIntervalSeconds(30)
    
      // call NodeManager before routine
      nodeManager.before();
    }
    
    // presentation
    void presentation() {
      // call NodeManager presentation routine
      nodeManager.presentation();
    }
    
    // setup
    void setup() {
      // call NodeManager setup routine
      nodeManager.setup();
    }
    
    // loop
    void loop() {
      // call NodeManager loop routine
      nodeManager.loop();
    }
    
    #if NODEMANAGER_RECEIVE == ON
    // receive
    void receive(const MyMessage &message) {
      // call NodeManager receive routine
      nodeManager.receive(message);
    }
    #endif
    
    #if NODEMANAGER_TIME == ON
    // receiveTime
    void receiveTime(unsigned long ts) {
      // call NodeManager receiveTime routine
      nodeManager.receiveTime(ts);
    }
    #endif
    

    Serial debug from node:

    0 NM:INIT:VER=1.8
    0 NM:INIT:INO=EasyPCB Water Meter #11 vJan 12 2019 - 20:36:35
    0 NM:INIT:LIB VER=2.3.1 CP=RNNNA---
    
     __  __       ____
    |  \/  |_   _/ ___|  ___ _ __  ___  ___  _ __ ___
    | |\/| | | | \___ \ / _ \ `_ \/ __|/ _ \| `__/ __|
    | |  | | |_| |___| |  __/ | | \__ \  _  | |  \__ \
    |_|  |_|\__, |____/ \___|_| |_|___/\___/|_|  |___/
            |___/                      2.3.1
    
    16 MCO:BGN:INIT NODE,CP=RNNNA---,REL=255,VER=2.3.1
    26 MCO:BGN:BFR
    28 NM:INIT:RBT p=255
    30 NM:BFR:INIT
    32 TSM:INIT
    34 TSF:WUR:MS=0
    40 TSM:INIT:TSP OK
    43 TSM:INIT:STATID=11
    45 TSF:SID:OK,ID=11
    47 TSM:FPAR
    83 TSF:MSG:SEND,11-11-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    346 TSF:MSG:READ,0-0-11,s=255,c=3,t=8,pt=1,l=1,sg=0:0
    352 TSF:MSG:FPAR OK,ID=0,D=1
    2093 TSM:FPAR:OK
    2093 TSM:ID
    2095 TSM:ID:OK
    2097 TSM:UPL
    2101 TSF:MSG:SEND,11-11-0-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=OK:1
    2203 TSF:MSG:READ,0-0-11,s=255,c=3,t=25,pt=1,l=1,sg=0:1
    2209 TSF:MSG:PONG RECV,HP=1
    2213 TSM:UPL:OK
    2215 TSM:READY:ID=11,PAR=0,DIS=1
    2220 TSF:MSG:SEND,11-11-0-0,s=255,c=3,t=15,pt=6,l=2,sg=0,ft=0,st=OK:0100
    2349 TSF:MSG:READ,0-0-11,s=255,c=3,t=15,pt=6,l=2,sg=0:0100
    2357 TSF:MSG:SEND,11-11-0-0,s=255,c=0,t=17,pt=0,l=5,sg=0,ft=0,st=OK:2.3.1
    2365 TSF:MSG:SEND,11-11-0-0,s=255,c=3,t=6,pt=1,l=1,sg=0,ft=0,st=OK:0
    2607 TSF:MSG:READ,0-0-11,s=255,c=3,t=6,pt=0,l=1,sg=0:M
    2613 NM:BFR:OK
    2617 TSF:MSG:SEND,11-11-0-0,s=255,c=3,t=11,pt=0,l=23,sg=0,ft=0,st=OK:EasyPCB Water Meter #11
    2629 TSF:MSG:SEND,11-11-0-0,s=255,c=3,t=12,pt=0,l=22,sg=0,ft=0,st=OK:Jan 12 2019 - 20:36:35
    2639 NM:PRES:WATER(1) p=21 t=35
    2643 TSF:MSG:SEND,11-11-0-0,s=1,c=0,t=21,pt=0,l=5,sg=0,ft=0,st=OK:WATER
    2652 MCO:REG:REQ
    2684 TSF:MSG:SEND,11-11-0-0,s=255,c=3,t=26,pt=1,l=1,sg=0,ft=0,st=OK:2
    2990 TSF:MSG:READ,0-0-11,s=255,c=3,t=27,pt=1,l=1,sg=0:1
    2996 MCO:PIM:NODE REG=1
    2998 MCO:BGN:STP
    3000 NM:STP:ID=11 M=1
    3002 NM:LOOP:INT p=3 v=1
    3004 NM:BFR:INT p=3 m=2
    3080 NM:STP:HW V=3441 F=8 M=1360
    3082 MCO:BGN:INIT OK,TSP=1
    3086 NM:LOOP:WATER(1):SET t=35 v=0.0010
    3090 NM:MSG:SEND(1) t=35 p=0.00
    3096 TSF:MSG:SEND,11-11-0-0,s=1,c=1,t=35,pt=7,l=5,sg=0,ft=0,st=OK:0.0010
    
    
    141883 NM:LOOP:INT p=3 v=0
    141883 NM:LOOP:INT p=3 v=0
    141883 NM:LOOP:INT p=3 v=0
    141883 NM:LOOP:INT p=3 v=0
    141885 NM:LOOP:INT p=3 v=0
    141885 NM:LOOP:INT p=3 v=0
    141885 NM:LOOP:WATER(1):SET t=35 v=0.0010
    141893 NM:LOOP:INT p=3 v=1
    141893 NM:LOOP:INT p=3 v=0
    141893 NM:LOOP:INT p=3 v=0
    141893 NM:LOOP:INT p=3 v=1
    141895 NM:LOOP:WATER(1):SET t=35 v=0.0020
    
    
    244365 TSF:MSG:READ,0-0-255,s=255,c=3,t=20,pt=0,l=0,sg=0:
    244371 TSF:MSG:BC
    245037 TSF:MSG:SEND,11-11-0-0,s=255,c=3,t=21,pt=1,l=1,sg=0,ft=0,st=OK:0
    1452361 TSF:MSG:READ,0-0-11,s=1,c=2,t=35,pt=0,l=0,sg=0:
    1452367 NM:MSG:RECV(1) c=2 t=35 p=
    1452371 NM:MSG:SEND(1) t=35 p=0.00
    1452376 TSF:MSG:SEND,11-11-0-0,s=1,c=1,t=35,pt=7,l=5,sg=0,ft=0,st=OK:0.0020
    1452386 NM:MSG:SEND(1) t=35 p=0.00
    1452390 TSF:MSG:SEND,11-11-0-0,s=1,c=1,t=35,pt=7,l=5,sg=0,ft=0,st=OK:0.0000
    
    3603003 NM:MSG:SEND(1) t=35 p=0.00
    3603007 TSF:MSG:SEND,11-11-0-0,s=1,c=1,t=35,pt=7,l=5,sg=0,ft=0,st=OK:0.0000
    5023537 TSF:MSG:READ,0-0-255,s=255,c=3,t=20,pt=0,l=0,sg=0:
    5023543 TSF:MSG:BC
    5024374 TSF:MSG:SEND,11-11-0-0,s=255,c=3,t=21,pt=1,l=1,sg=0,ft=0,st=OK:0
    6218539 TSF:MSG:READ,0-0-255,s=255,c=3,t=20,pt=0,l=0,sg=0:
    6218545 TSF:MSG:BC
    6219368 TSF:MSG:SEND,11-11-0-0,s=255,c=3,t=21,pt=1,l=1,sg=0,ft=0,st=OK:0
    7203016 NM:MSG:SEND(1) t=35 p=0.00
    7203020 TSF:MSG:SEND,11-11-0-0,s=1,c=1,t=35,pt=7,l=5,sg=0,ft=0,st=OK:0.0000
    

  • Contest Winner

    @fredswed ok looks like the interrupt is intercepted and accumulated value is calculated correctly but the values are just not sent at the specified interval, right? Try calling setReportIntervalSeconds()
    on waterMeter rather than nodeManager. When you call nodeManager.setReportIntervalSeconds(30), this is applied to all the sensors with a report interval not set yet. But since SensorPulseMeter already calls setReportIntervalMinutes() I believe NodeManager will skip it. Thanks



  • @user2684 Thanks! Using waterMeter.setReportIntervalSeconds(30); works and values are now reported every 30 seconds as expected.

    One problem still persists - the counter seem to be reset and there is always a zero value reported after the true value. E.g. after creating a few pulses, I get the log:

    27027 NM:LOOP:WATER(1):SET t=35 v=0.0190
    35086 NM:MSG:SEND(1) t=35 p=0.01
    35090 TSF:MSG:SEND,11-11-0-0,s=1,c=1,t=35,pt=7,l=5,sg=0,ft=0,st=OK:0.0190
    35098 NM:MSG:SEND(1) t=35 p=0.00
    35104 TSF:MSG:SEND,11-11-0-0,s=1,c=1,t=35,pt=7,l=5,sg=0,ft=0,st=OK:0.0000
    65099 NM:MSG:SEND(1) t=35 p=0.00
    65103 TSF:MSG:SEND,11-11-0-0,s=1,c=1,t=35,pt=7,l=5,sg=0,ft=0,st=OK:0.0000
    65112 NM:MSG:SEND(1) t=35 p=0.00
    65118 TSF:MSG:SEND,11-11-0-0,s=1,c=1,t=35,pt=7,l=5,sg=0,ft=0,st=OK:0.0000
    


  • I've digged a bit in the NodeManager code on my own and is far from certain, but isn't it a problem that reset() is called when the value has been reported by the child (line 199)

    If I get it correctly:
    When waterSensor calls setValue, it in turn calls setValueNumber which adds the pulse to _total. That's fine.
    But when sendValue is called at a later time, both _value and _total are reset to 0 as _value_processingis SUM.

    So the pulse count will restart from zero.
    Wouldn't we want to keep at least _total at its current value, to keep the accumulated number of pulses over time?


  • Contest Winner

    @fredswed thanks for your analysis. I think you hit a bug here,I believe is correct that _total is set to 0 when the value is sent (so to start counting again) but it should not send that 0 value message. Keeping track with https://github.com/mysensors/NodeManager/issues/458



  • @user2684 Thanks! Looking forward to a solution, one pulse at a time 🙂



  • @user2684

    I'm trying to convert all my existing sensors from the old mysensors code to the nodemanager which is really a great and easy approach. The problem is that on the original mysensors water pulse sensor, the value is not reseted to 0 after each SEND but the total keeps incrementing. So my question is why is it better to reset to 0?

    Also on the old water meter, there is a FLOW value and the sensor also try to get the existing value from the controller when starting. Do you think that could be implemented on the Nodemanager version?



  • @gomba777 I have only tried the NodeManager version but am considering the old-style code until it works. I would expect any water meter sensor to at least report accumulated totals, similarly to the physical device. I am sure that can be implemented in NodeManager - it is perfectly possible to use extend the framwork oneself even if it is not in there by default. It is more a question that someone as to put the time into it.
    If the other code works for you, I guess the best choice is to hang on to it for a while longer.


  • Contest Winner

    Thanks @fredswed and @gomba777 I've added to the roadmap the capabilities you are referencing to from https://www.mysensors.org/build/pulse_water so the align with NodeManager's. I'll likely come back to you once the development will get to that point for reviewing the implementation if you don't mind. Thanks



Suggested Topics

  • 2
  • 2
  • 3
  • 2
  • 1
  • 1
  • 13

1
Online

11.4k
Users

11.1k
Topics

112.7k
Posts