IT Strategy

How to Build a DIY Home Weather Station With ESP8266

This is my English translation of the article originally published in Geek Times.

A couple of years ago I purchased esp8266, a cheap Wi-Fi chip with full TCP/IP stack and micro controller capability manufactured by Espressif. My idea was to build something useful for my home using this controller. Such features as Wi-Fi connectivity, small size, enough inputs / outputs and ease of programming make esp8266 a perfect controller for enabling home automation. I eventually decided to build a home weather station.

Basic system requirements:

Check out a related article:
  • Remote view of data being analyzed
  • Remote control
  • Display for real-time data view
  • Ease of connectivity and USB charging
  • Data transmission to home server for collection of insights, data visualization and more
  • Scalability of connected sensors
  • Simultaneous use of many weather sensors
564d5e527195477081d617eae12bbba6

My first step was to find existing systems I could use for a prototype. As I explored available systems I understood none of them would meet my requirements either because of the closed code or because they charge extra fees for letting you get advantage of all features you need. Therefore, I chose to invent my own bicycle. To take my project from the ground up, I had to deploy software and hardware first. I bought the following components on eBay:

  • NodeMCU board
  • LCD TFT Display 320х240 based on ILI9340C
  • DHT22 sensor
  • BMP180 sensor
  • Prototyping boards (5х7 см)
  • Micro USB chip

For software development I chose a simple PHP + MySQL stack based on Raspberry PI and deployed to home server. Its advantage over Cloud services is system stability in case of black-out or disconnection. Although I had to program back-end for data storage and processing, I was excited to do so! Arduino IDE fitted with an esp8266 module was chosen as a programming environment, check out details here.
My plan A was to program everything in Lua (nodemcu), but I had to refuse from it because I'd run out of memory each time I uploaded sketches. For data exchange between Raspberry and my weather station I chose JSON.

I used standard methods of sensor connection to module and found relevant libraries here:

This library was helpful, too.

Here're additional sensors you can connect and configure for data collection and analysis:

Right now I'm waiting to receive MHT-Z19 CO2 sensor to monitor CO2 level in the air (indoor and outdoor). Once I've got it, I'm going to extend weather parameters I'm tracking at home.

After several iterations of code bug fixing and prototyping I was ready to assemble my home weather station.

Device circuit

675f6fc3f413434babf69ac0a7ecb605

At first, I made a display opening in a plastic box:

9c341662c8a946b28ebfee00ee157ea4

Then I embedded the display inside along with a hardware board, module and sensors. Reset button was deployed, too.

67eee227dd4f46cd8450e8437a32dfa7

I made holes in the front plates of the box for sensors ventilation and power connectors.

c8bbdbd0091c47958f4d33126751df61


I deployed a remote control in the module firmware using a web server. It allowed me to set up and configure the device with regards to:

  • Wi-Fi network to connect to
  • Sensors to be used
  • Real-time module setup
  • Data view from connected servers
  • Sensors to be reloaded, etc

I used responsive design to control my weather station remotely from a smartphone. Built-in pages don't have any external dependencies, all styles and scrips are being stored in modules memory.

41d33f02cef54881961b5a84fe183aca

I also created a basic website to view a list of connected modules, generated data and graphs and deployed it to Raspberry.

530568c9adc845c391b0ff8d19803c95

What is yet to be deployed?

  • NTP time sync
  • In-module data aggregation in case of disconnection
  • Authentication on data viewer server
  • Sensors connection to certain users
  • Data visualization
  • Outdoor sensor
  • Relay control
  • Ability to generate data from door / window open sensors
  • Making changes to generated data for analysis of in-box sensors.

Feel free to view the project code on GitHub.

Let's talk!

And have you experimented with DIY home automation? Please share your experience as a comment below or send us a tweet to @Intersog!

IT Storyteller and Copywriter
Andrew's current undertaking is big data analytics and AI as well as digital design and branding. He is a contributor to various publications with the focus on emerging technology and digital marketing.