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. Hardware
  3. SCT-013-030 current monitor sensor

SCT-013-030 current monitor sensor

Scheduled Pinned Locked Moved Hardware
65 Posts 16 Posters 50.8k Views 15 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
    #12

    In Emonlib you have example to measure watt etc. without measure voltage.
    https://github.com/openenergymonitor/EmonLib

    1 Reply Last reply
    0
    • rvendrameR rvendrame

      @chatainsim, if you know the Voltage, just multiply the voltage by the amperage and you will have the wattage...

      http://en.wikipedia.org/wiki/Ohm's_law

      chatainsimC Offline
      chatainsimC Offline
      chatainsim
      wrote on last edited by
      #13

      @rvendrame Thanks, I will try this.
      @maglo18 I will try to use some example.
      First I need to check if my sketch and my assemble works at least.

      Thanks for your help. I think I will need more from you guys !

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

        Hello guys,

        I've working on my sensor.
        It's seems working, but I have some trouble with Watt or Kwh.

        Here is the sketch:

        // 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
        #define CHILD_ID 0 
        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 IrmsMsg(CHILD_ID,V_WATT);
        void setup()
        {  
          gw.begin();
        
          // Send the sketch version information to the gateway and Controller
          gw.sendSketchInfo("Energy Meter", "1.0");
        
          // Register this device as power sensor
          gw.present(CHILD_ID, S_POWER);
          emon1.current(A0, 29.0);       // Current: input pin, calibration.
        }
        
        void loop()
        {
          gw.process();
          unsigned long now = millis();
          double Irms = emon1.calcIrms(1480);
          //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)
          bool sendTime = now - lastSend > SEND_FREQUENCY;
          if (sendTime) { 
            //float Irms = emon1.Irms;             //extract Irms into Variable
            gw.send(IrmsMsg.set(Irms*232.0,1));
            Serial.println(Irms*232.0);
            lastSend = now;
          }
        }
        

        I've got around 390 for the Irms*232, do you thinks it's a correct value ?
        Can I calculated the current kwh with the ampere ?

        Thank you.

        AWIA 1 Reply Last reply
        0
        • chatainsimC Offline
          chatainsimC Offline
          chatainsim
          wrote on last edited by
          #15

          Hello,

          I've made some change in the code :

          // 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
          #define CHILD_ID_WATT 0
          #define CHILD_ID_KWH 1
          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 IrmsMsg(CHILD_ID_WATT,V_WATT);
          MyMessage kWhMsg(CHILD_ID_KWH,V_KWH);
          void setup()
          {  
            gw.begin();
            gw.sendSketchInfo("Energy Meter", "1.0");  // Send the sketch version information to the gateway and Controller
            gw.present(CHILD_ID_WATT, S_POWER);  // Register this device as power sensor
            gw.present(CHILD_ID_KWH, S_POWER);
            emon1.current(A0, 29.0);       // Current: input pin, calibration.
          }
          
          void loop()
          {
            gw.process();
            unsigned long now = millis();
            //emon1.serialprint();           // Print out all variables (realpower, apparent power, Vrms, Irms, power factor)
            double Irms = emon1.calcIrms(1480);
            bool sendTime = now - lastSend > SEND_FREQUENCY;
            if (sendTime) {
              gw.send(IrmsMsg.set((Irms*232.0)*1000, 1));
          //    Serial.print("Watt: ");
          //    Serial.println(Irms*232.0);
              gw.send(kWhMsg.set((Irms*232.0)/1000, 1));
          //    Serial.print("kWH: ");
          //    Serial.println((Irms*232.0)/1000);
              lastSend = now;
            }
          }
          

          But in Domoticz, I've two line for this but in kWh and not on in kWh and other in Watt :
          Capture.PNG

          Do you know why ?

          Regards,

          1 Reply Last reply
          0
          • chatainsimC chatainsim

            Hello guys,

            I've working on my sensor.
            It's seems working, but I have some trouble with Watt or Kwh.

            Here is the sketch:

            // 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
            #define CHILD_ID 0 
            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 IrmsMsg(CHILD_ID,V_WATT);
            void setup()
            {  
              gw.begin();
            
              // Send the sketch version information to the gateway and Controller
              gw.sendSketchInfo("Energy Meter", "1.0");
            
              // Register this device as power sensor
              gw.present(CHILD_ID, S_POWER);
              emon1.current(A0, 29.0);       // Current: input pin, calibration.
            }
            
            void loop()
            {
              gw.process();
              unsigned long now = millis();
              double Irms = emon1.calcIrms(1480);
              //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)
              bool sendTime = now - lastSend > SEND_FREQUENCY;
              if (sendTime) { 
                //float Irms = emon1.Irms;             //extract Irms into Variable
                gw.send(IrmsMsg.set(Irms*232.0,1));
                Serial.println(Irms*232.0);
                lastSend = now;
              }
            }
            

            I've got around 390 for the Irms*232, do you thinks it's a correct value ?
            Can I calculated the current kwh with the ampere ?

            Thank you.

            AWIA Offline
            AWIA Offline
            AWI
            Hero Member
            wrote on last edited by
            #16

            @chatainsim Domoticz does not have a different device for power (Watt) and energy(kWh) but combines them in a single device. What you need to do is send both the power and energy to the same child.

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

              Thanks, but I've already test this and only the kWh is updated in domoticz, not watt.

              // 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
              #define CHILD_ID 0
              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 IrmsMsg(CHILD_ID,V_WATT);
              MyMessage kWhMsg(CHILD_ID,V_KWH);
              void setup()
              {  
                gw.begin();
                gw.sendSketchInfo("Energy Meter", "1.0");  // Send the sketch version information to the gateway and Controller
                gw.present(CHILD_ID, S_POWER);  // Register this device as power sensor
                emon1.current(A0, 29.0);       // Current: input pin, calibration.
              }
              
              void loop()
              {
                gw.process();
                unsigned long now = millis();
                //emon1.serialprint();           // Print out all variables (realpower, apparent power, Vrms, Irms, power factor)
                double Irms = emon1.calcIrms(1480);
                bool sendTime = now - lastSend > SEND_FREQUENCY;
                if (sendTime) {
                  gw.send(IrmsMsg.set((Irms*232.0)*1000, 1));
              //    Serial.print("Watt: ");
              //    Serial.println(Irms*232.0);
                  gw.send(kWhMsg.set((Irms*232.0)/1000, 1));
              //    Serial.print("kWH: ");
              //    Serial.println((Irms*232.0)/1000);
                  lastSend = now;
                }
              }
              

              Can you help me with this ?

              Thanks

              AWIA 1 Reply Last reply
              0
              • chatainsimC chatainsim

                Thanks, but I've already test this and only the kWh is updated in domoticz, not watt.

                // 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
                #define CHILD_ID 0
                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 IrmsMsg(CHILD_ID,V_WATT);
                MyMessage kWhMsg(CHILD_ID,V_KWH);
                void setup()
                {  
                  gw.begin();
                  gw.sendSketchInfo("Energy Meter", "1.0");  // Send the sketch version information to the gateway and Controller
                  gw.present(CHILD_ID, S_POWER);  // Register this device as power sensor
                  emon1.current(A0, 29.0);       // Current: input pin, calibration.
                }
                
                void loop()
                {
                  gw.process();
                  unsigned long now = millis();
                  //emon1.serialprint();           // Print out all variables (realpower, apparent power, Vrms, Irms, power factor)
                  double Irms = emon1.calcIrms(1480);
                  bool sendTime = now - lastSend > SEND_FREQUENCY;
                  if (sendTime) {
                    gw.send(IrmsMsg.set((Irms*232.0)*1000, 1));
                //    Serial.print("Watt: ");
                //    Serial.println(Irms*232.0);
                    gw.send(kWhMsg.set((Irms*232.0)/1000, 1));
                //    Serial.print("kWH: ");
                //    Serial.println((Irms*232.0)/1000);
                    lastSend = now;
                  }
                }
                

                Can you help me with this ?

                Thanks

                AWIA Offline
                AWIA Offline
                AWI
                Hero Member
                wrote on last edited by
                #18

                @chatainsim I am pretty sure it is a combined device which shows Watt only when added ...:
                upload-40825a2f-8628-4412-8fdb-44b222576843

                upload-11b440e7-718e-46ae-87f1-a4eb3c913c7e

                upload-408228f1-e921-418e-bae9-db19b6d47eee

                Although I am not sure if the Domoticz MySensors plug-in handles it right (I'm still using my own script).

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

                  Ok, thanks.
                  How do you get your watt info ? With teleinfo ?

                  AWIA 1 Reply Last reply
                  0
                  • chatainsimC chatainsim

                    Ok, thanks.
                    How do you get your watt info ? With teleinfo ?

                    AWIA Offline
                    AWIA Offline
                    AWI
                    Hero Member
                    wrote on last edited by
                    #20

                    @chatainsim
                    I send the V_Watt messages from the Power meter to Domoticz.

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

                      @AWI

                      MyMessage IrmsMsg(CHILD_ID,V_WATT);
                      MyMessage kWhMsg(CHILD_ID,V_KWH);

                      I also send both data but it's seems that Domoticz is ingnoring it !
                      I don't know why.

                      AWIA 1 Reply Last reply
                      0
                      • chatainsimC chatainsim

                        @AWI

                        MyMessage IrmsMsg(CHILD_ID,V_WATT);
                        MyMessage kWhMsg(CHILD_ID,V_KWH);

                        I also send both data but it's seems that Domoticz is ingnoring it !
                        I don't know why.

                        AWIA Offline
                        AWIA Offline
                        AWI
                        Hero Member
                        wrote on last edited by
                        #22

                        @chatainsim Sounds you like you need to consult the Domoticz forum. The Domoticz code shows that is interpreted.

                        case V_WATT:
                        		{
                        			_tMySensorSensor *pSensorKwh = FindSensor(pSensor->nodeID, V_KWH);
                        			if (pSensorKwh) {
                        				SendKwhMeter(pSensorKwh->nodeID, pSensorKwh->childID, pSensorKwh->batValue, pSensor->floatValue / 1000.0f, pSensorKwh->floatValue, "Meter");
                        			}
                        			else {
                        				_tUsageMeter umeter;
                        				umeter.id1 = 0;
                        				umeter.id2 = 0;
                        				umeter.id3 = 0;
                        				umeter.id4 = pSensor->nodeID;
                        				umeter.dunit = pSensor->childID;
                        				umeter.fusage = pSensor->floatValue/1000.0f;
                        				sDecodeRXMessage(this, (const unsigned char *)&umeter);
                        			}
                        		}
                        		break;
                        	case V_KWH:
                        		{
                        			_tMySensorSensor *pSensorWatt = FindSensor(pSensor->nodeID, V_WATT);
                        			if (pSensorWatt) {
                        				SendKwhMeter(pSensor->nodeID, pSensor->childID, pSensor->batValue, pSensorWatt->floatValue / 1000.0f, pSensor->floatValue, "Meter");
                        			}
                        			else {
                        				SendKwhMeter(pSensor->nodeID, pSensor->childID, pSensor->batValue, 0, pSensor->floatValue, "Meter");
                        			}
                        		}
                        		break;```
                        1 Reply Last reply
                        0
                        • E Offline
                          E Offline
                          ewgor
                          wrote on last edited by
                          #23

                          Does anyone have some OpenHab items and rules for @chatainsim sketch posted above? I have a SCT-013-000 can anyone help me use it in my project?
                          Thanks!

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

                            Hello, anybody can help me here?
                            What I want to do is to get the instant watt or kW read from my SCT013000 and to get also the kWh from a certain date, let's say fro first of this month!
                            Any idea will be kindly appreciated!
                            I'm using openhanb to display info and I'll need some rules for this!
                            Thanks all!

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

                              Nobody here?

                              1 Reply Last reply
                              0
                              • 5546dug5 Offline
                                5546dug5 Offline
                                5546dug
                                wrote on last edited by
                                #26

                                I have got this to work on my Cdn system 120/240 vac using A0 and A1 pins. The code needed to be changed to address our voltage and another clamp added., but I do have a few questions;

                                1. Is there a way I can record or view amps consumed in the vera dashboard?

                                2. I used the sketch above displayed by @chatainsim and in it there are two lines of code with values 29.0 and second 1480 both in green and in brackets. For the life of me I can not find an explanation of these or how the values were arrived at. Can anyone help with explanation?

                                    gw.present(CHILD_ID, S_POWER);
                                    emon1.current(A0, 29.0);       // Current: input pin, calibration.
                                    }
                                  
                                    void loop()
                                   {
                                   gw.process();
                                   unsigned long now = millis();
                                   double Irms = emon1.calcIrms(1480);
                                  
                                3. Is there a method to show current in phase. I tried presenting CHILD_ID, S_MULTIMETER and MyMessage IrmsMsg(CHILD_ID,V_CURRENT); but got nowhere.

                                4. There is/was much running up and down stairs from electrical panel to computer and back is OTA IDE what I think it might be-- firmware or sketches can be updated over the air from my computer>vera>gw>node while not needing to access the node? If so there is much learning for me to do.

                                5. Using arduino 1.6.5, Lib 1.4.1, vera 3/veralite, ui5, Ethernet g/w , win 8.1, pro mini clone

                                1 Reply Last reply
                                0
                                • ? Offline
                                  ? Offline
                                  A Former User
                                  wrote on last edited by
                                  #27

                                  Hello, last week i buy SCT013-30 (ebay.fr) and follow this topic for have powermeter with mysensors. I need only energy (kWh) and power (W) same my OWL sensors (use with domoticz controler)
                                  I modifie the sketch from mysensors/pulse powermeter (http://www.mysensors.org/build/pulse_power)

                                  // 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
                                  #define CHILD_ID 0 
                                  #define PIN_ANALOG_I A2
                                  MySensor gw;
                                  unsigned long lastSend;
                                  unsigned long lastSend2;
                                  unsigned long SEND_FREQUENCY = 90000; // Minimum time between send (in milliseconds).
                                  unsigned long SEND_FREQUENCY2 = SEND_FREQUENCY / 25;
                                  int index = 0;
                                  double Irms=0;
                                  double power;
                                  boolean pcReceived = false;
                                  double nrj=0, old_nrj;
                                  MyMessage IrmsMsg(CHILD_ID,V_WATT);
                                  MyMessage kWhMsg(CHILD_ID,V_KWH);
                                  MyMessage pcMsg(CHILD_ID,V_VAR1);
                                  
                                  
                                  void incomingMessage(const MyMessage &message) 
                                  {
                                    if (message.type==V_VAR1) 
                                    {  
                                      nrj = old_nrj = message.getLong();
                                      Serial.print("Received last nrj count from gw:");
                                      Serial.println(nrj);
                                      pcReceived = true;
                                    }
                                  }
                                  
                                  void setup()
                                  {  
                                    gw.begin(incomingMessage);
                                    gw.sendSketchInfo("Energy Meter", "1.0");  // Send the sketch version information to the gateway and Controller
                                    gw.present(CHILD_ID, S_POWER);   // Register this device as power sensor
                                    gw.request(CHILD_ID, V_VAR1);
                                    emon1.current(PIN_ANALOG_I, 30.0);       // Current: input pin, calibration.
                                  }
                                  
                                  void loop()
                                  {
                                    gw.process(); 
                                    unsigned long now = millis();
                                    unsigned long now2 = millis();
                                    bool sendTime2 = now2 - lastSend2 > SEND_FREQUENCY2;
                                    if (sendTime2) //calcul Irms moy
                                    {
                                      if (index==0) Irms=emon1.calcIrms(1480);
                                      else {
                                      index++;
                                      Irms = (index*Irms+emon1.calcIrms(1480))/(index+1);
                                      }
                                      lastSend2 = now2;
                                    }
                                    bool sendTime = now - lastSend > SEND_FREQUENCY;
                                    if (sendTime && pcReceived) 
                                    { 
                                      power = Irms*232.0;
                                      gw.send(IrmsMsg.set(power,1));
                                      Serial.println(Irms*232.0);
                                      nrj += (power*SEND_FREQUENCY/1000)/3.6E6;
                                      gw.send(kWhMsg.set(nrj,3));
                                      lastSend = now;
                                      index = 0;
                                      old_nrj=nrj;
                                    }
                                   else if (sendTime && !pcReceived)
                                   {
                                    gw.request(CHILD_ID, V_VAR1);
                                    lastSend=now;
                                   }
                                  }
                                  

                                  it seems that it works for now (but not optimal).
                                  0_1456322448197_upload-3801900a-dd69-437d-ac99-6f2baa635713

                                  Note 1) my cosphy=1 because i use only ampere clamp, i cant measure the phase between curent i and tension v.
                                  2) my calibration constant (used in emonlib) is 30
                                  3) Sorry for my english :disappointed: - Je suis français.

                                  1 Reply Last reply
                                  0
                                  • O Offline
                                    O Offline
                                    oudini
                                    wrote on last edited by
                                    #28

                                    Hello,
                                    The cos phi applies only to the three-phase, single phase not

                                    Je suis français aussi...

                                    1 Reply Last reply
                                    0
                                    • fredokF Offline
                                      fredokF Offline
                                      fredok
                                      wrote on last edited by
                                      #29

                                      Hello, if i remember physics course in university Power P=u.i and energy E=integrale(Pdt)=integrale(u.i.dt)=UeffxIeffxcos(phi)
                                      but for particular citizen same me, energy provider non consider cos(phi)

                                      So, i correct my last sketch for request last nrj value to the gw.

                                      // 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
                                      #define CHILD_ID 0 
                                      #define PIN_ANALOG_I A2
                                      MySensor gw;
                                      unsigned long lastSend;
                                      unsigned long lastSend2;
                                      unsigned long SEND_FREQUENCY = 20000; // Minimum time between send (in milliseconds). We don't wnat to spam the gateway.
                                      unsigned long SEND_FREQUENCY2 = SEND_FREQUENCY / 25;
                                      int index = 0;
                                      double Irms=0;
                                      double power;
                                      boolean pcReceived = false;
                                      boolean onyva=true;
                                      float nrj=0, old_nrj;
                                      MyMessage IrmsMsg(CHILD_ID,V_WATT);
                                      MyMessage kWhMsg(CHILD_ID,V_KWH);
                                      MyMessage pcMsg(CHILD_ID,V_VAR1);
                                      
                                      
                                      void incomingMessage(const MyMessage &message) 
                                      {
                                        if (message.type==V_VAR1) 
                                        {  
                                          nrj = old_nrj = message.getFloat();
                                          Serial.print("Received last nrj count from gw:");
                                          Serial.println(nrj);
                                          pcReceived = true;
                                        }
                                      }
                                      
                                      void setup()
                                      {  
                                        gw.begin(incomingMessage);
                                        gw.sendSketchInfo("Energy Meter", "1.0");  // Send the sketch version information to the gateway and Controller
                                        gw.present(CHILD_ID, S_POWER);   // Register this device as power sensor
                                        gw.request(CHILD_ID, V_VAR1);
                                        emon1.current(PIN_ANALOG_I, 30.0);       // Current: input pin, calibration.
                                      }
                                      
                                      void loop()
                                      {
                                        if (onyva) gw.process();
                                        onyva = false; 
                                        unsigned long now = millis();
                                        //unsigned long now2 = millis();
                                        bool sendTime2 = now - lastSend2 > SEND_FREQUENCY2;
                                        if (sendTime2) //calcul Irms moy
                                        {
                                          if (index==0) Irms=emon1.calcIrms(1480);
                                          else {
                                          index++;
                                          Irms = (index*Irms+emon1.calcIrms(1480))/(index+1);
                                          }
                                          lastSend2 = now;
                                        }
                                        bool sendTime = now - lastSend > SEND_FREQUENCY;
                                        if (sendTime && pcReceived) 
                                        { 
                                          power = Irms*232.0;
                                          gw.send(IrmsMsg.set(power,1));
                                          Serial.println(Irms*232.0);
                                          nrj += (power*SEND_FREQUENCY/1000)/3.6E6;
                                          gw.send(kWhMsg.set(nrj,5));
                                          gw.send(pcMsg.set(nrj,5));
                                          lastSend = now;
                                          index = 0;
                                          old_nrj=nrj;
                                          onyva=true;
                                        }
                                       else if (sendTime && !pcReceived)
                                       {
                                        gw.request(CHILD_ID, V_VAR1);
                                        lastSend=now;
                                        index=0;
                                        onyva=true;
                                       }
                                      }
                                      
                                      

                                      thx...

                                      chatainsimC warmaniacW 2 Replies Last reply
                                      0
                                      • M Offline
                                        M Offline
                                        maciejka
                                        wrote on last edited by
                                        #30

                                        Hi, I'm beginner of arduino programmer. Can You explain a little this sketch? What for You use "SEND_FREQUENCY2 = SEND_FREQUENCY / 25;" ? Why You using two if statements sendTime2 and sendTime ?

                                        Thanks
                                        Maciej

                                        1 Reply Last reply
                                        0
                                        • fredokF Offline
                                          fredokF Offline
                                          fredok
                                          wrote on last edited by
                                          #31

                                          Sorry, I'm late debause i come back holiday today
                                          This sketch send Power and energy (kWh) every Sendfrequency=90s but the sketch not measure power every 90s but everyre 90/25=3,6s and send to the GW the mean power (Pmean)
                                          this is calculate here :
                                          if (index==0) Irms=emon1.calcIrms(1480);
                                          else {
                                          index++;
                                          Irms = (index*Irms+emon1.calcIrms(1480))/(index+1);
                                          }
                                          lastSend2 = now;

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


                                          26

                                          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