BMOW title
Floppy Emu banner

Weather Logger with Losant and Amazon Alexa

Like a million other people on the Internet, I’ve been experimenting with home weather logging. I roll my eyes at the phrase “Internet of Things”, but it’s hard to deny the potential of cheap networked sensors and switches, and a weather logging system is like this field’s Hello World application. Back in June I posted about my initial experiments in ESP8266 weather logging. Since then I’ve finalized the hardware setup, installed multiple nodes around the house, organized a nice web page to analyze all the data, and integrated everything with Amazon Alexa. Time for an update.

Hardware

I’ve placed four sensor nodes around the house. At the heart of each one is a Wemos D1 Mini, a $4 Arduino-compatible ESP8266 microcontroller board with built-in WiFi. A Wemos OLED shield is used to display live stats at each node, and a Wemos SHT30 sensor shield collects temperature and humidity data.

My original prototype stacked the three modules on top of each other, but I found that this configuration caused the heat from the Wemos D1 Mini to skew the temperature readings from the SHT30 sensor. The final hardware setup uses a Wemos tripler base to mount the three modules side-by-side. The module is powered by a standard USB cable connected to a power adapter scavenged from some other long-forgotten device. The total hardware cost for the entire node is about $10, which seems amazingly inexpensive.

Three of the nodes are indoors. The fourth is outside on a patio, plugged into an outdoor electric outlet and protected from the elements by a sheet of cardboard. This node doesn’t have any OLED display (nobody is there to see it), and it uses a BMP085 sensor that measures temperature and air pressure instead of temperature and humidity. The outdoor node is unfortunately prone to crazy temperature readings when the direct sun hits its cardboard shield. The cardboard quickly warms in the sunlight, creating an oven effect that boosts the temperature readings to over 100 F, even when there are many holes in the cardboard to encourage airflow. I need to design a better enclosure for the outdoor sensor that’s not as sensitive to the sun.

This hardware setup works nicely where WiFi and electric outlets are easily available. For sensor nodes “in the field” outside WiFi range and requiring battery power, something like a Moteino may be more appropriate.

Software

The software running on each node is very simple: it’s little more than a combination of standard Arduino libraries for each of the modules. There are standard libraries for the SHT30 and BMP085 sensors, for the Wemos D1 Mini’s built-in WiFi, for the OLED display, and for the Losant data logging service. For anyone who’s done much Arduino programming, the glue code that’s needed to tie everything together is simple and can be written in an hour. See my example code.

When first powered on, the node software connects to the local WiFi network using a hard-coded SSID and password. It then connects to the data logging server, as well as an NNTP server to get the current date and time. Once that’s done, it polls the sensor every 15 seconds to get the latest data. The data is displayed on the OLED, and also transmitted to the logging server. Easy peasy.

Logging and Analysis

Displaying live data is nice, but the most interesting part of a weather logger is analyzing the collected data. By examining data over time, and comparing data from multiple nodes, it’s possible to answer burning questions like:

  • When it’s slightly warmer outside than in, will opening the windows cool the house by creating a breeze, or warm the house by admitting warmer air?
  • Does kitchen cooking have a measurable effect on indoor humidity?
  • How slowly or quickly does indoor temperature change in response to outdoor changes?
  • Is it always cooler downstairs than upstairs?
  • What’s the effect of opening specific windows around the house?

After experimenting with many different data logging and display services, I settled on Losant. Their web page looks very business-oriented and intimidating, so I initially thought it would be a poor match for my needs, but I was wrong. The system is easy to use, and is free as long as you don’t have a crazy number of nodes or data records.

Losant powers a custom web dashboard with a mix of graphs and other widgets. The layout, size, and data details are highly configurable, and a single widget can do more than simply displaying the latest sensor reading. For example, it can display the average, min, or max reading from a sensor over a window of time, or compute an aggregate value from several sensors.

My dashboard shows live data from the four nodes, as well as temperature, dewpoint, and atmospheric pressure graphs for the past 24 hours and past 7 days. I learned that downstairs is reliably cooler than upstairs, and that opening those windows really does create a cooling breeze. I found that a person entering a closed room for a few minutes can substantially raise its humidity (all that exhaling). My furnace has a cycle time of 20 minutes, visible in the ripple of the 24 hour temperature graph shown above. The kitchen temperature often shoots up around 4 PM when the afternoon sun comes in the windows. Outdoor low temperature was 51.9 F, reached at 7:15 AM this morning. Saturday’s outdoor low was 41.7 F at 5:40 AM. Lots of interesting stuff.

Amazon Alexa Integration

One of the most interesting features of Losant is its webhook integration. In addition to logging and displaying data, it can also interact with 3rd-party web services. A data update from a sensor node can trigger some related web request, or a web request to Losant’s servers can retrieve stored data, or even trigger a command to the sensors. There are some powerful options, and it’s all configured through a visual programming interface that Losant calls a workflow.

Using this tutorial, I created an Amazon Alexa skill for querying my weather logging nodes. The setup was a bit complex, but the tutorial does a good job of explaining the skill configuration that’s required in the Amazon developer admin interface, and the Losant workflow design. Within an afternoon of fiddling it was all working great. I can ask for the temperature or dewpoint of a specific weather node, using generic language like “temperature” or “how warm is it”. I can also make a general inquiry and have Alexa prompt me for necessary details:

“Alexa, ask the house how hot it is.”
“Which station? You can say kitchen, study, downstairs, or outside.”
“Outside”
“The current outside temperature is 63.1 degrees.”

Most of the interesting configuration work is done in the Amazon admin interface. This is where the various “intents” are defined (specific actions or requests that can be made by the user), and the vocabulary words related to each intent. It’s also where the Alexa skill is given a name, which in my example is “the house”. By beginning a request with “ask the house”, Amazon knows to process the rest of the sentence through my skill template instead of its built-in response templates. Once it determines what I’m asking for, Amazon’s server makes a web request to Losant. The Losant server looks up the desired data and returns it to Amazon, who sends it back to my Echo to be articulated as a spoken reply. Asking for the dewpoint in the kitchen may be pointless, but feels almost like conversing with the Star Trek computer. The future is here!

Read 4 comments and join the conversation 

4 Comments so far

  1. Dillon Nichols - November 21st, 2017 2:53 pm

    I like this a lot. I’ve wanted to do something similar for a while And I think the tripler and shields are the pieces I was missing. The $10 price point per station is really what I wanted to hit. I think I may duplicate this project exactly.

  2. kbob - November 22nd, 2017 7:38 am

    Ask Google about Stevenson screens. They are outdoor sensor enclosures that give good airflow and good shielding from insolation and rain. They are available from many sources, including your own 3D printer.

  3. Jared - December 5th, 2017 8:40 pm

    For the outdoor node, try a reflective sheet over and a distance away from some other sheet, leaving space for air to freely flow between both, as well as the sensor. A fan will improve things further.

    If you really don\’t care about kitchen dewpoint, you can use \”dry bulb\” temperature, dewpoint, and windspeed to get wind chill and heat index.

  4. seth - December 11th, 2017 7:28 pm

    great project! How would you go about making one of these more water tight. Leaving the sensor outdoors, eventually you will get dew or frost on it. How will the electronics behave? Also, how will they behave at temperatures around -40C?

Leave a reply. For customer support issues, please use the Customer Support link instead of writing comments.