Skip to content

leungkimming/ehome

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

eHome

Monitor Home electricity consumption using CT & ESP32

Author: Michael Leung from Hong Kong

Intro

eHome

This device provides the following functions:

  • Monitor home electricity consumption per second with realtime display in Ampere
  • With 10% change for 10 seconds, record to SD card
  • Trigger alarm when over predetermine Ampere
  • HTTP get current consumption
  • HTTP get history
  • HTTP restful API to adjust parameters

References

Components

Schematic circuit diagram

Schematic

Circuit Board design

Schematic

Assembly

Assembly Solder the bottom side, with ESP32 socket, buzzer, 5v 3.5mm plug, diode and wiring. As seen in the picture, you need to cut one side of the circuit board to fit into the box. The 4 pin socket on the side you have cut is just a dummy to make the circuit board sitting flat.
Prepare LED display on the cover top. Don't mount and drill holes for the 4 pins connector yet. Needs precise alignment with the top side socket.

Assembly Solder the top side, with resistors, capacitors, 3.5mm socket for SCT-13-060, 4 pins sockets for LED display and 6 pins socket for SD card module. I used the 0.1uf capacitor to mount the 3.5mm socket on the board because I want to cancel noise from the outset.
Mount the SD card module on the cover bottom. Need careful alignment with the 6 pins socket. Mount the LED display on cover top with holes for the 4 pins. Again, need careful aligment with the 4 pins socket.

Assembly Plug in ESP32, and the cover assembly with both LED display and SD module onto the respective sockets.

Assembly Drill holes on each side of the plastic box for the two 3.5mm sockets. Again, you need very careful alignment.
Close the plastic box and fasten the 3.5mm socket nuts.

Assembly Warning! Employ a licensed eletrical technician to plug in the SCT-13-060 to your home's main supply.

eHome Cut one end of the USB cable and replace it with the 3.5mm plug. I used a wall plug with USB charging to supply the +5v power supply.

HTTP functions

You have to hard code

  • your wifi routers SSID and Password
  • your region's NTP server URL

1. Current consumption https://xxx.xxx.x.xxx/

2021/10/31 00:05:52 - 1.55A
Date_Time,Amp
2021/10/28 14:17:14,2.76
2021/10/28 14:21:34,0.63
2021/10/28 19:51:35,7.74

3. Clear all History records https://xxx.xxx.x.xxx/clear

3300 with assumed 2 decimal point = 33.00A

We need a "Current Constant" to create the emonlib object.

emon1.current(ESP32 ADC pin, Current Constant);

Based on the calibration theory on learn.openenergymonitor.org, If you use a current transformer with a built-in burden (SCT-013-060 is one of these), then

current constant = max primary current ÷ (max secondary current (I) * burden reisiter (R))
current constant = max primary current ÷ (max voltage across the burden reisiter)

For SCT-013-060, we know "max primary current" = 60 and "max voltage across the burden reisiter" = 1V. Hence,

current constant = 60 ÷ (1) = 60
emon1.current(ESP32 ADC pin, 60);

6. Sampling cycle Calibration https://xxx.xxx.x.xxx/cycle?value=5394

Our electricity supply is in form of Alternating Current (AC), which is the number of cycles per second of sine waves in Hertz (Hz). Best sampling rates are complete multiple of complete sin wave. The sampling-rate-of-emonlib reference above found in his setup that:

calcIrms( ) will have approx 5588 current samples per second
1 cycle of mains:
112 for a 50 Hz system, or 93 for a 60 Hz system.

The smallest ‘universal’ number:
559 (100 ms, or 5 cycles of 50 Hz or 6 cycles of 60 Hz).

The recommended monitoring period:
1676 (300 ms).

However, in my setup, cycles to last for 300 ms is 5394.

  Serial.print("Cycle=");
  start = millis();
  Irms = emon1.calcIrms(5394);
  Serial.println(millis() - start);

output:
Cycle=300