7/10/18 by Dan

IoT Demo: Indoor Environmental Sensor Pack With Mbed and AWS IoT

Building a sensor module that logs data to DynamoDB with AWS IoT Core

TLDR: We built an IoT demo that logs data to AWS. See live data here.

IMG 7183 Our office dashboard showing current conditions


At DEB Associates we combine hardware and software expertise. To showcase our abilities in a new way, we are designing and building an environmental sensor for the office that highlights a number of technologies. The first revision of this project is a prototype using development boards from ST. The next revision will include custom hardware and Power over Ethernet.

High level data flow:

  • The device collects sensor data
  • Connects to AWS IoT endpoint securely
  • Logs data to DynamoDB
  • A lambda function is used to query the data
  • The data is displayed on our office dashboard and website

Technology Highlights:

  • ARM Mbed
  • Mbed TLS
  • ST Sensors
  • AWS IoT Gateway
  • DynamoDB
  • Lambda

This demo was put together using development kits from ST. I used the NUCLEO-F401RE base board with the X-NUCLEO-IDW04A1 wifi expansion board and X-NUCLEO-IKS01A2 sensor expansion board.

IMG 7184

Networking

The device connects to the network via wifi and sends data to the secure AWS MQTT endpoint. The data is logged to DynamoDB and queried using a Lambda function.

Security

Security is important in the emerging world of IoT. There have already been a number of major exploits from compromised IoT devices. This past year a casino's network was breached through sensors in a fish tank.

Two big parts of securing IoT devices is making sure data sent/received is encrypted and that user applications have the correct level of access to device resources. Mbed has answers for both of these issues. Check out their resources on security,

In this design we used Mbed OS and Mbed TLS to encrypt data sent to AWS IoT core.

Mbed

Mbed provides a rich environment for development of connected embedded devices. It provides a number of abstractions that fit together and can be mixed and matched as needed with minor development overhead:

Connectivity

Including Bluetooth, Wifi, Ethernet, Thread, NFC, 6LoWPAN Sub-GHz Mesh, LoRa LPWAN, RFID, Cellular connectivity

OS

Mbed OS includes an RTOS and additional drivers and support libraries from chip manufacturers and the community.

Security

Mbed TLS and uVisor (soon to be replaced by the Secure Partition Manager in Mbed OS 5.10) provide security primitives for IoT projects.

Compatibility

Mbed OS also includes support for many ARM devices. It ships with a hardware abstraction layer - allowing easier portability between devices.

CLI

One of my favorite features of Mbed is that it comes with a command line interface and a package management solution and workflow. Having a background in web application development, I've enjoyed the proper package management solutions of Elixir (hex), NodeJS (npm) and Rust (cargo).

When writing embedded code, I miss those toolchains. While Mbed package management leaves some things to be desired, it is much better than nothing at all!

Mbed Libraries Used

I used a number of Mbed libraries in this project including:

  • Mbed OS
  • Mbed TLS
  • MQTT
  • wifi-x-nucleo-idw01m1 (wifi, provides NetworkInterface)
  • HTS221 (humidity/temp sensor/I2C)
  • LPS22HB (pressure sensor/I2C)
  • TCPSocket

The final build will swap the Wifi interface for Ethernet and include support for additional sensors.

AWS

AWS has solutions for the major needs of an IoT project including:

  • Device provisioning
  • Security
  • A registry to track your devices
  • Rules engine
  • Over the air updates (jobs)
  • Seamless integration with other AWS services (Dynamo, Lambda, IoT analytics etc.)
  • Simple scaling

IoT Core

In this project the device is connecting securely to an IoT core endpoint and publishing messages with sensor data periodically.

Rules/DynamoDB

There is a rule set up to pipe messages received to a DynamoDB table. DynamoDB is a managed NoSQL database that provides consistent performance at any scale.

Lambda

Finally, to display the data, I have a Lambda function (written in NodeJS) that queries the DynamoDB table and returns a JSON payload. The lambda function is managed and deployed using Apex.

Apex is a library for deploying serverless functions. It abstracts some of the routine involved in setting up functions and makes it easier to manage them over their lifetime. Apex also supports integration with Terraform for infrastructure management. Over all, Apex (and the sister project Apex Up) provide a really nice developer experience and interface to AWS.

Displaying the data

We have an office dashboard that displays metrics and a nice background (of rotating images). I added charts showing the recent office conditions.

IMG 7183 IMG 7182

Current Conditions Page

I also added the charts to our public site. Check them out here.

By: Dan


Dan is an engineer with a background in software development. He graduated from GVSU with BSEE in 2011 and has been building ever since. His tools of choice are C, JavaScript, Elixir and everything that AWS offers.

Like what you see?

About Us

DEB Associates helps companies through the entire electronics design process. Our team is smart, reliable, and deeply knowledgeable about the intricacies of circuit design, PCB layout, and EMC.


DEB Associates 2018