Power Monitoring with SCT013-030 Current sensor & Wemos D1 Mini-ESP12:

Components needed:
1. ESP8266 (Wemos D1 Mini)
2. SCT013-030 30A Non Invasive Current Sensor 
3. 2 x 100K/ 0.25W Resistors
4. 10UF/15V Capacitor

In this project, we clamp the mains cable which is carrying current which we want to measure with the Current sensor.
One of the outputs of the current sensor is kept at the half of the supply voltage, in this case it is 3.3V / 2 = about 1.6V.
The other output pin of the current sensor is connected to the Analog input pin (A0) of the Di Mini board.



Sample code for the above project listed below.
EmonLib is being used to calculate RMS value of the AC Current. The library has to be installed on arduino IDE first.
On Arduino IDE, Tools -> Manage Libraries , and search for "emon" and install EmonLib.



Arduino Code:

//Simple Home Power Monitoring Webserver
//With Wemos D1mini(ESP8266) + SCT013-030 Non Invasive Current Sensor
//AMP Technology Aug 2020
//Ref:Open Energy Monitor https://github.com/openenergymonitor/EmonLib
//https://learn.openenergymonitor.org/electricity-monitoring/ct-sensors/interface-with-arduino
//---------------------------------------------------------------------

#include <ESP8266WiFi.h>
#include "EmonLib.h"                   // Include Emon Library

const char* ssid     = "XXXXXXXXXXXX"; // Your WIFI ssid
const char* password = "XXXXXXXXX";   // Your WIFI Password

float Irms;
double CurrentMillis;
WiFiServer server(80);
EnergyMonitor emon1;                   // Create an instance

void setup() {
Serial.begin(115200);
delay(10);
Serial.println();
emon1.current(A0, 30.0);             // Current: input pin, Calibration

// Connect to WiFi network
WiFi.mode(WIFI_STA);
Serial.println();
Serial.println();
Serial.print("Connecting to ");
Serial.println(ssid);

WiFi.begin(ssid, password);

while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");

// Start the server
server.begin();
Serial.println("Server started");

// Print the IP address
Serial.print("Webserver IP:");
Serial.println(WiFi.localIP());
Serial.println();
}

void loop() {
 Irms = emon1.calcIrms(1480);  // Calculate Irms only 
 Irms = Irms - 0.15;
 Serial.print("Current(A):");
 Serial.println(Irms);
 Serial.print("Power(W):");
 Serial.println(Irms*230);    //Assuming the Line voltage is 230V AC
 Serial.println("--------------------");

 WiFiClient client = server.available();
 client.println("HTTP/1.1 200 OK");
 client.println("Content-Type: text/html");
 client.println("Connection: close");  // the connection will be closed after completion of the response
 client.println("Refresh: 5");  // refresh the page automatically every 5 sec
 client.println();
 client.println("<!DOCTYPE html>");
 client.println("<html xmlns='http://www.w3.org/1999/xhtml'>");
 client.println("<head>\n<meta charset='UTF-8'>");
 client.println("<title>ESP8266 Home Power Monitor</title>");
 client.println("</head>\n<body>");
 client.println("<H2>Home Power Monitoring with</H2>");
 client.println("<H2> ESP8266 + SCT013-030 Current Sensor:<H2>");
 client.println("<H3>======================================<H3>");
 client.println("<H3>Current Power Consuption:</H3>");
 client.println("<pre>");
 client.print("Current(A) : ");
 client.println((float)Irms, 1);
 client.print("Power(W)   : ");
 client.println((float)(Irms*230),1);
 client.println("</pre>");
 client.println("==================================");
 client.println("<H3>AMP Technology</H3>");
 client.println("<H4>www.amptech.co.nz</H4>");
 client.print("</body>\n</html>");
 delay(1000); //delay for reread
}
//============================================


Compile the ino, upload to the ESP8266, pres the reset button on the board.
Open the serial monitor of the arduino IDE, wait few second until it gets the IP, note down the IP address of the webserver.
Browse to the ip address from web browser. Browser auto updates every 5 seconds.


Web page:

0Comments

For Comment you need to Login