You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hey Rob. -thanks for your great work here - really, really cool! I tried to measure the power consumption for my setup for a whole day and finally made it :) Since I struggeled a lot and searched countless forums, i wanted to share my experience how I made it here (in case it is of help to other noobs like me):
Setup:
Aim: Measuring power consumption of an interactive company sign.
ESP32 Wroom Dev Board with multiple sensors (DHT, MIC, LD, Speaker, and multiple LEDs) integrated via ESP Home into Home Assistant.
Power supply. 5v (Measured 5,18 V) with a maximum of 18 amps (unlikely to be ever drawn - standard would be up to 8 a)
ACS712 with 20a threshold
Wiring: ACS712 connected directly (without any voltage divider) to GPIO34
Relevant Code used for the ESP32 within ESP Home:
`esphome:
acs712_component.h #Should be stored in your ESP Home Folder (directly - no sub folder needed)
esp32:
board: esp32dev
framework:
type: arduino
sensor:
platform: adc #Displays the value measured at the GPIO of your ESP32 - for control purposes - can be deleted if finished
pin: GPIO34
name: "Stromsensor für Leistungsaufnahme"
update_interval: 5s
attenuation: auto #Essential part for the ESP32 since they are otherwise skipping out any voltage higher 1,01V - Alternative Calibration can be done
platform: custom
lambda: |-
auto acs712_sensor = new ACS712Sensor();
App.register_component(acs712_sensor);
return {acs712_sensor->current_sensor, acs712_sensor->power_sensor};
sensors:
name: "Stromaufnahme in Ampere"
unit_of_measurement: A
accuracy_decimals: 2
name: "Aktuelle Leistung in Watt"
unit_of_measurement: W
accuracy_decimals: 2
`
Within the File ACS712.h that I shared by @marianomd I had to do the following minor adjustments
#include"ACS712.h"classACS712Sensor : publicPollingComponent {
public:// Connected to GPIO34, 3.3 Volts being the maximum Voltage on an ESP32, // 4095 being the maximum steps for 12bit (4096 is the number of steps, while 4095 is the // number of options available and 100 being the factor for my 20a Version fo the AC712 // without any Voltage divider, so no recalculation needed)
ACS712 *ACS = new ACS712(34, 3.3, 4095, 100);
Sensor *current_sensor = new Sensor();
Sensor *power_sensor = new Sensor();
ACS712Sensor() : PollingComponent(10000) {} // Changed Polling interval to 10 Seconds instead of 15 to get a faster responsevoidsetup() override {
ACS->autoMidPoint();
ESP_LOGD("acs712", "MidPoint: %d", ACS->getMidPoint());
ACS->setNoisemV(21);
ESP_LOGD("acs712", "Noise mV: %d", ACS->getNoisemV());
}
voidupdate() override {
float average = 0;
int count = 5;
for (int i = 0; i < count; i++) {
average += abs(ACS->mA_DC()); // Two changes here: For an AC Measurement it should be mA_AC(), since I only measure DC, i changed it accordingly. the second add on was the abs() added, since I did not wanted to rewire the load but had negative values for a and p :) - Works perfectly fine for me
}
float amps = average / count / 1000.0;
current_sensor->publish_state(amps);
power_sensor->publish_state(amps * 5.18); // Since my power supply delivers 5.18 V and not 220 or 230 as in DC, this is required to get the correct Power consumption
}
};
Hope this is the correct way to share this and that it helps someone with as little experience as me :-)
The text was updated successfully, but these errors were encountered:
Hey Rob. -thanks for your great work here - really, really cool! I tried to measure the power consumption for my setup for a whole day and finally made it :) Since I struggeled a lot and searched countless forums, i wanted to share my experience how I made it here (in case it is of help to other noobs like me):
Setup:
Aim: Measuring power consumption of an interactive company sign.
ESP32 Wroom Dev Board with multiple sensors (DHT, MIC, LD, Speaker, and multiple LEDs) integrated via ESP Home into Home Assistant.
Power supply. 5v (Measured 5,18 V) with a maximum of 18 amps (unlikely to be ever drawn - standard would be up to 8 a)
ACS712 with 20a threshold
Wiring: ACS712 connected directly (without any voltage divider) to GPIO34
Relevant Code used for the ESP32 within ESP Home:
`esphome:
libraries:
includes:
esp32:
board: esp32dev
framework:
type: arduino
sensor:
platform: adc #Displays the value measured at the GPIO of your ESP32 - for control purposes - can be deleted if finished
pin: GPIO34
name: "Stromsensor für Leistungsaufnahme"
update_interval: 5s
attenuation: auto #Essential part for the ESP32 since they are otherwise skipping out any voltage higher 1,01V - Alternative Calibration can be done
platform: custom
lambda: |-
auto acs712_sensor = new ACS712Sensor();
App.register_component(acs712_sensor);
return {acs712_sensor->current_sensor, acs712_sensor->power_sensor};
sensors:
unit_of_measurement: A
accuracy_decimals: 2
unit_of_measurement: W
accuracy_decimals: 2
`
Within the File ACS712.h that I shared by @marianomd I had to do the following minor adjustments
Hope this is the correct way to share this and that it helps someone with as little experience as me :-)
The text was updated successfully, but these errors were encountered: