Building a Battery Powered Mobile Weather Station with ESP8266

One of our beloved traditions at Hipo is our Hack Days. Every couple of months, we pause our regular work for a day to focus on building or designing something. The only rule is that we need to be able to present something about the project at the end of the day. It’s fun, a great excuse to learn something new, and it inspires a lot of creativity.

I tend to gravitate towards hardware projects during Hack Days and my platform of choice has always been Arduino. It’s a simple and comfortable prototyping board, but also offers a lot of challenges in terms of limitations. During the past year however, a new entrant in the hardware prototyping scene has been making a lot of headway with the maker community and I finally got a chance to play with it during our last Hack Day.

ESP8266 is a very low-cost (some module as cheap as $5) WiFi chip manufactured by Espressif. It first started gathering some attention with the introduction of ESP-01 in late 2014, especially after Espressif released an official SDK, allowing the community to build an open source toolchain built on GCC.

ESP8266

Last year, a group from the Arduino community released a version of the Arduino IDE that supports ESP8266. This means that a big part of the existing Arduino toolchain works as is on the device, so building a cheap, standalone, WiFi-enabled hardware module is a breeze.

So what can the ESP8266 do? It depends on the board you are using, and there are a lot of them. The most popular is the ESP-01, especially due to its low cost and simple setup. This module gives you 2 GPIO pins, which is just enough to build a simple standalone device.

Mobile Weather Station

For the Hack Day, we decided to build a mobile weather station. Inspired by Mr. Chilly, a genius little app that shows microclimate temperatures in San Francisco, we wondered if we could gather and visualize such data in any city with small, cheap devices. Using a ESP8266 module was a no-brainer, but it took some work to get it running.

Setting Up

Before you can design and build a project with the ESP-01, or any other ESP8266 board, you need to have a reliable development and testing environment ready. Unlike Arduino, these devices are not plug and play: They don’t come with a USB port to you can use to upload your firmware.

What you will need is an FTDI that will allow you to communicate with the module from your computer’s USB port. There are a ton of options available here, from fully integrated, power-supplying versions to simple USB to TTL UART cables:

We didn’t have the more sophisticated modules handy so we ended up using a simple (and cheap!) USB to TTL cable from Sparkfun. The most important detail when using these cables is to make sure that the I/O pins operate at 3.3V, to match the ESP8266.

Other necessary components were a 4xAA battery holder and a 3.3V voltage regulator to drive power to the ESP-01 module.

To finalize the development environment, we connected everything together:

  • RXD on FTDI cable to TXD on ESP-01
  • TXD on FTDI cable to RXD on ESP-01
  • 3.3V VCC Output on voltage regulator to VCC and CH_PID on ESP-01
  • GND on voltage regulator to GND on ESP-01

Weatherbot Schematic

Last step was taking a deep breath and connecting the USB cable, then running the Arduino IDE. We tested our setup with the ESP8266WiFi library’s WiFiClient sample, and saw the device connect to the Hipo network. Now we could build!

Building the Device

For the temperature sensor, we went with the tried and true DHT-22. It provides humidity and temperature information using a single GPIO pin, so it was perfect for our needs. Once we got everything hooked up, it looked like this:

Weatherbot Diagram

The only difference between the development setup I had described above is the GPIO connection from DHT-22 to the ESP-01. With the sensor in place, we were ready to code.

Software

Best part of using the Arduino toolchain is being able to use all the existing libraries and sample code that the amazing Arduino community provides. In this case, all we had to do was to modify the sample HTTP communication sketch provided with the ESP8266/Arduino project and integrate the DHT library for working with the sensor. You can find the full Sketch, as well as a Flask server for testing requests on the Weatherbot GitHub repo.

Deployment & Visualization

Now that we have a prototype device ready, we are planning to build 20 mobile weather stations and deploy them across Istanbul. Once we start gathering real time data, it will be an interesting challenge to parse, visualize and make it accessible online. We already started experimenting with QGIS and Mapbox to generate beautiful maps from existing data sets. We can’t wait to share more on this project in the upcoming months.

Istanbul Weather Map