How to measure temperature and send it to AWS IoT using a Raspberry Pi

Leo Kyrpychenko
Sep 10, 2018 · 3 min read

What if you want to self-correct the temperature in your office? Or what if you are curious to understand your office environment using IoT sensors?

If this sounds interesting to you, please read on.

To begin with, we need to set up a temperature reading sensor. We connect it to an Arduino which connects to a RaspberryPi.

Image for post
Image for post

The next step is to set up AWS IoT SDK on your Raspberry Pi.

Setup the Thing

  1. Create a thing in AWS IoT:

2. Create a single thing to begin with:

Image for post
Image for post

3. Create a thing of a particular type. We are using RaspberryPi here (the types are made up by you).

Image for post
Image for post

4.Create a certificate for your Thing to communicate with AWS:

Image for post
Image for post

5. Download the certificates, a root certificate authority (CA), activate the Thing, and attach the policy.

Image for post
Image for post

6. The policy code is here. It may seem a bit permissive, but it is OK for the demo App.

Image for post
Image for post

Setup your RaspberryPi

Before you start the setup, please copy all certificates and all root CA files over to the RaspberryPI (scp might help you). You also need to install Node.js if you don’t have it already.

You will also need to install the AWS IoT device SDK.

Here is the code that reads the data from the serial port and sends temperature readings using the AWS IoT device SDK. The code is based on the examples from Amazon.

So now what can you do with that data?

You can write a Lambda that enqueues the data for processing. It may look like this:

And your serverless.com file may look like this:

I hope this post has saved you some time setting up your device. Thanks for reading!

freeCodeCamp.org

This is no longer updated.

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store