Temp. and RH Data Logger With Wifi UI

3,857

69

7

Introduction: Temp. and RH Data Logger With Wifi UI

About: I'm a web developer and I enjoy outdoors a lot

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:

  1. wire GPIO15 to GND (mode configuration)
  2. wire GPIO02 to VCC (mode configuration)
  3. wire EN/CH_PD to VCC (to enable the chip)
  4. wire GPIO16 to RST (for the deep-sleep wakeup)
  5. wire a slide switch between GPIO00 and GND, we'll name it program switch (to switch between running and programming mode)
  6. wire a momentary push button between GPIO04 and GND, we'll name it Wifi button (to de/activate Access Point Wifi mode)
  7. 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)
  8. 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:

  1. wire SI's SDA to ESP's GPIO13
  2. wire SI's SCL to ESP's GPIO12
  3. wire SI's GND to ESP's GND
  4. wire SI's 3.3V VCC to ESP's VCC

Finally we need to build the power setup:

  1. wire battery's Pos. to a slide switch
  2. wire the slide switch to LT's VIN, we'll name it power switch
  3. wire battery's Neg. to LT's GND
  4. wire LT's SENSE to LT's OUTPUT
  5. wire the capacitor between LT's OUPUT and GND
  6. wire TP's BAT Pos. to battery's Pos.
  7. wire TP's BAT Neg. to battery's Neg.

Now we can pair the power circuit with the rest:

  1. wire LT's OUTPUT to ESP's VCC
  2. 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.

circuit

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 pinESP pin
RXTX
TXRX
GNDGND

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:

  1. Make sure the circuit is energised
  2. Push and maintain pushed the Wifi button
  3. Push and release the Reset button
  4. Wait for 3 seconds
  5. 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:

UI

Congrats, you made it!

Step 6: Put It in a Nice Enclosure

Using a hot glue gun fasten securely all the parts in the enclosure except the voltage regulator which could potentially get hot (it shouldn't though) that I fastened with a screw.

To prevent the buttons from being unintentionally activated in a backpack or a pocket I made the choice to left them inside the enclosure. The drawback of this is that I have to unscrew the enclosure to have access to them. You can make the choice to drill some holes and let them accessible from the outside, it's your call.

open

One end of the enclosure is replaced by a piece of aluminum screen so the air is free to flow to the sensor, it also prevents small object to intrude. If your enclosure has no removable end you can drill a hole and glue the screen.

closed

Step 7: Results

I attached a sample CSV file (downloaded directly from the UI) and a Excel file I built for its interpretation.

Step 8: Final Thoughts

This project is quite cheap, under 20USD, and may gives you more ideas on how to build a nice autonomous, efficient, Wifi enabled, data logger!

Please post your comments below if you have any question.

Also don't hesitate to post pictures of your version!

Thank you for reading.

Sensors Contest 2017

Runner Up in the
Sensors Contest 2017

Microcontroller Contest 2017

Participated in the
Microcontroller Contest 2017

Be the First to Share

    Recommendations

    • Make It Bridge

      Make It Bridge
    • Big and Small Contest

      Big and Small Contest
    • For the Home Contest

      For the Home Contest

    7 Comments

    0
    Michal Choma
    Michal Choma

    3 years ago

    Hello, very nice and useful thing, but I have problem. I would like to connect BMP280 sensor and use wemos insted of bare ESP8266. I have problem with turn to AP my wemos when I use in code BMP280 sensor. Dont know why. I start normally BME with command

    "if (!bme.begin()) {
    Serial.println("Could not find a valid BMP280 sensor, check wiring!");
    while (1);
    }"

    I dont know how to replace command in your ini function
    " bool ok = _sensor.begin(SDA, SCL); "
    it totally doesnt work. Nah.

    0
    ClemRz
    ClemRz

    Reply 3 years ago

    I'm sorry I've never used Wemos.

    0
    Michal Choma
    Michal Choma

    3 years ago

    and how device know exact time of individual measurement? Or doesnt add to every measure time and date?

    0
    ClemRz
    ClemRz

    Reply 3 years ago

    I doesn't. It's approximately wakes up in a periodic way. Via the web UI, either when you reset the internal memory or when you download the file a timestamp is added by the browser you're using. If you know how to use a spreadsheet it is easy then to compute the date of each log line.

    0
    ozguratak0
    ozguratak0

    Question 4 years ago on Step 8

    Hi, I didn’t find the LT1529 3-3. So that, can I use LP33CV for alternative? Thank you.

    0
    ClemRz
    ClemRz

    Reply 4 years ago

    Yes of course!

    0
    fdaprz88
    fdaprz88

    6 years ago

    Super! I loved being part of the official trial of this data logger <3 Congratulations on your amazing job creating this project! More to come from Clement Stark (hopefully a robot or at least a super hero outfit for me to wear on my next backpacking trip haha).