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. Troubleshooting
  3. Custom power meter

Custom power meter

Scheduled Pinned Locked Moved Troubleshooting
31 Posts 15 Posters 30.3k Views 14 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.
  • M Offline
    M Offline
    maglo18
    wrote on last edited by maglo18
    #1

    I created a power meter based on emoncms. My code does not work quite correctly. When I run not everything is fine, but after reboot gets below the value of information and does not update.

    10-12-2014 12:02:57: 0;0;3;0;9;send: 0-0-6-6 s=255,c=3,t=8,pt=1,l=1,st=fail:0
    10-12-2014 12:02:56: 0;0;3;0;9;read: 6-6-255 s=255,c=3,t=7,pt=0,l=0:
    10-12-2014 12:02:36: 0;0;3;0;9;send: 0-0-6-6 s=255,c=3,t=8,pt=1,l=1,st=fail:0
    10-12-2014 12:02:36: 0;0;3;0;9;read: 6-6-255 s=255,c=3,t=7,pt=0,l=0:
    10-12-2014 12:02:16: 0;0;3;0;9;send: 0-0-6-6 s=255,c=3,t=8,pt=1,l=1,st=fail:0

    My sketch:. If i can improve code help me please

    // EmonLibrary examples openenergymonitor.org, Licence GNU GPL V3
     ***/
    #include <SPI.h>
    #include <MySensor.h>  
    #include "EmonLib.h"             // Include Emon Library
    EnergyMonitor emon1;             // Create an instance
    EnergyMonitor emon2;             // Create an instance
    EnergyMonitor emon3;             // Create an instance
    #define CHILD_ID 0  
    #define CHILD_ID2 1  
    #define CHILD_ID3 2  
    MySensor gw;
    unsigned long lastSend;
    unsigned long SEND_FREQUENCY = 20000; // Minimum time between send (in milliseconds). We don't wnat to spam the gateway.
    
    MyMessage realPowerMsg(CHILD_ID,V_VAR1);
    MyMessage apparentPowerMsg(CHILD_ID,V_VAR2);
    MyMessage powerFActorMsg(CHILD_ID,V_VAR3);
    MyMessage supplyVoltageMsg(CHILD_ID,V_VAR4);
    MyMessage IrmsMsg(CHILD_[link text](CHILD_ID,V_VAR5);
    
    MyMessage realPowerMsg2(CHILD_ID2,V_VAR1);
    MyMessage apparentPowerMsg2(CHILD_ID2,V_VAR2);
    MyMessage powerFActorMsg2(CHILD_ID2,V_VAR3);
    MyMessage supplyVoltageMsg2(CHILD_ID2,V_VAR4);
    MyMessage IrmsMsg2(CHILD_ID2,V_VAR5);
    
    MyMessage realPowerMsg3(CHILD_ID3,V_VAR1);
    MyMessage apparentPowerMsg3(CHILD_ID3,V_VAR2);
    MyMessage powerFActorMsg3(CHILD_ID3,V_VAR3);
    MyMessage supplyVoltageMsg3(CHILD_ID3,V_VAR4);
    MyMessage IrmsMsg3(CHILD_ID3,V_VAR5);
    
    
    void setup()
    {  
      gw.begin();
    
      // Send the sketch version information to the gateway and Controller
      gw.sendSketchInfo("Energy Meter x 3", "2.0");
    
      // Register this device as power sensor
      gw.present(CHILD_ID, S_POWER);
      gw.present(CHILD_ID2, S_POWER);
      gw.present(CHILD_ID3, S_POWER);
    
    
      emon1.voltage(A3, 116.26, 1.7);  // Voltage: input pin, calibration, phase_shift
      emon1.current(A0, 29.1);       // Current: input pin, calibration.
      emon2.voltage(A4, 116.76, 1.7);  // Voltage: input pin, calibration, phase_shift
      emon2.current(A1, 29.1);       // Current: input pin, calibration.
      emon3.voltage(A5, 116.46, 1.7);  // Voltage: input pin, calibration, phase_shift
      emon3.current(A2, 29.1);       // Current: input pin, calibration.
    }
    
    void loop()
    {
      gw.process();
      unsigned long now = millis();
      emon1.calcVI(20,2000);         // Calculate all. No.of half wavelengths (crossings), time-out
      //emon1.serialprint();           // Print out all variables (realpower, apparent power, Vrms, Irms, power factor)
      emon2.calcVI(20,2000);         // Calculate all. No.of half wavelengths (crossings), time-out
      //emon2.serialprint();           // Print out all variables (realpower, apparent power, Vrms, Irms, power factor)
      emon3.calcVI(20,2000);         // Calculate all. No.of half wavelengths (crossings), time-out
      //emon3.serialprint();           // Print out all variables (realpower, apparent power, Vrms, Irms, power factor)
      bool sendTime = now - lastSend > SEND_FREQUENCY;
      if (sendTime) { 
    
        float realPower       = emon1.realPower;        //extract Real Power into variable
        float apparentPower   = emon1.apparentPower;    //extract Apparent Power into variable
        float powerFactor     = emon1.powerFactor;      //extract Power Factor into Variable
        float supplyVoltage   = emon1.Vrms;             //extract Vrms into Variable
        float Irms            = emon1.Irms;             //extract Irms into Variable
        
        float realPower2       = emon2.realPower;        //extract Real Power into variable
        float apparentPower2   = emon2.apparentPower;    //extract Apparent Power into variable
        float powerFactor2     = emon2.powerFactor;      //extract Power Factor into Variable
        float supplyVoltage2   = emon2.Vrms;             //extract Vrms into Variable
        float Irms2            = emon2.Irms;             //extract Irms into Variable
        
        float realPower3       = emon3.realPower;        //extract Real Power into variable
        float apparentPower3   = emon3.apparentPower;    //extract Apparent Power into variable
        float powerFactor3     = emon3.powerFactor;      //extract Power Factor into Variable
        float supplyVoltage3   = emon3.Vrms;             //extract Vrms into Variable
        float Irms3            = emon3.Irms;             //extract Irms into Variable
    
        gw.send(realPowerMsg.set(realPower,1));
        gw.send(apparentPowerMsg.set(apparentPower,1));
        gw.send(powerFActorMsg.set(powerFactor,1));
        gw.send(supplyVoltageMsg.set(supplyVoltage,1));
        gw.send(IrmsMsg.set(Irms,1));
    
        gw.send(realPowerMsg2.set(realPower2,1));
        gw.send(apparentPowerMsg2.set(apparentPower2,1));
        gw.send(powerFActorMsg2.set(powerFactor2,1));
        gw.send(supplyVoltageMsg2.set(supplyVoltage2,1));
        gw.send(IrmsMsg2.set(Irms2,1));
    
        gw.send(realPowerMsg3.set(realPower3,1));
        gw.send(apparentPowerMsg3.set(apparentPower3,1));
        gw.send(powerFActorMsg3.set(powerFactor3,1));
        gw.send(supplyVoltageMsg3.set(supplyVoltage3,1));
        gw.send(IrmsMsg3.set(Irms3,1));
        
        lastSend = now;
      }
    
    }
    
    1 Reply Last reply
    0
    • gigiG Offline
      gigiG Offline
      gigi
      wrote on last edited by
      #2

      I have emon energymonitor but trasmission is with RFM12B radio!!!

      emonTx_V2.0 overview_0.png

      Vera lite - mysensors Ethernet gateway - AirWik sensor - Relay Module

      1 Reply Last reply
      0
      • G Offline
        G Offline
        Gambituk
        wrote on last edited by
        #3

        Hi, any progress with this? I would be interested in trying to adapt this to my needs. I have just finished setting up the basic arduino sketch from http://openenergymonitor.org/emon/buildingblocks/how-to-build-an-arduino-energy-monitor-measuring-current-only

        and i assume this should just work with the sketch you are working on?

        M 1 Reply Last reply
        0
        • G Gambituk

          Hi, any progress with this? I would be interested in trying to adapt this to my needs. I have just finished setting up the basic arduino sketch from http://openenergymonitor.org/emon/buildingblocks/how-to-build-an-arduino-energy-monitor-measuring-current-only

          and i assume this should just work with the sketch you are working on?

          M Offline
          M Offline
          maglo18
          wrote on last edited by
          #4

          My hardware is on photo. I prepare hardware from emoncms site for 3 phases. My sketh working good so far about 3 weeks. My controler is pidome and send values to emoncms on mys NAS.

          20150123_214231.jpg
          obllcov.jpg
          ltbnanr.jpg
          20150125_191907.jpg

          B RJ_MakeR 2 Replies Last reply
          2
          • M maglo18

            My hardware is on photo. I prepare hardware from emoncms site for 3 phases. My sketh working good so far about 3 weeks. My controler is pidome and send values to emoncms on mys NAS.

            20150123_214231.jpg
            obllcov.jpg
            ltbnanr.jpg
            20150125_191907.jpg

            B Offline
            B Offline
            boozz
            wrote on last edited by
            #5

            @maglo18
            Please put back the plastic cover :-)

            Looks good btw

            Boozz

            1 Reply Last reply
            0
            • M maglo18

              My hardware is on photo. I prepare hardware from emoncms site for 3 phases. My sketh working good so far about 3 weeks. My controler is pidome and send values to emoncms on mys NAS.

              20150123_214231.jpg
              obllcov.jpg
              ltbnanr.jpg
              20150125_191907.jpg

              RJ_MakeR Offline
              RJ_MakeR Offline
              RJ_Make
              Hero Member
              wrote on last edited by
              #6

              @maglo18 Is that 3 transformers in that box?

              RJ_Make

              M 1 Reply Last reply
              0
              • RJ_MakeR RJ_Make

                @maglo18 Is that 3 transformers in that box?

                M Offline
                M Offline
                maglo18
                wrote on last edited by
                #7

                @ServiceXp In the box are 3 transformer, one for each phase to measure the voltage

                gigiG 1 Reply Last reply
                0
                • M maglo18

                  @ServiceXp In the box are 3 transformer, one for each phase to measure the voltage

                  gigiG Offline
                  gigiG Offline
                  gigi
                  wrote on last edited by gigi
                  #8

                  @maglo18 How to transmit data to emoncms?

                  Vera lite - mysensors Ethernet gateway - AirWik sensor - Relay Module

                  1 Reply Last reply
                  0
                  • M Offline
                    M Offline
                    maglo18
                    wrote on last edited by
                    #9

                    I use Pidome server and by automation rule send values to emoncms..

                    1 Reply Last reply
                    0
                    • T Offline
                      T Offline
                      tbully
                      wrote on last edited by
                      #10

                      Hello,

                      I've been looking in to this for quite some time. Here in the US, our residential wiring is usually 220V "split-phase" where we have a neutral/ground connection that allows us to get 120V from either "leg" (not to be confused with phase) to "ground". If you go "leg to leg", you'll get the full 220V of the phase.

                      I've been searching quite a bit and am a little confused so I was hoping that you could expand on your solution a bit. (schematics, part numbers, full sketch) Your efforts look great. I'm wondering how you've integrated in to MySensors (and your controller, Vera?)

                      In my case, I think that I will need to do the following:

                      1. Have two CT's - one for each leg
                      2. Have two transformers to measure each leg to neutral
                      3. Somehow convert the voltage-measurement transformers in to something Arduino can read (0-5V)
                      4. Convert the current induced by the CTs to a voltage that the Arduino can read
                      5. Do the "V*I" math to calculate power, etc.

                      Most US based solutions call for only one transformer/leg-measurement. However, I have seen an imbalance in my utility power. I'm not sure if this is due to underground resistance, faulty utility transformers, etc. But my point is, I think it'd be safer to measure both, do my calculations separately, and then add them accordingly (in software) to get total power consumption.

                      Can you expand a bit on my thoughts? Has anyone in the US been successful in my above approach?

                      1 Reply Last reply
                      0
                      • epierreE Offline
                        epierreE Offline
                        epierre
                        Hero Member
                        wrote on last edited by
                        #11

                        @maglo18 why do you need a transformer ? my owl ones work on battery, couldn't that simplpify the sketch ?

                        z-wave - Vera -&gt; Domoticz
                        rfx - Domoticz &lt;- MyDomoAtHome &lt;- Imperihome
                        mysensors -&gt; mysensors-gw -&gt; Domoticz

                        1 Reply Last reply
                        0
                        • M Offline
                          M Offline
                          maglo18
                          wrote on last edited by
                          #12

                          I use transformer to measure voltage on each from three phases

                          epierreE 1 Reply Last reply
                          0
                          • chatainsimC Offline
                            chatainsimC Offline
                            chatainsim
                            wrote on last edited by
                            #13

                            @maglo18 how many is your burden resistor ?
                            If found a blog where he talk about of turn in the sensor, do you know how many is it ?
                            http://www.homautomation.org/2013/09/17/current-monitoring-with-non-invasive-sensor-and-arduino/

                            1 Reply Last reply
                            0
                            • DidiD Offline
                              DidiD Offline
                              Didi
                              wrote on last edited by
                              #14

                              @maglo18

                              please explain how to use one transformer on 3 phases to measure voltage on each

                              if (knowledge == 0) { use BRAIN; use GOOGLE;use SEARCH; } else {make POST;}

                              1 Reply Last reply
                              0
                              • M maglo18

                                I use transformer to measure voltage on each from three phases

                                epierreE Offline
                                epierreE Offline
                                epierre
                                Hero Member
                                wrote on last edited by
                                #15

                                @maglo18 said:

                                I use transformer to measure voltage on each from three phases

                                I have at home some OWL CM180i that work on batteries... how can it be applied to the example here ?

                                z-wave - Vera -&gt; Domoticz
                                rfx - Domoticz &lt;- MyDomoAtHome &lt;- Imperihome
                                mysensors -&gt; mysensors-gw -&gt; Domoticz

                                1 Reply Last reply
                                0
                                • M Offline
                                  M Offline
                                  maglo18
                                  wrote on last edited by
                                  #16

                                  I use 3 x transformers One for each phase

                                  1 Reply Last reply
                                  0
                                  • DidiD Offline
                                    DidiD Offline
                                    Didi
                                    wrote on last edited by
                                    #17

                                    @maglo18 said:

                                    I use 3 x transformers One for each phase

                                    Sorry for me it sounds like you use 1 transformer that was confusing me ;-)

                                    if (knowledge == 0) { use BRAIN; use GOOGLE;use SEARCH; } else {make POST;}

                                    1 Reply Last reply
                                    0
                                    • E Offline
                                      E Offline
                                      ewgor
                                      wrote on last edited by
                                      #18

                                      Have anyone integrated this with Openhab? can we find somwhere some Openhab items, rules for this sketch that @maglo18 posted here http://forum.mysensors.org/topic/1464/sct-013-030-current-monitor-sensor?
                                      Thanks for any help!

                                      1 Reply Last reply
                                      0
                                      • G Offline
                                        G Offline
                                        Gambituk
                                        wrote on last edited by
                                        #19

                                        Hi @maglo18 i have been using a current only version of emon for quite some time, i am interested in adding the ac-ac transformer to calculate the apparent power more accurately. Do you have a project page for your build with diagrams and specs? What type of transformers are you using (i can just about read it from picture) and how happy are you with the performance?

                                        Thanks Gambituk

                                        1 Reply Last reply
                                        0
                                        • E Offline
                                          E Offline
                                          ewgor
                                          wrote on last edited by ewgor
                                          #20

                                          Hi All,

                                          Did anyone worked with this sensor SCT-013-000 and Openhab? I would like to ask how can I integrate this with Openhab so to be able to display the apparent power consumption in watts, to display the Kwh starting a certain date lets say starting on 12th this month or from today as for example and to display to total Kwh.
                                          @maglo18 where are you from?

                                          Any help or suggestion will be kindly appreciated.

                                          Thanks All!

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


                                          12

                                          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