Shares

Subscribe to the RNT Newsletter
1) You get a free eBook with 18+ Arduino Projects
2) Join an amazing community of > 55,000 members
3) You'll be the first to hear about new projects and get access to exclusive resources

ESP8266 – Wireless Weather Station with Data Logging to Excel

Shares
This project is a collaboration between Yves Arbour and Rui Santos.

In this project we are going to establish a wireless communication between two ESPs and send data from three sensors to an Excel spreadsheet. This tutorial shows a wireless weather station with data logging that you can implement in your home.

Before you continue reading this project, please complete the following tutorials: 

If you like the ESP WiFi module and you want to build more projects you can download my eBook called “Home Automation using ESP8266” hereLet’s get started!

Summary

Here’s a Figure that describes exactly how everything works together:

introduction esp8266 wireless station

Parts List

Here’s the hardware that you need to make the weather station:

DS18B20 – One Wire Digital Temperature Sensor

In this project, we will be using the DS18B20 one wire digital temperature sensor. Now, before we get to the programming part, lets learn how to wire up our temperature sensor.

The DS18B20 can be powered by between 3.0V and 5.5V so you can simply connect its GND pin to GND and the VDD pin to 3.3V from the ESP8266.

Then connect the DQ pin to IO04 on the ESP8266. A 4K7 ohm pullup resistor is required on the DQ pin to pull it up to 3.3V.

DS18B20 pinout

Reading ADC Value

We’re going to use the ADC pin to read an analog value and when referring to the ESP ADC pin you will often hear these different terms interchangeably:

  • ADC (Analog-to-digital Converter)
  • TOUT
  • Pin6
  • A0
  • Analog Pin 0

All these terms refer to the same pin in the ESP8266 that is highlighted in the next section (read this article for more information on the ADC pin).

Currently, TOUT (Pin6) has a 10-bit precision and its input voltage range is 0 to 1.0 V when TOUT is connected to an external circuit.

Accessing the ESP8266 Analog Pin

With the ESP-201 is very easy to access the ADC, you simply connect a jumper wire to the pin highlighted in the Figure below.

esp-201

Flashing Boths ESPs with NodeMCU

We are going to use the NodeMCU firmware, so you have to flash your ESPs with NodeMCU firmare.

Downloading ESPlorer IDE

I recommend using the ESPlorer IDE which is a program created by 4refr0nt to upload scripts to your ESP8266.

Follow these instructions to download and install ESPlorer IDE:

1) Click here to download ESPlorer

2) Unzip that folder

3) Go to the main folder

4) Run ESPlorer.jar

5) Open the ESPlorer

Uploading a Script to Your ESP8266 (3.3V FTDI Programmer)

The schematics to upload scripts to an ESP are very straight forward. You only need to establish a serial communication between your FTDI programmer and your ESP8266 (repeat the schematics below for the Client and Server).

Here’s the connections:

  • VCC – 3.3V
  • GND – GND
  • TX – RX
  • RX – TX
  • GPIO 0 – 3.3V
  • GPIO 15 – GND

Writing Your Client Scripts

There are three scripts that you need to upload to your ESP8266 client:

Start by uploading the following script and name it counterMax.lua. It is just a numerical number 1 that does some counting and helps reset your board if it looses connection with the ESP server.

When you upload the counterMax.lua script it is expected to print the following error:

uploading counter max

Upload the script below to read the temperature in ºC or upload this script to read temperature in ºF. Make sure you save the file to your ESP with the name ds18b20.lua.

Finally upload the main script to your ESP and name it init.lua.

Client Circuit

Follow this circuit to build your ESP client and if you are using the ESP-12, you can view the schematics here:

weatherStation-201 Sketch_bb

The right switch connected to IO05 is used to simulate wind speed. The program currently doesn’t give a real-time wind speed, but a last 5 seconds wind speed average.

So it doesn’t mater how fast you press right switch. If you push right switch 5 times in the 5 seconds sampling period… that translates into once per second average giving 1.492 MPH or 2.4 KMH (at this point we’re using NodeMCU integer version, so you’ll get 1492 MPH and 24 KMH. You’ll have to divide in the spreadsheet by 100 and 10 respectively).

Writing Your Server Script

Upload the following script to your ESP and name it init.lua.

Final Server Circuit

Follow this circuit to make your ESP server and if you are using the ESP-12, you can view the schematics here.

WirelessWeatherStationServer_201_bbWe’ve created a custom PCB for the ESP-201. Here’s the details:

  • Yellow wire: can either connect GPIO 0 to GND to flash NodeMCU firmware or to VCC to save scripts to ESP
  • GPIO15 is hard wired to GND
  • Reset button and 10K Ohm pull-up resistor to RST pin (in order to reset the board the RST pin has to be pulled down and then has to go back up)

ESP8266 with PCBs

Putting Everything Together

Power both your ESPs and make sure the ESP server still has the serial communication established with your computer, because that’s how you are going to post the data to your Excel spreadsheet.

Downloading and Installing Things Gateway

For this project we are going to use Things Gateway a software by Roberto Valgolio to write data on an Excel spreadsheet and display a self updating real time charts.

Things Gateway is a PC application that connects a microcontroller and makes it able to:

  • Get data from Excel files
  • Write Excel files
  • Write CSV log files
  • Send emails (when certain conditions are met)
  • Show values and charts (charts are Excel independent)

Things Gateway can also connect a GPS and show on the screen:

  • Speed, heading, altitude and other navigation info
  • Real-time tracks in Google Maps

Go to the Things Gateway website, download the program and install it. This project was tested with the Beta4 version.

ThingsGatewaydownload

Launching Your Things Gateway Application

To launch the Things Gateway application is very straight forward. Go to Your PC > Documents > ThingsGateway and open the application.

things gateway app

Then follow these instructions:

  1. Go to the Config tab
  2. Select the Serial COM Port of your ESP8266 Server
  3. Set the Serial port Speed to 9600

 

things config

Demonstration

Open the RealTime tab and select From Serial to Excel.

ThingsGateway

An Excel spreadsheet should appear and your data should start appearing there every few seconds!

ThingsGateway excel

Your data is being stored in the example Excel spreadsheet in that folder:

things gateway example

Future Improvements

In this tutorial we established a basic system to send data wirelessly to an Excel spreadsheet using 2 ESP8266 and Things Gateway software.

With this example, you’ll be able to explore more features from Things Gateway like:

  • Real-time self updating graph (not Excel dependent)
  • Data logging in .csv files
  • Auto email sending when custom conditions are met (strong wind above so many kmh, temp to low… warning of heating system failure or freezer not cold enough etc)
  • Data logging in stream.txt that can be replayed at speed 0.1, 0.5, 1, 5, 10, 60 or 3600 times faster
  • GPS track can also be streamed on Google map at actual speed or 0.1, 0.5, 5, 10, 60 or 3600 times faster

Further development could also include:

  • Other sensors like bmp180 barometric pressure sensor
  • Light sensors
  • Humidity sensor
  • Any other digital or analog sensor with the use of multiplexing

Please note that Things Gateway was designed to use with Arduino board, but as long as you send the proper string via serial, it can be used with any board.

I hope you found this guide helpful and huge thanks to Yves Arbour that created this project!

Do you have any questions or feedback? Leave a comment down below.

Thanks for reading. If you like this post probably you might like my next ones, so please support me by subscribing my blog and my Facebook Page.

Leave a Comment:

Add Your Reply