Creating Alexa Skills for IoT and Nodemcu - Part 1 Design

Let's Make Alexa Interact with Nodemcu

In this post I will we create a solution that allows Alexa to read sensor data collected by a Nodemcu and a DHT11/DHT22 sensor.

Go to Part 2


I collect temperature and humidity data with Nodemcu and DHT11/DHT22 sensors throughout my house. I have been storing the data in Graphite, which is a proven time-series database solution. Graphite is traditionally used in the context of monitoring IT systems such as server and application performance. I visualize the sensor information with Grafana

This is great for me, but let's say my wife wants to know the temperature in our daughter's room... I would quickly learn that what seems great to me does not create a simple experience for others. So how would I go about making a method that my wife would actually use? My answer is Alexa.

I will use a the inexpensive ESP8266 based Nodemcu and a DHT11 or DHT22 sensor to collect temperature and humidity data. We will use Arduino to do the programming and some AWS services to create a service that we can send temperature and humidity data to, so that Alexa can interact with it.

A WORD OF CAUTION: A few different AWS services are used in this guide. These can be used free, but make sure you understand how AWS calculates billing for any service you use.


  • Collect Temperature and Humidity using Nodemcu and DHT11 or DHT22
  • Use Alexa to retrieve and read the current temperature or humidity
  • Use "free" cloud services


The following design will meet the goals of the project without deploying servers or containers.

Here is the proposed solution:
  1. Each Nodemcu will have a Thing Shadow created in AWS IoT. The Nodemcu will write temperature and humidity to AWS IoT Thing Shadow using the AWS IoT SDK.
  2. When the user asks Alexa "what is the current" temperature or humidity for a room, Alexa will call on an Alexa Skill.
  3. The Alexa Skill will connect to AWS Lambda. The Lambda code will use python to connect to AWS IoT and gather the current state of the Thing Shadow.
  4. The state of the Thing Shadow will be returned to Alexa and read aloud.

Security Design Considerations

A requirement of AWS IoT thing interaction is certificate based encrypted communications. At the time of this post, Nodemcu does not support the required TLS 1.2 encryption. The AWS IoT SDK is used as a work around to get a one way stream of sensor data into AWS IoT.

This is not ideal, because credentials will have to be included in the sketch. When we place credentials on our Nodemcu, they are written in clear text. Even if you encrypt or obfuscate the creds, they will still be written to the Nodemcu in clear text. You should be aware of this and consider the potential implications.

An option I have not yet tested is Mongoose OS. It supports AWS IoT encryption for ESP8266 and I will most likely post some material on using Mongoose OS in the future. Another option is an IoT hub/broker such as AWS Greengrass that supports AWS IoT encryption requirements.

Next Steps

In the next part of this guide we will setup our Nodemcu hardware and DHT sensor.

Go to Part 2


Popular posts from this blog

Hacking the Sonoff Wifi Switch - Part 1

Hacking the Sonoff Wifi Switch - Part 2

Hacking the Sonoff Wifi Switch - Part 3 Alexa Smart Home