https://github.com/npotts/esp32-samplenode
ESP32 that measures PTU and AC power measurements to spew to MQTT.
https://github.com/npotts/esp32-samplenode
esp32 humidity mqtt power-meter temperature
Last synced: 3 months ago
JSON representation
ESP32 that measures PTU and AC power measurements to spew to MQTT.
- Host: GitHub
- URL: https://github.com/npotts/esp32-samplenode
- Owner: npotts
- License: other
- Created: 2019-12-05T02:58:56.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2022-05-06T04:26:16.000Z (about 4 years ago)
- Last Synced: 2024-01-26T07:10:45.195Z (over 2 years ago)
- Topics: esp32, humidity, mqtt, power-meter, temperature
- Language: C
- Homepage:
- Size: 422 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ESP32 Sampler
The TL;DR is that I got excited about looking into how to use [Split Phase Current Measurement](https://circuitsetup.us/index.php/product/split-single-phase-real-time-whole-house-energy-meter-kit-programmed-esp32-2-cts-abs-box/) kit, and trying to figure out how to avoid installing some arbitrary annoying PHP software that is called ESPMon.
I soon started reading the docs on [FreeRTOS](www.freertos.com), and quickly bought:
* I2C Hygrometer [SI7021](https://www.adafruit.com/product/3251)
* I2C Barometer [MPL3115A2](https://www.adafruit.com/product/1893)
* SPI based on a ATM90E32 [Split Phase Current Measurement](https://circuitsetup.us/index.php/product/split-single-phase-real-time-whole-house-energy-meter-kit-programmed-esp32-2-cts-abs-box/)
With the intent to spew data into a MQTT queue installed inside my home network.
# Wiring Diagram

# MQTT Enpoints
Running `make menuconfig` will allow one to modify the bulk of what is in there, but the defaults do the following. Data points all have the same structure:
> {"t":1231231,"v":832.234662}
`t` is the ESP32's `millis()` clock that eventually rolls over. V is the
|Topic|Data|
|:----|:---|
|heartbeat/pwr| Heartbeat message with a brief timestamp. Messages here are strings, and are triggered when the SPI poll has errant data|
|heartbeat/wxpwr| Heartbeat for main monitor loop. Contains slightly different data values |
|sensor/wx/p| Pressure, in mBar|
|sensor/wx/pth| Temperature of the barometer sensor. Could be used for
calibration|
|sensor/wx/rh| Relative humidity in %RH. Is not clipped to 100 and may be wildly off during temperature shocks|
|sensor/wx/rht| Relative humidity sensor temperature in C. Could be used for calibration|
|sensor/power/f| Frequency, in Hz|
|sensor/power/v1| Phase 'A' voltage, RMS|
|sensor/power/v2| Phase 'C' voltage, RMS (not entirely sure how this is different from v1 above|
|sensor/power/i1| Phase 'A' current (amps) |
|sensor/power/i2| Phase 'C' current (amps) |
|sensor/power/I| Total current (A+C) |
|sensor/power/ap| [Apparent Power](https://en.wikipedia.org/wiki/AC_power#Active,_reactive,_and_apparent_power) |
|sensor/power/ap| [Power Factor](https://en.wikipedia.org/wiki/Power_factor) |
|sensor/power/t| Temperature sensor |
|sensor/power/f| AC Frequency |
|sensor/power/w| Power (Watts) |
# How to Build
* Firstly, you need to get the [esp-idf](https://github.com/espressif/esp-idf). That is outside the realm of this manual, but is necessary to work properly.
```sh
source path/to/esp-idf/export.sh # get the ESP-IDF build environment
cp sdkconfig.sample sdkconfig
make menuconfig # Modify the build parameters (eg, Wifi SSID, Password, MQTT etc) under the "House Monitor Config"
make -j8 #because I can
```
# Why?
Do you really need to to ask that?
Outside the normal `I had an itch` answers, consider the fact you are here continuing to read this sentence; impling that you too, want to invest time tinkering in homebrewing your own tools.