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. My Project
  3. SCT-013-030 Energy Meter

SCT-013-030 Energy Meter

Scheduled Pinned Locked Moved My Project
35 Posts 15 Posters 25.4k Views 25 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.
  • john7845J Offline
    john7845J Offline
    john7845
    wrote on last edited by
    #26

    Again, I take zeros.

    1 Reply Last reply
    0
    • meanmrgreenM Offline
      meanmrgreenM Offline
      meanmrgreen
      wrote on last edited by
      #27

      Sorry for nuub question but can you use a pro mini 3.3 för this?
      Or do i need a nano or pro mini 5v?

      Talat KeleşT 1 Reply Last reply
      0
      • meanmrgreenM meanmrgreen

        Sorry for nuub question but can you use a pro mini 3.3 för this?
        Or do i need a nano or pro mini 5v?

        Talat KeleşT Offline
        Talat KeleşT Offline
        Talat Keleş
        wrote on last edited by Talat Keleş
        #28

        @meanmrgreen
        Sure you can use 3.3v for this. If you are using sct-013-000 version, adjust your burden according to

        Burden Resistor (ohms) = (AREF * CT TURNS) / (2√2 * max primary current)
        

        where Aref =3.3 (or at worst case, it's lower than 3.3V- if battery powered)
        Also don't forget to change calibration which is

        Current Calibration Constant = CT TURNS / burden resistor
        
        1 Reply Last reply
        1
        • B Offline
          B Offline
          Bill Thomson
          wrote on last edited by
          #29

          One thing to keep in mind with this configuration: you're not actually measuring true power. Rather by not using a voltage reference, you're calculating apparent power, which is measured in VA (Volt Amps) vice Watts.

          For resistive loads, apparent power and real power are the same, or very nearly so. But with reactive loads, e.g. motors, computer power supplies, compact flourescent or LED lamps, etc. they will differ considerably.

          1 Reply Last reply
          1
          • Suresh MaliS Offline
            Suresh MaliS Offline
            Suresh Mali
            wrote on last edited by
            #30

            Hi @patrick-schaerer ,
            I got my setup running and was trying your code.

            I was testing this code on my AC unit which has 1600W max consumption. When I first ran it always reported a value of around 270W even when the AC unit was off from mains and in running condition it reported around 750W with compressor on and around 250W with compressor off.
            I adjusted the value on line

            emon1.current(ANALOG_INPUT_SENSOR, 30);             // Current: input pin, calibration
            

            Tried values from 10 to 111(default as per emon lib) to calibrate it to report 0 in off condition. finally at 10 it reported zero but now when the AC is on it reports 270W max.

            Could you please help me figure out where the problem could be. Thanks

            1 Reply Last reply
            0
            • D Offline
              D Offline
              dakipro
              wrote on last edited by
              #31

              Thank for sharing the code and schematics, I cannot get it to run however, I always get 0 value whatever I do. Anyone has a suggestion about how to test this sensor the easiest way?

              I have sct 013 030 sensor, and I connected it using the schematics provided here, I tried even the most basic examples I could find using EmonLib, I tried some basic examples using analog read and what not, but nothing seemed to work properly, I would always get either 0 or some fixed value.
              I am connecting "first" and "last" conneciton on 3.5mm jack, but I also tried all combinations, and nothing seems to make a diffference.
              I am using two resistors of 20Kohm as splitters, I am getting 2.43v between both side of them (using nano on 5V).
              I am wrapping the module around the cable of the water cooker for example, which is 1.5KW, but values never change at all. It is either 0 or some max value (46A f.eks.) either with or without the load.
              I was trying both nano and pro mini, same thing happens. Checked the circuit and connection between components several times.
              This is the simplest code I found on the internet (not even mysensorized)

              void setup() {
              	
              	Serial.begin(9600);
              	analogReference(INTERNAL);
              	//analogReference(INTERNAL1V1); //solo Arduino Mega
              }
              
              void loop() {
              	
              	float Irms=get_corriente(); //Corriente eficaz (A)
              	float P=Irms*220.0; // P=IV (Watts)
              
              	Serial.print("Irms: ");
              	Serial.print(Irms,3);
              	Serial.print("A, Potencia: ");
              	Serial.print(P,3);
              	Serial.println("W");
              	//delay(100);
              }
              
              float get_corriente()
              {
              	float voltajeSensor;
              	float corriente=0;
              	float Sumatoria=0;
              	long tiempo=millis();
              	int N=0;
              	while(millis()-tiempo<500)//Duración 0.5 segundos(Aprox. 30 ciclos de 60Hz)
              	{
              		voltajeSensor = analogRead(A0) * (1.1 / 1023.0);////voltaje del sensor
              		corriente=voltajeSensor*30.0; //corriente=VoltajeSensor*(30A/1V)
              		Sumatoria=Sumatoria+sq(corriente);//Sumatoria de Cuadrados
              		N=N+1;
              		delay(1);
              	}
              	Sumatoria=Sumatoria*2;//Para compensar los cuadrados de los semiciclos negativos.
              	corriente=sqrt((Sumatoria)/N); //ecuación del RMS
              	return(corriente);
              }
              

              Could it be that here in Norway we use two "phases" in the house? (or I could be wrong here either).

              What is the most easy "idiot" proof way of testing this and getting some values? What could I be doing wrong?
              Should I just order another sensor, can this "simple" sensor even be wrong?

              Any clues, anyone?

              C: OpenHAB2 with node-red on linux laptop
              GW: Arduino Nano - W5100 Ethernet, Nrf24l01+ 2,4Ghz mqtt
              GW: Arduino Mega, RFLink 433Mhz

              1 Reply Last reply
              0
              • Lawrence HelmL Offline
                Lawrence HelmL Offline
                Lawrence Helm
                wrote on last edited by
                #32

                I never got this going, have to play around with it again, but one thing I did do wrong was put the clip around both wires, instead of just the positive. I.e. putting it around + and - will give 0.

                1 Reply Last reply
                0
                • D Offline
                  D Offline
                  dakipro
                  wrote on last edited by
                  #33

                  Ok so it will not work around both wires?
                  You can not clamp it around extension cable and measure "something"?

                  I basically just want to detect if stove is on or off, i was hoping to see at least a blip or anything really, can leave without actual numbers..

                  C: OpenHAB2 with node-red on linux laptop
                  GW: Arduino Nano - W5100 Ethernet, Nrf24l01+ 2,4Ghz mqtt
                  GW: Arduino Mega, RFLink 433Mhz

                  1 Reply Last reply
                  0
                  • D Offline
                    D Offline
                    dakipro
                    wrote on last edited by
                    #34

                    After some research I realized that this cannot work with two wires as they cancel each other.
                    After some googling I have found this https://moderndevice.com/product/a1324-hall-effect-sensor/ in description they mention that it can do what I want, to detect if appliance is on or off even if two wires are in close proximity. They mention that you could detect 100W, although I am planning to monitor if stove is on or off, which is I assume more then 100w.
                    They also have more precise "boosted" version that is more precise https://moderndevice.com/product/current-sensor/ but I think I do not need it for now.

                    C: OpenHAB2 with node-red on linux laptop
                    GW: Arduino Nano - W5100 Ethernet, Nrf24l01+ 2,4Ghz mqtt
                    GW: Arduino Mega, RFLink 433Mhz

                    1 Reply Last reply
                    0
                    • P patrick schaerer

                      I alread updated to MySensors 2.0

                      This is the update code:

                      I also edited the first post.

                      /**
                       * The MySensors Arduino library handles the wireless radio link and protocol
                       * between your home built sensors/actuators and HA controller of choice.
                       * The sensors forms a self healing radio network with optional repeaters. Each
                       * repeater and gateway builds a routing tables in EEPROM which keeps track of the
                       * network topology allowing messages to be routed to nodes.
                       *
                       * Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
                       * Copyright (C) 2013-2015 Sensnology AB
                       * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
                       *
                       * Documentation: http://www.mysensors.org
                       * Support Forum: http://forum.mysensors.org
                       *
                       * This program is free software; you can redistribute it and/or
                       * modify it under the terms of the GNU General Public License
                       * version 2 as published by the Free Software Foundation.
                       *
                       *******************************
                       *
                       * EnergyMeterSCT by Patrick Schaerer
                       * This Sketch is a WattMeter used with a SCT-013-030 non invasive PowerMeter
                       * see documentation for schematic
                       * 
                       * Special thanks to Surge, who optimized my code.
                       * 
                       * updated to mySensors Library 2.0
                       */
                      
                      
                      #define MY_RADIO_NRF24
                      #define MY_REPEATER_FEATURE
                      #define MY_DEBUG
                      
                      
                      #include <SPI.h>
                      #include <MySensors.h>  
                      #include <EmonLib.h> 
                       
                      #define ANALOG_INPUT_SENSOR 1  // The digital input you attached your SCT sensor.  (Only 2 and 3 generates interrupt!)
                      //#define INTERRUPT DIGITAL_INPUT_SENSOR-2 // Usually the interrupt = pin -2 (on uno/nano anyway)
                      #define CHILD_ID 1              // Id of the sensor child
                      
                      EnergyMonitor emon1;
                      
                      MyMessage wattMsg(CHILD_ID,V_WATT);
                      MyMessage kwhMsg(CHILD_ID,V_KWH);
                      MyMessage msgKWH(CHILD_ID,V_VAR1);
                      unsigned long SLEEP_TIME = 60000 - 3735; // sleep for 60 seconds (-4 seconds to calculate values)
                      
                      float wattsumme = 0;
                      float kwh = 0;
                      float wh = 0;
                      int minuten = 0;  //vorher 61
                      boolean KWH_received=false;
                      
                      //Humidity Sensor Code
                      #include <DHT.h>  
                      #define CHILD_ID_HUM 2
                      #define CHILD_ID_TEMP 3
                      #define HUMIDITY_SENSOR_DIGITAL_PIN 2
                      DHT dht;
                      float lastTemp;
                      float lastHum;
                      boolean metric = true; 
                      MyMessage msgHum(CHILD_ID_HUM, V_HUM);
                      MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP);
                      
                      //End of Humidity Sensor Code
                      
                      
                      void setup()  
                      {  
                        //energy clamp code
                        //gw.begin(incomingMessage, AUTO, true,0); 
                        
                        Serial.begin(115200);
                        emon1.current(ANALOG_INPUT_SENSOR, 30);             // Current: input pin, calibration.
                      
                        
                        double Irms = emon1.calcIrms(1480);  // initial boot to charge up capacitor (no reading is taken) - testing
                        request(CHILD_ID,V_VAR1);
                        //end of energy clamp code
                      
                      //Humidity Sensor Code
                        dht.setup(HUMIDITY_SENSOR_DIGITAL_PIN);   
                        metric = getConfig().isMetric;
                        //End of Humidity Sensor Code 
                      }
                      
                      void presentation() {
                        // Send the sketch version information to the gateway and Controller
                        // Register this device as power sensor
                      sendSketchInfo("Energy Meter SCT013", "2.0");
                      present(CHILD_ID, S_POWER);
                      present(CHILD_ID_HUM, S_HUM);
                      present(CHILD_ID_TEMP, S_TEMP);
                      
                      }
                      void loop()     
                      { 
                        
                        //process();
                      
                        //KWH reveived check
                        if (!KWH_received) request(CHILD_ID,V_VAR1);
                        
                        // power used each minute
                        if (minuten < 60) {
                          double Irms = emon1.calcIrms(1480);  // Calculate Irms only
                          if (Irms < 0.3) Irms = 0;
                          long watt = Irms*240.0; // default was 230 but our local voltage is about 240
                          wattsumme = wattsumme+watt;
                          minuten++;
                          send(wattMsg.set(watt));  // Send watt value to gw
                          
                          Serial.print(watt);         // Apparent power
                          Serial.print("W I= ");
                          Serial.println(Irms);          // Irms   
                        }
                        // end power used each minute
                        
                        // hours KW reading
                        if (minuten >= 60) {
                          wh = wh + wattsumme/60;
                          kwh = wh/1000;
                          send(kwhMsg.set(kwh, 3)); // Send kwh value to gw 
                          send(msgKWH.set(kwh, 3)); // Send kwh value to gw
                          wattsumme = 0;
                          minuten = 0;
                        }
                      // end of hourly KW reading
                          
                      // Humidity Sensor Code
                       if (minuten == 15 || minuten == 30 || minuten == 45|| minuten == 60) {
                          float temperature = dht.getTemperature();
                          if (isnan(temperature)) {
                            Serial.println("Failed reading temperature from DHT");
                          } else if (temperature != lastTemp) {
                            lastTemp = temperature;
                          if (!metric) {
                            temperature = dht.toFahrenheit(temperature);
                          }
                          send(msgTemp.set(temperature, 1));
                          Serial.print("T: ");
                          Serial.println(temperature);
                          }
                        
                        float humidity = dht.getHumidity();
                        if (isnan(humidity)) {
                            Serial.println("Failed reading humidity from DHT");
                        } else if (humidity != lastHum) {
                            lastHum = humidity;
                            send(msgHum.set(humidity, 1));
                            Serial.print("H: ");
                            Serial.println(humidity);
                        }
                       }
                      
                       //End of Humidity Sensor Code
                       wait(SLEEP_TIME);
                      }
                      
                      void receive(const MyMessage &message) {
                        if (message.type==V_VAR1) {  
                          kwh = message.getFloat();
                          wh = kwh*1000;
                          Serial.print("Received last KWH from gw:");
                          Serial.println(kwh);
                          //send(kwhMsg.set(kwh, 3)); // Send kwh value to gw 
                          KWH_received = true;
                        }
                      }
                          
                      
                      
                      Hassan AnsariH Offline
                      Hassan AnsariH Offline
                      Hassan Ansari
                      wrote on last edited by
                      #35

                      @patrick-schaerer can I use same code file for measuring current only using sct-013-030 and at other end I'll use other sensor to read ac voltage and with the help of that I'll calculate power.
                      I'm new on this. Just start learning and I'm using esp32 instead of Arduino.
                      Please share your suggestion on this. It will really help me to learn .

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


                      29

                      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