As I have the energy monitoring working well, I thought it might be a nice idea to have an OLED display running off an ESP that shows real time energy consumption: a visual reminder to save energy as every time we look at the number its going up…
As we are supposed to be saving energy with this it would make sense to run it off a battery, so my idea is a motion sensor to wake up from deep sleep and display the data. However I have run into an interesting problem testing this out - the esp32 shuts down and restarts by the deep sleep code, but the display stays on and still draws some current. So, is there any way to completely turn off the OLED at the same time?
Snippet of the code that runs without the wake up from the PIR:
captive_portal:
font:
- file: "arial.ttf"
id: font1
size: 22
- file: "arial.ttf"
id: font2
size: 14
time:
- platform: homeassistant
id: homeassistant_time
sensor:
- platform: homeassistant
id: Energy_Sensor
entity_id: sensor.house_daily_energy
- platform: homeassistant
id: Consumed_Energy_Sensor
entity_id: sensor.total_consumed_daily_energy
- platform: homeassistant
id: Hidden_Energy_Sensor
entity_id: sensor.hidden_daily_energy
- platform: adc
pin: GPIO35
name: "battery"
unit_of_measurement: "V"
icon: "mdi:battery-high"
device_class: "voltage"
state_class: "measurement"
accuracy_decimals: 2
attenuation: 11db
filters:
- multiply: 2.0
i2c:
sda: GPIO21
scl: GPIO22
display:
- platform: ssd1306_i2c
model: "SH1106 128x64"
# reset_pin: D0
address: 0x3C
id: my_display
pages:
- id: page1
lambda: |-
it.printf(0, 0, id(font2), "Current Energy:");
it.printf(23, 25, id(font1), "%.3f kWh", id(Energy_Sensor).state);
it.strftime(64, 64, id(font2), TextAlign::BASELINE_CENTER, "%H:%M", id(homeassistant_time).now());
- id: page2
lambda: |-
it.printf(0, 0, id(font2), "Consumed Energy");
it.printf(23, 25, id(font1), "%.3f kWh", id(Consumed_Energy_Sensor).state);
it.strftime(64, 64, id(font2), TextAlign::BASELINE_CENTER, "%H:%M", id(homeassistant_time).now());
- id: page3
lambda: |-
it.printf(0, 0, id(font2), "Hidden Energy:");
it.printf(23, 25, id(font1), "%.3f kWh", id(Hidden_Energy_Sensor).state);
it.strftime(64, 64, id(font2), TextAlign::BASELINE_CENTER, "%H:%M", id(homeassistant_time).now());
interval:
- interval: 8s
then:
- display.page.show_next: my_display
- component.update: my_display
#binary_sensor:
# - platform: gpio
# pin: GPIO13
# name: "PIR Sensor"
# device_class: motion
deep_sleep:
run_duration: 30s
sleep_duration: 5min
switch:
- platform: gpio
pin: GPIO5
name: "LED"