jojo99
September 16, 2023, 5:36pm
1
Hello,
as I found the possibility to disable/enable WiFi in ESPHome I was thinking that this will be a good solution to save energy and minimise WiFi radiation in several places.
In my case it is the first project with a ESP8285 found in a cheap curtain switch SC500W from Ali. After a while to programm it with ESPHome, finally I got it work quiet fine. This curtain relais is controlled by a mechanical push button switch, rf-control and wifi, integrated in HA.
After testing some days and seeing the actor got warmer then expexted, I started to mesure the power consumption.
It uses in power save mode “HIGH” between 7,5 and 10mA while idleing.
Now I thought in some rooms rf-control and pushbuttons is enough and started to turn wifi off, 2min after boot. This works without any problems and after a restart there is wifi for ota etc.
But the consumption in wifi.disable mode is constantly 10mA and never less.
Now my question:
Has got somebody experiences with this and knows if this is normal?
What does the wifi modul do, when its off but uses full amount of power?
Woud be very appreciated for any helpfull hint and thanks in advance.
jojo99
September 16, 2023, 5:55pm
2
If somebody is interessed in the code:
esphome:
name: "curtain-test"
friendly_name: "curtain-test"
#turn wifi off, set (api: --> reboot_timeout: 0s) to prevent bootloop
on_boot:
then:
- delay: 120s
- wifi.disable:
#esp8266 1MB flash
esp8266:
board: esp8285
restore_from_flash: false
# Enable logging
logger:
# Enable Home Assistant API
api:
reboot_timeout: 0s
encryption:
key: "xxxxxx"
ota:
password: "xxxxxx"
#wifi powersafe mode: NONE,LIGHT,HIGH
wifi:
power_save_mode: HIGH
# fast_connect: true
ssid: !secret wifi_ssid
password: !secret wifi_password
manual_ip:
static_ip:
gateway:
subnet:
dns1:
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Esphome-Web-xxxx"
password: "xxxx"
captive_portal:
# reduce write frequency to flash to avoid wearing it out, adjust it as needed
preferences:
flash_write_interval: 1h
substitutions:
device_name: 'shutter 1'
# for hard restart
button:
- platform: restart
id: restart_button
name: 'Restart ${device_name}'
entity_category: diagnostic
status_led: # onboard LED
pin:
number: 3
inverted: true
# external switches
binary_sensor:
- platform: gpio
id: switch_open
pin:
number: 4
inverted: true
on_click:
- min_length: 50ms # Short press
max_length: 500ms
then:
- cover.open: shutter
- min_length: 1000ms # Medium press / long
max_length: 5000ms
then:
- cover.stop: shutter
- platform: gpio
id: switch_close
pin:
number: 5
inverted: true
on_click:
- min_length: 50ms # Short press
max_length: 500ms
then:
- cover.close: shutter
- min_length: 1000ms # Medium press / long
max_length: 5000ms
then:
- cover.stop: shutter
- platform: gpio
id: stop_button
pin:
number: 13
inverted: true
on_click:
then:
- cover.stop: shutter
# relays
output:
- platform: gpio
id: relay_open
pin: 12
- platform: gpio
id: relay_close
pin: 14
# cover with 1000ms delay
cover:
- platform: time_based
id: shutter
name: '${device_name}'
device_class: shutter
open_action:
- output.turn_off: relay_close
- delay: 1000ms
- output.turn_on: relay_open
open_duration: 40s # adjust it to the actual duration to fully open
close_action:
- output.turn_off: relay_open
- delay: 1000ms
- output.turn_on: relay_close
close_duration: 40s # adjust it to the actual duration to fully close
stop_action:
- output.turn_off: relay_open
- output.turn_off: relay_close
assumed_state: true
#optional
sensor:
- platform: wifi_signal
name: "WiFi Signal Strength"
update_interval: 600s
- platform: wifi_signal # Reports the WiFi signal strength/RSSI in dB
name: "WiFi Signal dB"
id: wifi_signal_db
update_interval: 600s
entity_category: "diagnostic"
- platform: copy # Reports the WiFi signal strength in %
source_id: wifi_signal_db
name: "WiFi Signal Percent"
filters:
- lambda: return min(max(2 * (x + 100.0), 0.0), 100.0);
unit_of_measurement: "Signal %"
entity_category: "diagnostic"
- platform: uptime
name: Uptime Sensor
update_interval: 600s
#timings for push button wall switch
#on_click:
# - min_length: 50ms # Short press
# max_length: 500ms
# then:
# # Some action
# - min_length: 500ms # Medium press
# max_length: 3000ms
# then:
# # Some other action
# - min_length: 3000ms # Long press
# max_length: 10000ms
# then:
# # Some other action
jojo99
September 18, 2023, 2:57pm
3
Because the wifi.disable function in ESPHome is not working like expected, I do try to find a other way.
Now I found another possibility. The modem_sleep_action .
Here it is explained well. https://diyi0t.com/how-to-reduce-the-esp8266-power-consumption/ https://diyi0t.com/how-to-reduce-the-esp8266-power-consumption/
Now I have the problem not knowing how to implement a simple lambda into my YAML.
Is there somebody who could guide me through this, please?
I thieyd to use this code: ESP8266 Turn off WiFi to save power | Circuits4you.com https://circuits4you.com/2019/01/08/esp8266-turn-off-wifi-save-power/
And the beginning of my YAML looks like this now:
yaml
´´´
esphome:
name: “rolladen-test”
friendly_name: “rolladen-test”
on_boot:
then:
- lambda: |-
Serial.begin(19200);
Serial.println(“Turning WiFi Off”);
delay (60000)
WiFi.disconnect();
WiFi.mode(WIFI_AP);
delay (60000)
WiFi.mode(WIFI_OFF);
esp8266:
board: esp8285
restore_from_flash: false
logger:
api:
reboot_timeout: 0s
encryption:
key: “xxxxxxxx”
ota:
password: “xxxxxxxx”
wifi:
power_save_mode: HIGH
ssid: !secret wifi_ssid
password: !secret wifi_password
manual_ip:
static_ip: 192.168.1.00
gateway: 192.168.1.0
subnet: 255.255.255.0
dns1: 192.168.1.0
ap:
ssid: “Esphome-Web-xxxxxxx”
password: “pwd”
captive_portal:
´´´
but it is not working. I get an error while compiling:
error warning
´´´
INFO ESPHome 2023.8.3
INFO Reading configuration /config/esphome/rolladen-test.yaml…
INFO Generating C++ source…
INFO Compiling app…
Processing rolladen-test (board: esp8285; framework: arduino; platform: platformio/[email protected] )
HARDWARE: ESP8266 80MHz, 80KB RAM, 1MB Flash
Dependency Graph
|-- ESPAsyncTCP-esphome @ 1.2.3
|-- ESPAsyncWebServer-esphome @ 2.1.0
|-- DNSServer @ 1.1.1
|-- ESP8266WiFi @ 1.0
|-- ESP8266mDNS @ 1.2
|-- noise-c @ 0.1.4
Compiling /data/rolladen-test/.pioenvs/rolladen-test/src/main.cpp.o
/config/esphome/rolladen-test.yaml: In lambda function:
/config/esphome/rolladen-test.yaml:15:7: error: expected ‘;’ before ‘WiFi’
15 | WiFi.disconnect();
| ^
/config/esphome/rolladen-test.yaml:18:7: error: expected ‘;’ before ‘WiFi’
18 | WiFi.mode(WIFI_OFF);
| ^
*** [/data/rolladen-test/.pioenvs/rolladen-test/src/main.cpp.o] Error 1
========================= [FAILED] Took 12.41 seconds =========================
´´´
jojo99
September 19, 2023, 6:23am
4
After many attempts, I was not able to make this work propperly with the Arduino code… WiFi always resetted and came up again.
But the good thing from the hole story is that wifi:off/on will be fixed soon.
edit:
Fix is allready working, only needs to pass the github ceremony and find its place in the next update of ESPHome.
Can you link the github ticket where this was fixed @jojo99 ? Also did you measure the power consumption again with Wifi turned off and the fix applied?