ESP-01 + DHT11 temp/humidity + 18650 battery

1,667 views
Skip to first unread message

bre...@hatcher.co.za

unread,
Feb 8, 2021, 10:36:55 AM2/8/21
to London Hackspace
Hi again

I am creating a digital thermometer to demonstrate IoT (communicates with Node-RED on a Raspberry Pi via MQTT). 
It needs to be battery operated.
It doesn't need to be super power efficient, as it won't stay on all the time, only during workshops.

1. I know that the battery will need a charger with overcharging protection.
I have a 18650 charger, so I could just pull the battery out and charge it.

2. I will need to protect against over discharge, and for that I'll need a module.

3. I also need a way to reduce the battery output voltage to 3.3 for the ESP-01.
The DHT11 can handle 3 to 5V.

I think I can use a TP4056 to handle items 1 and 2.

I don't know how to handle item 3.
I have a DC to DC converter with a pot to set the output voltage.
But since the battery output voltage decreases over time, eventually the voltage is too low for the ESP-01 and/or DHT11 to function.

Does anyone have any suggestions?

Thanks
Brendon

Jon Russell

unread,
Feb 8, 2021, 10:57:47 AM2/8/21
to London Hackspace
Unless you are hell bent on use an ESP01, there might be an easier option.
I'm a big fan of the Wemos D1 mini. Still ESP8266 based, but in a more useful form factor.

There are a bunch of ready made shields for it:
Battery shield with charging and under voltage protection - https://www.wemos.cc/en/latest/d1_mini_shield/battery.html

Solder them together in a stack, and voila, instant solution :-)

Also, if you install Tasmota (https://github.com/arendst/tasmota/) with no coding, just a bit of config in the GUI, you will have an MQTT message with the temp and RH sent out every 5 minutes automatically, and over the air updates and config.
The ESP01 can run Tasmota, but you need to be careful about flash storage space. Some earliy ESP01 modules only have 512MB, which isnt enough for OTA updates. The Wemos D1 mini has 4MB.
:-)
 
I hope this helps.

Jon.

Toby Catlin

unread,
Feb 8, 2021, 11:08:26 AM2/8/21
to london-h...@googlegroups.com
I used a bunch of Wemos D1 mini for my MQTT project and they are great I did use the SHT30 Shield too but found the heat from the board affected the temp sensor. I use a mcp9808 breakout board which are more accurate and can be mounted away from the Wemos board.

However I would offer my suggestion of these:  https://uk.banggood.com/LILYGO-TTGO-ESP32-WiFi-+-bluetooth-18650-Battery-Protection-Board-0_96-Inch-OLED-Development-Tool-p-1213497.html

They take a 18650 battery with all the necessary management circuits. They also have a little screen which is great for displaying status and its the ESP32 which are more powerful than the ESP8266


toby

--
You received this message because you are subscribed to the Google Groups "London Hackspace" group.
To unsubscribe from this group and stop receiving emails from it, send an email to london-hack-sp...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/london-hack-space/57eb32dd-c9f2-4983-9d21-09ad5a2c5dc2n%40googlegroups.com.

Matthew

unread,
Feb 8, 2021, 11:11:34 AM2/8/21
to London Hackspace
Hi Brendan,

If the focus is more on the code / IOT side rather than building the hardware there's lots of off the shelf solutions with the required charging controllers, step ups, etc as Jon has pointed out.

I found this one on Aliexpress. It's an ESP32 rather than an ESP8266, but code wise they're pretty much identical - https://www.aliexpress.com/item/1005001874178225.html It also has a bonus moisture sensor.

Hope that helps.

Christian Valdivia Torres

unread,
Feb 8, 2021, 11:35:02 AM2/8/21
to london-h...@googlegroups.com
Hi, to supply the 3.3v there are two standard ways: 1) linear voltage regulators, they are used when the device is connected to main because to bring down the voltage they waste energy in heat;2) switching boost/buck converters, more espensive, more space but more efficient for battery powered. Look up on google/youtube for how to set them up, both very simple.
C


--
You received this message because you are subscribed to the Google Groups "London Hackspace" group.
To unsubscribe from this group and stop receiving emails from it, send an email to london-hack-sp...@googlegroups.com.

Christian Valdivia Torres

unread,
Feb 8, 2021, 11:41:54 AM2/8/21
to london-h...@googlegroups.com
Ps. If you use lipos your voltage should never fall below 3.0v so i guess the thing might more be around how to shot down the device if the voltage goes below 3. something..

bre...@hatcher.co.za

unread,
Feb 8, 2021, 11:44:30 AM2/8/21
to London Hackspace
Hi Jon, Toby, Matthew and C...

Thanks.  I used the ESP-01 simply because I had some!
The lack of USB connection is a real pain, easily solved by specifying the Wemos D1 mini instead.

I like the extra GPIO pins on the Wemos.
The ESP8266 is overkill for this specific purpose.

