Outdoor Temperature Humidity Sensor with an ESP32 and Esphomeyaml

It draws miliamperes due to reasons you mentioned if you power it via USB port.
If powered from battery it’s way more economical in deep sleep, with current draw around 100 uA. The comparison spreadsheet from Andreas Spiess of many ESP32 boards has all the currents actually measured with proper lab equipment:

Hi,
thanks @void for posting this. I’m planning to try this out as my first project of this kind.
Since I want to use this sensor outdoor the whole year battery life might be an issue. A parallel connection between two batteries should double the times between charges, right?
How do you charge the batteries, do you just connect a charger via micro usb to the board? Is an extra charger needed?
Thanks

hey there,

as proven I’m not an expert when it comes to safety of battery cells :wink: afaik doubling the capacity should better be supervised by some sort of a load balancer circuit…

I have a lot of 18650 cells and charge them in an external charger to reduce node downtimes… imho changing the cell every 2-3 months is ok.

Thanks. Looks like a great project and not too complicated. Just wondering. Since the ESP power consumption is so low, wouldn’t this be a good application for a solar panel for recharging the battery?

How difficult would that be and what products would people recommend for the solar panel and charging system?

18650 battery shield
I use one of these 18650 battery shields with over and under charging protection with 5v 1 watt solar panel. Been running for 7 months. Battery has never gone below 3.67v. During summer(UK) it daily went to 4.2v and then cut off charging to protect battery. I use it with Wemos D1 mini and it’s in deep sleep for 5 mins then runs for 10 sec and back to sleep. BMP280 sensor.

2 Likes

what about winter and -10ish degrees

This winter it hasn’t gone much below -2 C. I use it to determine if my heating should come on an hour earlier or so to bring temp up to daytime comfortable. Inside temps sensors were not enough. It’s been 12 years since we got down to -17C in winter here. Don’t think there is much chance the lithium battery would perform in that. But then again there is little chance the battery would get anything from the solar panel that early in the morning. Where I have it the sun doesn’t hit it until 10:30.

Was just curious because it’s been consistently -6 to 10f (-21c to -10c) here. I have an automation to shut off my outdoor cameras when it dips below 14f and I haven’t been able to use them in like 3 weeks. It’s driving me crazy but I want the temperature and humidity right outside my house.

I believe LIPO batteries can still discharge down to -20c but not charge below 0.

Andreas Spiess video on cold batteries

The video says different.

1 Like

Guys, how long the humidity sensor lasts, outdoor?
I’ve blown like 3 in 4 months (i live near the sea). All of them gives now 99/100% humidity, even if moved indoor.

I’m looking for a temp/hum sensor that is capable of surviving outdoor for at least 1 or 2 years.

Which sensor are you using?
I am using BME280 and BMP280 for my sensor and it is holding up pretty good until now.

Tried DHT22 and the BME280.The first one lasted about a month, and the BME nearly 3, but then both lost the humidity part.

Would you mind sharing the yaml for your whole sensor/esp? I’d be interested to see how you have it conifgured to sleep etc and also report battery voltage.

Configuration yaml

esphome:
  name: esp12f-test1
  platform: ESP8266
  board: esp01_1m

# Enable logging
logger:
  level: INFO
  
# Enable Home Assistant API
#api:

ota:
  password: "****************"

wifi:
  ssid: "************"
  password: "*******************"
  manual_ip:
    static_ip: 192.168.81.70
    gateway: 192.168.81.1
    subnet: 255.255.255.0
    dns1: 192.168.81.113
    dns2: 8.8.8.8  
  output_power: 14dB

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Esp12F-Test1 Fallback Hotspot"
    password: "*************"
    ap_timeout: 15min    #Set to >1min to prevent going to fallback when HA restarting after an update and run battery down
captive_portal:
switch:
  - platform: restart
    name: "esp12f Restart"

i2c:
    sda: 5
    scl: 4
    scan: true

sensor:

  - platform: bmp280
    address: 0x76
    update_interval: 30s 
    temperature:
      name: Esp12f Temp
      oversampling: 16x
    pressure:
      name: Esp12f Pres
      oversampling: 16x

 
  - platform: adc
    pin: A0
    name: esp12f Battery
    id: battery_voltage_12f
    filters:
      - multiply: 4.81    
    accuracy_decimals: 3
    update_interval: 60s

  - platform: wifi_signal
    name: "esp12f1 WiFi Signal"
    update_interval: 60s      
    
  - platform: mqtt_subscribe
    name: "Sleep time topic"
    id: custom_sleep_time
    unit_of_measurement: ms
    accuracy_decimals: 0
    topic: esp12f1/sleep_mode_time
    on_value:
      then:
       - lambda: |-
          id(deep_sleep_1).set_sleep_duration(id(custom_sleep_time).state);	    
    
