Outdoor Temperature Humidity Sensor with an ESP32 and Esphomeyaml

Yes. But today I took the Lolin32, soldered two 68k resistors (I ran out of 100k) onto it and voila, battery voltage measurement works with Esphome just as it did with board that have this built in (like in TTGo T-display or TTGO T7). So I’d begin with soldering those two resistors before spending some more money on a new board :slight_smile:

neat!
so for soldering idiots like me: I go pin 34 (or any ADC) --> 100k resistor -> 100k --> + from battery. right?

resistors should be inline or parallel?

This is how the resistors should be soldered/connected:

(I soldered R1’s lead through 35 hole and then R2’s lead to R1’s lead. Get a conical tip for your soldering iron because you want to be neat when soldering Batt+ terminal)

I chose GPIO35 because it’s easier to solder into (the WROOM module chassis!) but GPIO34 is fine as well. The voltage divider means that for full battery (4.2V) the ADC will read out around 2.1V, although there’s stuff about vref fuses, calibration etc. – the best would be to start measuring, use a multimeter to check battery voltage at the same time and fine-tune the multiplication of voltage measured by ADC (“filter” section below). The multiplication factor for me turned out to be around 1.8.

Here’s the relevant part from Esphome config yaml:

sensor:
  - platform: adc
    pin: GPIO35
    attenuation: 11db
    name: "Lolin32 V Battery"
    id: lolin32_vbatt
    update_interval: 60s
    filters:
      - multiply: 1.8
2 Likes

Thanks =)

it works pretty good here on a breadboard. Right now it runs for 8h on a fully charged 18650 and the measurement looks good.

the values flunctuate a bit but I think thats inside an acceptable range. (see the attached image)

log output (adc update interval set to 2 seconds):

esp32_6/sensor/esp32_6_voltage/state 3.95
esp32_6/sensor/esp32_6_voltage/state 3.91
esp32_6/sensor/esp32_6_voltage/state 3.95
esp32_6/sensor/esp32_6_voltage/state 3.91
esp32_6/sensor/esp32_6_voltage/state 3.95

on what voltage should the shutdown be triggered? right now I moved the logic to a HASS automation but I’m uncertain if this should be better stored in the esphome config…

Screenshot_2021-01-27 Übersicht - Home Assistant

I like this collaboration, I’ve used some of your knowledge, you’ve used some of mine :sunglasses:

The values fluctuate a bit because a voltage source (battery) has a voltage drop when there is current drained, batteries are also sensitive to temperature, and esp32’s ADC basically sucks :wink:
From what I read, 3.7 V lithium battery should not be drained below 3.2 V, according to some sources 3.0 V is an absolute minimum (and there’s a minimal amount of energy between 3.2 and 3.0 so it makes no sense to discharge so deeply).

My Lolin32 with a single 18650 cell runs for a third day now with a small voltage drop so far (14 minutes of deep sleep + 30 seconds of running to report BME280 measurements to MQTT broker).

Dang! Thanks again to @Tomash =)
All 3 battery powered esps run now with a voltiage divider and report the correct (+/- 0.02 on repeated readings) voltage of the battery.

I’ve run in a pretty stupid error with incorrect readings on on sensor and learnt my lesson: let HASS manage the shutdown automation (which can be disabled)… The esp will run into an shutdown loop in somehow the ADC reports wrong or no values…

imho the easiest way to do that is to send an “alarm trigger” if the battery drops below a certain value

    on_value_range:
      - below: 3.29
        then:
          - mqtt.publish:
              topic: $devicename/low_voltage
              payload: "true"

for convienient reasons here the updated version of the esphome sketch:
ESP32 + DeepSleep + OTA Awake Switch + ADC report for Battery Voltage

If requested I’ll post the links to the HASS package and lovelace configs.

As always, comments or questions are highly appreciated!

2 Likes

I’ve soldered a 220 uF electrolytic capacitor between 3V3 and GND pins on ESP32, should help with the battery voltage dips due to power usage spikes (which batteries don’t like) while increasing deep sleep current by no more than 10-20 uA. Tests are underway :cowboy_hat_face:

Hello sir, I think if you use Wemos then in deep sleep it draws about 1mA or more, because of voltage converter and USB interface. You could probably lower the deep sleep current 10 or 100 times if you use just ESP32 plain chip, have you tried that? Thanks, Jan

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.