Does the Wemos battery shield handle over and under voltage on the battery?
Will it handle the conversion from the 18650 voltage to 3.3V consistently as the 18650 voltage drops?

I'll probably stick to the DHT11 because I have some, but also because, from a teaching perspective, I like the fact that it is a separate board that I can point to!

Finally, since I have 2 ESP-01 boards, 2 DHT11 boards and 5 18650 batteries, if anyone has further input on my original build, that would be great.

Switching boost/buck converters - since I want to reduce 4.2 to 3.3V I need a buck converter?  Or is a "Switching boost/buck converters" a single phrase for a specific thing?

Regards
Brendon

bre...@hatcher.co.za

unread,
Feb 8, 2021, 12:30:54 PM2/8/21
to London Hackspace
Well, my 18650 battery cases just arrived, so I inserted a battery and tested the output voltage with a multimeter - 4.2V
I attached my DC to DC converter, and trimmed the pot to provide 3.3V on the output side.
Attached that to my circuit, with the following results:

- the output voltage decreased to 2.8V, too low for the ESP-01
- the ESP-01 started producing a high pitched whine - a mystery to me, as I see no way it can generate sound
- the ESP-01 did not start its onboard webserver, nor did it broadcast to node-RED via MQTT

I have clearly ventured far beyond the borders of Monkey-See-Monkey-Do land, into a place called You-Actually-Have-To-Understand Land.
I wish I had a map!

B

Jim Hayes

unread,
Feb 8, 2021, 12:41:37 PM2/8/21
to London Hack Space
If I recall correctly (not always the case) the buck convertors can
only convert down to a voltage a volt or two below their input voltage
(if that makes sense?) so that sounds plausible.
To get you going right now, try 2 18650s in series to give you an 8.4
volts input and adjust the buck output to 3.3v once more - see if it
works!
> To view this discussion on the web, visit https://groups.google.com/d/msgid/london-hack-space/063d8840-45b2-4fc1-85cd-4c6eb7f41042n%40googlegroups.com.

Michael Cullen

unread,
Feb 8, 2021, 12:41:59 PM2/8/21
to london-h...@googlegroups.com
If it’s a decent converter (a buck regulator or similar), loading it shouldn’t affect it like that unless you’re pulling too much current - they use a potential divider on the output to compare it to a known internal reference, which forms part of the feedback loop for the regulator. You could try pushing up the trim pot a bit to see if you can get 3.3v out of it I guess.

The high pitched noise is likely the thing oscillating because it isn’t getting enough voltage. My guess is it shuts itself down, the voltage rises, it tries to start up but then the voltage drops and it shuts down again.

Some 18650 cells are protected internally (current limited, over and under voltage protected) - they’re a lot easier to work with, but that current limit can bite you if you hit it (I think I did once with a GSM module)

Basically it seems like either something is pulling too much current or your power supply setup is too weedy.

Michael

Michael Cullen

unread,
Feb 8, 2021, 12:44:52 PM2/8/21
to london-h...@googlegroups.com
Depends on the converter.

To get the most power out of a lithium cell you really need a boost-buck converter - these can either raise or lower the voltage as the cell discharges. They work by being either a boost or buck regulator depending on what’s needed. 

This is probably overkill here though - I mention it because it does nicely demonstrate that a good buck regulator can operate with the output close to the input voltage. 

Check the specs on the regulator if you’re curious. 

bre...@hatcher.co.za

unread,
Feb 8, 2021, 1:14:34 PM2/8/21
to London Hackspace
I tried a voltage divider.  The output voltage was correct.
The moment I attach the CH_PD pin from the ESP-01 the voltage in the circuit decreases from 3.2 to 1.5V.
That PIN is used to set the chip to ON.
I'm too much of a noob to understand the actual reason for the decrease.

Logic suggests that I could factor the decrease into my calculation, but that is usually how I blow things up!

Brendon

Christian Valdivia Torres

unread,
Feb 8, 2021, 2:52:53 PM2/8/21
to london-h...@googlegroups.com
If the switching power unit is too much of a hassle and the power dissipation is not a big issue i d go with a standard linear voltage regulator. They are designed to output standard voltage 3.3, 5, 12 etc. Considering you use a battery you won t need decoupling caps to set it up.

Christian Valdivia Torres

unread,
Feb 8, 2021, 2:55:10 PM2/8/21
to london-h...@googlegroups.com
This is a good video about power supply options

JJ

unread,
Feb 8, 2021, 3:13:11 PM2/8/21
to London Hackspace
Have you encountered the Cricket from ThingsOnEdge?  Based on the ESP8266 and incorporates a temperature (but not humidity) sensor it has incredibly low power consumption spending most of its life in deep sleep and can run for anything from weeks to years on a couple of AA batteries.  They can be configured via a webpage for use with MQTT or just to send HTTP POST or GET and although I expected to have to program them for use with my home-rolled heating controller I found I was able to do it with the stock firmware.  Although they're a bit spendy the fact you hardly need any other parts mitigates that and I think there's currently a discount with the code 'PCPRO' from PC-Pro magazine.

