We use A1, A2 and A3 because the are free (most ADCs are already used on the HelTec Board)
### Sensors
The SCT-013 sensors are small current transformers (SCT). They have a ferromagnetic core that can be opened and in which we can enclose our conductor. This conductor is the primary winding and the secondary winding is fixed in the sensor and can have 2000 turns. This gives us a ratio of 1:2000 as an example.
When AC current flows through the conductor, a magnetic flux is generated in the ferromagnetic core, which in turn generates an electric current in the secondary winding.
I could not meassure "small" power consumptions (like a LED lamp or a light stripe, as the magnetix flux in the ferromagnet core seems to be too small).
![clamp on wire](./docs/images/clamp1.jpeg "clamp on a wire")
I was able to measure high loads (like a heater the can be switched between 1 kW and 2 kW).
![heater](./docs/images/example-heater.png "serial out of a heater")
Make sure the clamp is *always positioned towards the consumer*, otherwise it does *not* work. There is a small arrow on the case.
![point the clamp](./docs/images/clamp2.jpeg "point the clamp")
![Photo of breadboard](./docs/images/photo-breadboard.jpeg "photo of breadboard")
To understand this, have a look at this plan:
![Plan](./docs/images/plan.png "plan")
R1 & R2 are a voltage divider that provides the 1.65 V source. We use 10 kΩ for mains powered monitors. If we want to run on batteries, we have to choose differnt ones (like 470 kΩ resistors to keep the power consumption to a minimum).
Capacitor C1 has a low reactance - a few hundred ohms - and provides a path for the alternating current to bypass the resistor. A value of 10 μF is suitable.
R3 is the burden resistor. Ideal burden would be 19 Ω. As this is not a common value, you could choose 18 Ω or 22 Ω (I am still using a 47 Ω restistor, that has to be replaced).
See the Fritzing file for [details](./energy-monitor/energy-monitor.fzz).
### Code
#### Print to serial out
Start with a simple code that just prints the values. The code is quite simple, as we can use the existing *[EmonLib libary V1.1.0 by OpenEnergyMonitor](https://docs.openenergymonitor.org/electricity-monitoring/ct-sensors/)*.
[Check out the small amount of code to print the values to serial out.](./01-energy-monitor-serial-out/) This piece of code is based on on Thomas Edlinger's code for [Edi's Tech Lab](https://www.edistechlab.com).
The [calibration](https://docs.openenergymonitor.org/electricity-monitoring/ctac/calibration.html) value "8" was done with a Fluke multimeter (and maybe a not so ideal burden resistor).
* A very comprehensive project to build an energy monitor can be found in the [ESP32 + ESPHome Open Source Energy Monitor project by Daniel BP](https://github.com/danpeig/ESP32EnergyMonitor).
* Have a look at the [complete documentation of the Open Energy Monitor project](https://docs.openenergymonitor.org/).
* There is also a German [example project](http://www.technik-fan.de/index.php/Open_Energy_Monitor_mit_dem_ESP32) (that currently cannot be reached over TLS, so be careful before clicking this link).