mqtt:
  broker: 192.168.81.107
  username: *******
  password: **************
  birth_message:
    topic: esp12f1/birthdisable  #just make sure birth and LWT have diffent subjects to prevent unavailable showing up 
    payload: disable
  will_message:
    topic: esp12f1/willdisable
    payload: disable
  discovery: true
  discovery_retain: true    
  on_message:
    - topic: esp12f1/ota_mode
      payload: 'ON'
      then:
        - logger.log: 'OTA Mode ON - Deep sleep DISABLED'
        - deep_sleep.prevent: deep_sleep_1

    - topic: esp12f1/sleepearly
      payload: 'ON'
      then:
        - deep_sleep.enter: deep_sleep_1              


deep_sleep:
  id: deep_sleep_1
  run_duration: 10s    #backup time in case mqtt fails
  sleep_duration: 5min     


Below are the automations


 
- id: '**********'
  alias: send esp12f sleep early
  description: When HA gets battery reading it sends esp asleep early(this could be changed to pressure or temp state) . Takes up to 9 seconds off the awake time. 
  trigger:
  - platform: mqtt
    topic: esp12f-test1/sensor/esp12f_battery/state
  condition: []
  action:
  - service: mqtt.publish
    data:
      topic: esp12f1/sleepearly
      payload: 'ON'
      qos: '1'
      retain: true
  mode: single
- id: '***********'
  alias: esp12f1 ota off
  description: Turns ota mode off by turning deepsleep on and early sleep on.
  trigger:
  - platform: state
    entity_id: input_boolean.esp12f1_ota
    from: 'on'
    to: 'off'
  condition: []
  action:
  - service: mqtt.publish
    data:
      topic: esp12f1/ota_mode
      payload: 'OFF'
      retain: true
      qos: '1'
  - service: mqtt.publish
    data:
      topic: esp12f1/sleepearly
      payload: 'ON'
      qos: '1'
      retain: true
  mode: single
- id: '*********'
  alias: esp12f1 ota on
  description: Turns deepsleep off and early sleep off
  trigger:
  - platform: state
    entity_id: input_boolean.esp12f1_ota
    from: 'off'
    to: 'on'
  condition: []
  action:
  - service: mqtt.publish
    data:
      topic: esp12f1/ota_mode
      payload: 'ON'
      qos: '1'
      retain: true
  - service: mqtt.publish
    data:
      topic: esp12f1/sleepearly
      payload: 'OFF'
      qos: '1'
      retain: true
  mode: single



- id: '************'
  alias: esp12f adjust sleep time 3.2-3.7
  description: if battery is between 3.2-3.7 then deepsleep time is 10mins
  trigger:
  - platform: numeric_state
    entity_id: sensor.esp12f_battery
    below: '3.700'
    above: '3.200'
  condition: []
  action:
  - service: mqtt.publish
    data:
      topic: esp12f1/sleep_mode_time
      payload: '600000'
      qos: '2'
      retain: true
  mode: restart
- id: '***********'
  alias: esp12f adjust sleep time >3.7
  description: if battery >3.7 then deepsleep is set to 5mins
  trigger:
  - platform: numeric_state
    entity_id: sensor.esp12f_battery
    above: '3.700'
  condition: []
  action:
  - service: mqtt.publish
    data:
      topic: esp12f1/sleep_mode_time
      payload: '300000'
      qos: '2'
      retain: true
  mode: restart
- id: '***********'
  alias: esp12f adjust sleep time <3.2
  description: If battery is <3.2V then deepsleep time is 50mins. Also sends a telegram message to alert me to low battery
  trigger:
  - platform: numeric_state
    entity_id: sensor.esp12f_battery
    below: '3.200'
  condition: []
  action:
  - service: mqtt.publish
    data:
      topic: esp12f1/sleep_mode_time
      payload: '3000000'
      qos: '1'
      retain: true
  - service: telegram_bot.send_message
    data:
      message: ESP12f voltage <3.2V
  mode: restart 

If you wanted to set sleep time for only 2 settings it could be done inside ESPhome. I wanted 3 different deepsleep times and couldn’t figure out how to do it in ESPhome.

  - platform: adc
    pin: A0
    name: Outside Battery
    id: battery_voltage
    on_value:
      then:
      - if:
          condition:
            lambda: 'return id(battery_voltage).state < 3.7;'
          then:
          - lambda: |-
              id(deep_sleep_1).set_sleep_duration(600000);
          else:
          - lambda: |-
              id(deep_sleep_1).set_sleep_duration(300000);
1 Like

Hey,
first of all i really like the idea of the sensor and thats exactly what i search for but unfortunately i‘m a newby with the esp. Are there „noobfriendly“ steps how to setup this sensor?

Noobfriendly in what way?
Hardware or software- wise?

do you any esp on hand?

He is comparing all of those