Jon Russell

unread,
Feb 8, 2021, 4:40:57 PM2/8/21
to London Hackspace
Hi Brendon,

A couple of things to try...

The voltage across the battery, while not connected to anything (the open circuit voltage) might not be the same when its under load.
Once you have connected the DC/DC convertors, try testing the battery voltage with a multimeter while its actually under load. You may find its less than 4.2v.
The stepdown convertor will only be able to "reduce" the voltage (hence "step down") so if the battery falls to less that 3.3v the stepdown convertor wont be able to maintain 3.3v. 
There is always a drop out voltage across any step down convertor. You will need to check the data sheet for yours, but it could be 0.5v for example. In which case, the battery voltage will need to be at least 3.8v for the DC/DC convertor to produce 3.3v, as 0.5v is "lost" in the convertor.
If you haven't already, check the ESP01 module works using a separate power supply. if you don't have a bench power supply, just charge your 18650 to 3.3v and connect it directly. But be careful.
DOUBLE CHECK the polarity. every time you connect the power. the output voltage dropping to 2.8v and a buzzing sound could be you have it connected back to front, or the module is already toast.
I would suggest you buy a simple USB to serial dongle to program the ESP01. They normally have a voltage regulator on them too, so its a good what to test everything works, before plugging the module in to something else.

And to answer your other questions .. yes, the Wemos D1 mini battery shield has under voltage protection. So it cuts out when the battery drains. It also cuts out when its fully charged too.

Regards,

Jon.


bre...@hatcher.co.za

unread,
Feb 9, 2021, 10:42:04 AM2/9/21
to London Hackspace
Hi

Thanks for the troubleshooting advice.

If I use the 18650 + DC to DC converter, I get the voltage decrease and the whine, and it doesn't work.
If I then take the same circuit and connect it to 3.3 from my bench supply, it does work, and I don't get the whine.
I'm going to park that exploration because I have now ordered a Wemos D1 mini and battery shield.
I think this is going to be a much better kit to specify for my project build.

Regards
Brendon

Jon Russell

unread,
Feb 9, 2021, 11:25:45 AM2/9/21
to London Hackspace
It sounds like your DC/DC convertor is toast. Buzzing from a DC/DC convertor is normally from the high frequency components of the switching circuit. 

Shout or DM if you ned any help once your Wemos arrives.

I have a few blog posts on installing Tasmota and some general electronics and home automation subjects if they are useful:
Regards,

Jon.

bre...@hatcher.co.za

unread,
Feb 11, 2021, 11:12:42 AM2/11/21
to London Hackspace
My Wemos D1 mini and battery shield arrive tomorrow.
For several reasons, I don't want to stack them.
So, if I am going to have the mini and the battery shield next to each other on a protoboard, I need to work out how to connect them.

Do I understand correctly?  The battery shield only needs to connect to the mini on A0, GND and 5V?
It is a real pity that it uses A0 because I was keen to explore adding analogue sensors.

Thanks
Brendon

Nick Reynolds

unread,
Feb 11, 2021, 11:58:04 AM2/11/21
to london-h...@googlegroups.com
A0 is only so you can choose to measure the battery voltage, it doesn't need it.
> To view this discussion on the web, visit https://groups.google.com/d/msgid/london-hack-space/7f2a3f7a-7697-4fe0-a3e7-565692b96ef8n%40googlegroups.com.



--
Nick Reynolds - 950SM|620SC
In the land beyond cleaning where the Dust Donkeys dwell

Jon Russell

unread,
Feb 11, 2021, 3:19:17 PM2/11/21
to London Hackspace
This may be too late but they make a side by side base too :-)


:-)

bre...@hatcher.co.za

unread,
Feb 18, 2021, 3:13:05 PM2/18/21
to London Hackspace
A big thank you to all those who made suggestions and provided advice.

Here is the finished project:

Wemos D1 mini and battery shield - one on either side of the perfboard, juuuuust making contact via the pins!
18650 battery and case
LED
Light dependent resistor

Communicates with my Node-RED dashboard running on a Raspberry Pi via MQTT
Also has an onboard web server that displays the temperature and humidity

I'm going to use it as a digital thermometer around the house, and also to teach kids about Node-RED, IoT, home automation etc

layout.png

Toby Catlin

unread,
Feb 18, 2021, 3:17:04 PM2/18/21
to london-h...@googlegroups.com
well done!

Warning it does get addictive. I have built a current monitor for electricity consumption and a sensor for the gas that counts the LED flashes on the gas meter.
I want to add some sensors to the door locks and ideally have a remotely activated door lock. One of our members built an awesome doorlock actuator for our hackspace door. It allows totally normal operation with a key but can also toggle the handle to lock and unlock from a rfid card.

t

Reply all
Reply to author
Forward
0 new messages