I know! Youāre thinking: āOh god⦠another ESP temperature and humidity silly projectā¦ā but wait! Here are the characteristics that might interest you:
- this data loggerĀ can run for 55 daysĀ before theĀ memory is fullĀ (considering a 15 minutes sampling rate and a 64K SPIFFS)
- ItĀ can run for 43+ monthsĀ before runningĀ out of batteryĀ (considering a 15 minutes sampling rate)
- You can easily turn on/off Access Point Wifi mode to pair it with your cell phone (or tablet, laptop etc.) to download the data in a snap!Ā (<- thatās what is uncommon!)
Why I created that project? Because I needed to log the temperature and humidity with a 15 minutes rate during a 6Ā days backpacking expeditionĀ through theĀ Gran Desierto de AltarĀ (111+miles). I needed it to beĀ cheap,Ā reliable,Ā precise,Ā easy to useĀ and most of all that couldĀ run for daysĀ without having to either free memory space or recharge the batteries.
How I built it? Follow the steps!
You love it? Please vote!
Here:Ā https://www.instructables.com/contest/Microcontrolā¦
And here:Ā https://www.instructables.com/contest/sensors2017/
Step 1: Parts List
The pars are quite easy to find (Amazon, Ebay, local dealer etc.) and relatively cheap:
- 1 xĀ ESP8266Ā version ESP07 (my favourite)
- 1 xĀ SI7021Ā temperature and humidity industrial sensor, I2C connectivity
- 1 xĀ LT1529-3.3Ā 3.3V voltage regulator with ultra-low quiescent current
- 1 x 22µF 100V electrolytic capacitor
- 1 xĀ 1900mAhĀ 3.7V LiPo/Li-ion battery
- 1 xĀ TP4056Ā Li-ion charger board
- 2 x single rowĀ male headers
- 2 xĀ Slide switches
- 2 xĀ Momentary pushĀ buttons
- 1 xĀ Plastic enclosure
- 1 x piece ofĀ aluminium screen
You will also needĀ regular electronics toolsĀ like soldering iron, pliers, wires etc., aĀ hot glue gunĀ and aĀ FTDI232 3.3VĀ programmer.
Step 2: Solder the Parts Together
We are going to build the circuit.
First we need to wire the ESP properly:
- wire GPIO15 to GND (mode configuration)
- wire GPIO02 to VCC (mode configuration)
- wire EN/CH_PD to VCC (to enable the chip)
- wire GPIO16 to RST (for the deep-sleep wakeup)
- wire a slide switch between GPIO00 and GND, weāll name itĀ program switchĀ (to switch between running and programming mode)
- wire a momentary push button between GPIO04 and GND, weāll name itĀ Wifi buttonĀ (to de/activate Access Point Wifi mode)
- wire a momentary push button between RST and GND, weāll name itĀ Reset buttonĀ (to be able to reset the ESP at any time)
- solder the 2 headers to RX and TX (this will ease the connection between the programmer and the ESP)
Then we can connect the Temp. RH sensor to the ESP:
- wire SIās SDA to ESPās GPIO13
- wire SIās SCL to ESPās GPIO12
- wire SIās GND to ESPās GND
- wire SIās 3.3V VCC to ESPās VCC
Finally we need to build the power setup:
- wire batteryās Pos. to a slide switch
- wire the slide switch to LTās VIN, weāll name itĀ power switch
- wire batteryās Neg. to LTās GND
- wire LTās SENSE to LTās OUTPUT
- wire the capacitor between LTās OUPUT and GND
- wire TPās BAT Pos. to batteryās Pos.
- wire TPās BAT Neg. to batteryās Neg.
Now we can pair the power circuit with the rest:
- wire LTās OUTPUT to ESPās VCC
- wire LTās GND to ESPās GND
At this point, you should be able to see the EPSās and SIās power LEDs turn on when switching on the power slide switch. If not, double check your circuit for openings and shorts, make sure your battery is fully charged.
The LEDs draw unnecessary current and must be removed by either desoldering them or carefully ādestroyingā them with pliers.
Here is a breadboard schematic view of the circuit, you can download the Fritzing fileĀ here.
Step 3: Send the Program to the ESP
To flash the ESP we will use the Arduino IDE. Itās almost as easy as flashing an Arduino.
Make sure theĀ power switchĀ is turner off.
First connect your FTDI programmer as follow:
FTDI pin | ESP pin |
---|---|
RX | TX |
TX | RX |
GND | GND |
Do not connect FTDIās VCC to ESPās VCC as ESP is already powered by the battery and it could damage it.
Connect the programmer to your computerās USB port.
Install Arduino IDE: see the first step of one of my Ibles.:Ā https://www.instructables.com/id/IoT-Door-Alarm-UPGRADED/#step1
Download the SI7021 library and uncompress it in the Arduinoās Library folder:Ā https://github.com/LowPowerLab/SI7021/archive/master.zip
Download the latest version of the code from my Github:Ā https://github.com/ClemRz/EspDataLogger/archive/master.zip
Unzip the file in the Arduinoās folder and openĀ EspDataLogger/software design/ESP8266_data_logger/ESP8266_data_logger.inoĀ with Arduino IDE.
Set theĀ program switchĀ so there is continuity between GPIO00 and GND, this isĀ program modeĀ (V.S.Ā run mode).
Turn on theĀ power switch.
Push the Upload button of the Arduino IDE, the ESP should be flashed with the firmware smoothly.
Set theĀ program switchĀ toĀ run mode.
Step 4: [Optional] Code Documentation
In this step I explain roughly how the software/firmware works.
There are 2 main āfunctionsā:
- one that logs the temperature and humidity in a very power-efficient manner
- another that activate the wifi and provide a UI to serve data and parameters
When the ESP starts or wakeup, it runs theĀ setupĀ function where we read GIPO04, the one connected to theĀ Wifi button.
- If this pin is high it means that the button is not pressed (due to internal pull up resistor). In this case we will read the sensor, store the value read into the file and go to sleep for an amount of time defined by the sampling rate parameter.
- If it is low, it means that the button is being pressed and instead of logging a new set of values we will activate the Wifi in the Access Point mode and serve a web page. This web page provide a form with different fields to allow visualisation, download and actions such as:
- delete the file from te EEPROM memory
- change the value of the sampling rate parameter (wakeup rate)
- reset the ESP
- etc.
If you want to know more about it feel free to check theĀ readmeĀ fileĀ here.
Step 5: Preliminary Tests
Before moving everything into a nice enclosure we will make sure that it is working as designed.
Turn on the Access Point / Wifi doing the following:
- Make sure the circuit is energised
- Push and maintain pushed theĀ Wifi button
- Push and release theĀ Reset button
- Wait for 3 seconds
- Release theĀ Wifi button
Using any wifi enabled device, like a smart phone, a tablet or a computer, search the open wifi signal namedĀ espDataLoggerĀ and pair with it.
Using a web browser on the paired device, visit the following url:Ā http://192.168.4.1
You should see a UI similar to this one:
Source: Temp. and RH Data Logger With Wifi UI