Rachel Lima
Published

Monophasic and Biphasic Power Meter Smart with ESP32

This is a monophasic and biphasic residential consumption monitoring meter using the ESP32.

IntermediateWork in progress2,299
Monophasic and Biphasic Power Meter Smart with ESP32

Things used in this project

Hardware components

Sct 013 - Current Sensor
×1
P8 - Voltage Sensor
×1
ESP32S
Espressif ESP32S
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

Monophasic Mode

You will connect the SCT-013 sensor and the P8 sensor together with the ESP32 and measure the voltage and current as shown in the circuit:

Monophasic mode by measuring the power of a lamp

Monophasic Mode Web Platform

Biphasic Mode

You will connect two SCT-013 sensors together with the ESP32 and measure currents 1 and 2 as shown in the circuit:

Biphasic mode connected in the general picture of the residence

Biphasic Mode Web Platform

Code

Measurement

C/C++
Measurement of current and voltage in conjunction with the calculation of power and sending to the web platform.
void loop() {
  
  int cont = 0;
  double Irms = emon1.calcIrms(12000);
  double Vrms = tensao;  
  double Potencia = Irms * Vrms;
  double Preco = (5 * Potencia)*0.604; 
  boolean envia = true;
   
  client = server.available();   
  
  if (client) {
    Serial.println("New Client.");
    String currentLine = "";

    while (client.connected()){
      if (client.available()) {
        char c = client.read();
        Serial.write(c);
        if (c == '\n') {
          if (currentLine.length() == 0) {
            client.println("HTTP/1.1 200 OK");
            client.println("Content-type:text/html");
            client.println("Refresh: 5");  
            client.println();
            // the content of the HTTP response is a JSON File:
            client.print("dados({ corrente : ");
            client.print(Irms);
            client.print(", tensao:  ");
            client.print(Vrms);
            client.print(", potencia:  ");
            client.print(Potencia);
            client.print(", preco:  ");
            client.print(Preco);
            client.print("})");
            client.println();           
            client.println();
            // break out of the while loop:
            break;
          } else {   
            currentLine = "";
          }
        } else if (c != '\r') {  
          currentLine += c;     
        }
      }
    }
    
    delay(5);
    
    client.stop();
    Serial.println("Client Disconnected.");
  }
}

Credits

Rachel Lima

Rachel Lima

1 project • 1 follower
IoT Enthusiast and Software Developer

Comments