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.
  • maghacM Offline
    maghacM Offline
    maghac
    wrote on last edited by
    #48

    As the sketch starts by requesting the latest pulse count (e.g starting kWh value) and does not send anything without having received it, how do I "seed" this value to my GW? I am using a MQTT GW, can I construct a MQTT special message containing the value, or how is it supposed to work?

    F 1 Reply Last reply
    0
    • maghacM maghac

      As the sketch starts by requesting the latest pulse count (e.g starting kWh value) and does not send anything without having received it, how do I "seed" this value to my GW? I am using a MQTT GW, can I construct a MQTT special message containing the value, or how is it supposed to work?

      F Offline
      F Offline
      flopp
      wrote on last edited by
      #49

      @maghac
      I am using Domoticz ans MyS 1.5.1
      You don't have to create VAR1, it will be created when you ask for it or it always exists for each Child.
      If you want VAR1 to be exactly the same as your meter you need to open domoticz.db and set the value or in your sketch.

      maghacM 1 Reply Last reply
      0
      • sundberg84S Offline
        sundberg84S Offline
        sundberg84
        Hardware Contributor
        wrote on last edited by sundberg84
        #50

        Anyone knows why I dont get the sleep() function (time) to work properly.

        My hardware is EasyPCB, Pro Mini 3.3v 8mhz, Booster 2xAA and NRF24 radio.
        My software is: standard sketch 2.0.1, with sleep function.

        The problem is the sleep time is 5 times less than declared so maybe timing?
        When i enter sleep(10000) for example the nodes sleeps for 2 sec and wakes up.

        The interupt works fine.

        My sollution was adding *5 to get the correct sleep time - but why doesnt it work?

        Controller: Proxmox VM - Home Assistant
        MySensors GW: Arduino Uno - W5100 Ethernet, Gw Shield Nrf24l01+ 2,4Ghz
        MySensors GW: Arduino Uno - Gw Shield RFM69, 433mhz
        RFLink GW - Arduino Mega + RFLink Shield, 433mhz

        1 Reply Last reply
        0
        • F flopp

          @maghac
          I am using Domoticz ans MyS 1.5.1
          You don't have to create VAR1, it will be created when you ask for it or it always exists for each Child.
          If you want VAR1 to be exactly the same as your meter you need to open domoticz.db and set the value or in your sketch.

          maghacM Offline
          maghacM Offline
          maghac
          wrote on last edited by
          #51

          @flopp I had to set pcReceived to true, upload the sketch, run it and then change back to false again and recompile/reupload. I can understand why it does it, since you don't want the pulse counter to reset to 0 if the sensor happens to restart (because you killed the power or whatever).

          What I don't understand is how I can seed the value with the correct initial value.

          Is it the controller (in my case HomeAssistant) or the gateway that is supplying the value?

          maghacM 1 Reply Last reply
          0
          • maghacM maghac

            @flopp I had to set pcReceived to true, upload the sketch, run it and then change back to false again and recompile/reupload. I can understand why it does it, since you don't want the pulse counter to reset to 0 if the sensor happens to restart (because you killed the power or whatever).

            What I don't understand is how I can seed the value with the correct initial value.

            Is it the controller (in my case HomeAssistant) or the gateway that is supplying the value?

            maghacM Offline
            maghacM Offline
            maghac
            wrote on last edited by
            #52

            It appears to be the controller that stores the value. I deleted the sensor from HomeAssistant and restarted, when it came back in again it started from zero.

            martinhjelmareM 1 Reply Last reply
            0
            • maghacM maghac

              It appears to be the controller that stores the value. I deleted the sensor from HomeAssistant and restarted, when it came back in again it started from zero.

              martinhjelmareM Offline
              martinhjelmareM Offline
              martinhjelmare
              Plugin Developer
              wrote on last edited by
              #53

              @maghac

              This is a hack, but if using json persistence, you can set the count in the JSON file and restart home assistant, with the node turned off. Then turn on the node.

              maghacM 1 Reply Last reply
              0
              • martinhjelmareM martinhjelmare

                @maghac

                This is a hack, but if using json persistence, you can set the count in the JSON file and restart home assistant, with the node turned off. Then turn on the node.

                maghacM Offline
                maghacM Offline
                maghac
                wrote on last edited by
                #54

                @martinhjelmare Yep, I figured I could do that. The absolute value is not so important actually, I'm more interested in the daily/weekly delta, which I hope Grafana can tell me.

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

                  is this the same sensor than the one in the guide?
                  http://uk.farnell.com/ams/tsl250r-lf/photodiode-sensor-l-volts/dp/1182346

                  Can I also use also photoresistor? (Since I already have one)

                  sundberg84S 1 Reply Last reply
                  0
                  • gohanG gohan

                    is this the same sensor than the one in the guide?
                    http://uk.farnell.com/ams/tsl250r-lf/photodiode-sensor-l-volts/dp/1182346

                    Can I also use also photoresistor? (Since I already have one)

                    sundberg84S Offline
                    sundberg84S Offline
                    sundberg84
                    Hardware Contributor
                    wrote on last edited by sundberg84
                    #56

                    @gohan - nope its not the same, and yes you can use a photoresistor (i have just made one) but I needed a transistor for it to work and also it had to be completley dark. Using this on batteries its much better using just a photoresistor because the sensor in the guide draws about 1mA which will drain the batteris very quickly.

                    I will post my sensor later.

                    Edit: this is the sensor i build:

                    0_1486915502085_1.jpg
                    0_1486915592318_20170212_135834.jpg

                    The node (including pro mini) draws about 50uA sleeping and 170uA not sleeping.
                    The photoresistor was 5M ohm in complete dark.

                    Controller: Proxmox VM - Home Assistant
                    MySensors GW: Arduino Uno - W5100 Ethernet, Gw Shield Nrf24l01+ 2,4Ghz
                    MySensors GW: Arduino Uno - Gw Shield RFM69, 433mhz
                    RFLink GW - Arduino Mega + RFLink Shield, 433mhz

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

                      The guide specifies LM393 Light Sensor or the tsl250r-lf so I thought it was the same since the same name.
                      Since the node will be powered with it's power supply, I don't have any battery drain problem in this case. But why did you use a transistor? Can't you just check for a threshold value in the analog input to count as a pulse?

                      sundberg84S 1 Reply Last reply
                      0
                      • gohanG gohan

                        The guide specifies LM393 Light Sensor or the tsl250r-lf so I thought it was the same since the same name.
                        Since the node will be powered with it's power supply, I don't have any battery drain problem in this case. But why did you use a transistor? Can't you just check for a threshold value in the analog input to count as a pulse?

                        sundberg84S Offline
                        sundberg84S Offline
                        sundberg84
                        Hardware Contributor
                        wrote on last edited by sundberg84
                        #58

                        Ok, all I can see is that it doesnt look the same at all.
                        @gohan - I tried, and I thought that should work - but for some reason I could not get it to trigger the interupt on the atmega :(
                        Looking the the voltage thresholds it was supposed to work but it didnt. I was thinking it was to low uA but i dont know really.

                        Controller: Proxmox VM - Home Assistant
                        MySensors GW: Arduino Uno - W5100 Ethernet, Gw Shield Nrf24l01+ 2,4Ghz
                        MySensors GW: Arduino Uno - Gw Shield RFM69, 433mhz
                        RFLink GW - Arduino Mega + RFLink Shield, 433mhz

                        gohanG 1 Reply Last reply
                        1
                        • F Offline
                          F Offline
                          flopp
                          wrote on last edited by
                          #59

                          This is what I use togeheter with LM393
                          https://www.kjell.com/se/sortiment/el-verktyg/elektronik/optokomponenter/ir-dioder-fototransistorer/fototransistor-p90042

                          1 Reply Last reply
                          0
                          • sundberg84S sundberg84

                            Ok, all I can see is that it doesnt look the same at all.
                            @gohan - I tried, and I thought that should work - but for some reason I could not get it to trigger the interupt on the atmega :(
                            Looking the the voltage thresholds it was supposed to work but it didnt. I was thinking it was to low uA but i dont know really.

                            gohanG Offline
                            gohanG Offline
                            gohan
                            Mod
                            wrote on last edited by gohan
                            #60

                            @sundberg84

                            Instead of the 10k resistor, do you think I could use a potentiometer to "adjust" sensitivity? I would like to avoid messing up the readings with lights entering when opening the cabinet door where the meter is located

                            @flopp
                            Do you mind sharing your wiring? 940nm, isn't it infrared?

                            sundberg84S F 2 Replies Last reply
                            0
                            • gohanG gohan

                              @sundberg84

                              Instead of the 10k resistor, do you think I could use a potentiometer to "adjust" sensitivity? I would like to avoid messing up the readings with lights entering when opening the cabinet door where the meter is located

                              @flopp
                              Do you mind sharing your wiring? 940nm, isn't it infrared?

                              sundberg84S Offline
                              sundberg84S Offline
                              sundberg84
                              Hardware Contributor
                              wrote on last edited by
                              #61

                              @gohan - a potentiometer is just a variable resistor so why not? Good idea if you have one laying around.
                              As i said before though, the try with the transistor is just a try - im not that good with transistors yet and dont know how they work exactly. After this i read somewhere that the base resistor should be bigger to protect the transistor... dont know how to calculate that.

                              Controller: Proxmox VM - Home Assistant
                              MySensors GW: Arduino Uno - W5100 Ethernet, Gw Shield Nrf24l01+ 2,4Ghz
                              MySensors GW: Arduino Uno - Gw Shield RFM69, 433mhz
                              RFLink GW - Arduino Mega + RFLink Shield, 433mhz

                              1 Reply Last reply
                              0
                              • gohanG gohan

                                @sundberg84

                                Instead of the 10k resistor, do you think I could use a potentiometer to "adjust" sensitivity? I would like to avoid messing up the readings with lights entering when opening the cabinet door where the meter is located

                                @flopp
                                Do you mind sharing your wiring? 940nm, isn't it infrared?

                                F Offline
                                F Offline
                                flopp
                                wrote on last edited by flopp
                                #62

                                @gohan said in 💬 Power Meter Pulse Sensor:

                                @sundberg84

                                @flopp
                                Do you mind sharing your wiring? 940nm, isn't it infrared?

                                I connected the photo resistor directly to the LM393.
                                I don't know if that is IR.

                                1 Reply Last reply
                                0
                                • moumout31M Offline
                                  moumout31M Offline
                                  moumout31
                                  wrote on last edited by
                                  #63

                                  Hello,

                                  First, thanks for this tutorial !
                                  I used the code defined in tutorial but I have the following message for "void receive(const MyMessage &message)" :

                                  'MyMessage' does not name a type
                                  

                                  Do you know what can be the cause of this error please ?

                                  Thanks in advance for your help

                                  mfalkviddM 1 Reply Last reply
                                  0
                                  • moumout31M moumout31

                                    Hello,

                                    First, thanks for this tutorial !
                                    I used the code defined in tutorial but I have the following message for "void receive(const MyMessage &message)" :

                                    'MyMessage' does not name a type
                                    

                                    Do you know what can be the cause of this error please ?

                                    Thanks in advance for your help

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

                                    @moumout31 do you have void receive(const MyMessage &message) somewhere in your code or where does it come from?
                                    Could you post the full error message?

                                    Have you installed the MySensors library?

                                    moumout31M 1 Reply Last reply
                                    1
                                    • mfalkviddM mfalkvidd

                                      @moumout31 do you have void receive(const MyMessage &message) somewhere in your code or where does it come from?
                                      Could you post the full error message?

                                      Have you installed the MySensors library?

                                      moumout31M Offline
                                      moumout31M Offline
                                      moumout31
                                      wrote on last edited by moumout31
                                      #65

                                      @mfalkvidd void receive(const MyMessage &message) is in the code.
                                      MySensors library is installed, I already use it in other nodes.
                                      It's strange because it works in another computer...

                                      The full error messages, in french beacause I'm french are :

                                      Arduino : 1.8.0 (Windows 7), Carte : "Arduino Pro or Pro Mini, ATmega328 (3.3V, 8 MHz)"
                                      
                                      _02_Main_loop:271: error: 'MyMessage' does not name a type
                                      
                                      In file included from C:\Users\Anne-Laure\Documents\Arduino\libraries\arduino_759467/MySensors.h:257:0,
                                      
                                                       from C:\Users\Anne-Laure\Dropbox\Maison\A récupérer sur OneDrive\my_teleinfo_light\_02_Main_loop.ino:118:
                                      
                                      C:\Users\Anne-Laure\Documents\Arduino\libraries\arduino_759467/core/MyTransport.cpp: In function 'void transportProcessMessage()':
                                      
                                      C:\Users\Anne-Laure\Documents\Arduino\libraries\arduino_759467/core/MyTransport.cpp:745:14: error: cannot resolve overloaded function 'receive' based on conversion to type 'bool'
                                      
                                         if (receive) {
                                      
                                                    ^
                                      
                                      C:\Users\Anne-Laure\Documents\Arduino\libraries\arduino_759467/core/MyTransport.cpp:811:15: error: cannot resolve overloaded function 'receive' based on conversion to type 'bool'
                                      
                                          if (receive) {
                                      
                                                     ^
                                      
                                      exit status 1
                                      'MyMessage' does not name a type
                                      
                                      Bibliothèque non valide trouvée dans C:\Users\Anne-Laure\Documents\Arduino\libraries\MySensors : C:\Users\Anne-Laure\Documents\Arduino\libraries\MySensors
                                      
                                      Ce rapport pourrait être plus détaillé avec
                                      l'option "Afficher les résultats détaillés de la compilation"
                                      activée dans Fichier -> Préférences.
                                      

                                      Thanks for your help

                                      mfalkviddM 1 Reply Last reply
                                      0
                                      • moumout31M moumout31

                                        @mfalkvidd void receive(const MyMessage &message) is in the code.
                                        MySensors library is installed, I already use it in other nodes.
                                        It's strange because it works in another computer...

                                        The full error messages, in french beacause I'm french are :

                                        Arduino : 1.8.0 (Windows 7), Carte : "Arduino Pro or Pro Mini, ATmega328 (3.3V, 8 MHz)"
                                        
                                        _02_Main_loop:271: error: 'MyMessage' does not name a type
                                        
                                        In file included from C:\Users\Anne-Laure\Documents\Arduino\libraries\arduino_759467/MySensors.h:257:0,
                                        
                                                         from C:\Users\Anne-Laure\Dropbox\Maison\A récupérer sur OneDrive\my_teleinfo_light\_02_Main_loop.ino:118:
                                        
                                        C:\Users\Anne-Laure\Documents\Arduino\libraries\arduino_759467/core/MyTransport.cpp: In function 'void transportProcessMessage()':
                                        
                                        C:\Users\Anne-Laure\Documents\Arduino\libraries\arduino_759467/core/MyTransport.cpp:745:14: error: cannot resolve overloaded function 'receive' based on conversion to type 'bool'
                                        
                                           if (receive) {
                                        
                                                      ^
                                        
                                        C:\Users\Anne-Laure\Documents\Arduino\libraries\arduino_759467/core/MyTransport.cpp:811:15: error: cannot resolve overloaded function 'receive' based on conversion to type 'bool'
                                        
                                            if (receive) {
                                        
                                                       ^
                                        
                                        exit status 1
                                        'MyMessage' does not name a type
                                        
                                        Bibliothèque non valide trouvée dans C:\Users\Anne-Laure\Documents\Arduino\libraries\MySensors : C:\Users\Anne-Laure\Documents\Arduino\libraries\MySensors
                                        
                                        Ce rapport pourrait être plus détaillé avec
                                        l'option "Afficher les résultats détaillés de la compilation"
                                        activée dans Fichier -> Préférences.
                                        

                                        Thanks for your help

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

                                        @moumout31 My guess is that MyMessage is defined in your sketch, overriding the definition in the MySensors library. Could you post your sketch?

                                        moumout31M 1 Reply Last reply
                                        0
                                        • mfalkviddM mfalkvidd

                                          @moumout31 My guess is that MyMessage is defined in your sketch, overriding the definition in the MySensors library. Could you post your sketch?

                                          moumout31M Offline
                                          moumout31M Offline
                                          moumout31
                                          wrote on last edited by
                                          #67

                                          @mfalkvidd It's strange... It works with an older version of Arduino software... Thus, the problem is solved ! Thanks

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


                                          15

                                          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