Mar 03, 2020

Digiteum Team

Amazon Raspberry Pi

IoT

Why Connecting Raspberry Pi and AWS IoT

In our recent article about the programming languages for IoT development, we’ve mentioned the multicomponent nature of Internet of Things. This is also the reason why choosing the right tech stack for an IoT project can be challenging.

It takes knowledge and experience to select hardware, cloud services and big data tools for an IoT system with multiple devices, complex data model various end-user applications. Needless to say, there’s no lack of tools to build and manage each IoT layer.

Among the well-known names commonly associated with connected technology are Raspberry Pi on the hardware side and AWS IoT platform as an IoT ecosystem management service.

There are many reasons why IoT platform by Amazon and Raspberry Pi hardware are so popular among IoT amateurs and professionals. Earlier, we have talked about what to look for when choosing Arduino or Raspberry Pi for IoT development and later also reviewed AWS IoT platform.

In this article, we’ll touch upon the benefits of AWS IoT — Raspberry Pi combo and find out why making these two work together is a good idea.

Arduino vs Raspberry Pi

You’ll find out:

  • Why Raspberry Pi and AWS IoT are a good match
  • How to connect your Pi computer to AWS IoT platform
  • About using Raspberry Pi and AWS IoT in a simple IoT agriculture application

Now, let’s get down straight to the first point.

Why Raspberry Pi and AWS IoT are such a good match

  • Purpose and requirements. Relatively high computing power, rich componentry and customization opportunities make Pi a great choice for an edge layer device like a gateway or local server. The latest Pi 4 model B has a 1.5 GHz ARM Cortex-A72 processor and up to 4GB SDRAM enough to handle intensive data flows and perform computing at the edge. In turn, AWS IoT platform offers the services designed specifically to quickly and securely roll out edge intelligence and enable diverse functions such as computing, device communication, data management or even running machine learning models locally. Designed for this purpose, AWS IoT Greengrass service can run on general-purpose computers that have at least 1 GHz of computing power and 128MB of RAM. These requirements match the specifications of many Raspberry Pi models and make this small computer ideal to work with this and other AWS IoT services.
  • Cost-efficiency. You can buy Raspberry Pi online at an average price of $35 (this is the price for the most popular Raspberry Pi 3 Model B+). Amazon IoT platform also stands out for its favorable and flexible pricing policy. According to the official AWS website, “you pay only for what you use.” When it comes to AWS IoT Greengrass services, you even get a free first year of use with AWS Free Tier when connecting up to 3 devices. This is good news for those who create a prototype device to test an IoT business idea.
  • Tools and support. Amazon recognizes Raspberry Pi as a popular tool for prototyping and development of Internet of Things applications and offers support for Raspberry Pi and Raspbian OS. There are ready-to-use developer tools, libraries, AWS IoT SDKs and official tutorials and guides on how to use them on Raspberry Pi.
  • Simplicity. This could be one of the biggest benefits for those who are just starting an IoT project. You can connect Raspberry Pi and AWS IoT platform in several consecutive steps. It’s a pretty straightforward process, and there’s no shortage of examples and guides on how to do it, including the one provided by AWS. Here’s this process described in more detail.
AWS IoT Platform

How to connect Raspberry Pi to AWS IoT

As we have mentioned earlier, the process of setting up Raspberry Pi to work with AWS IoT is straightforward and doesn’t require a lot of tools and coding. Apart from Raspberry Pi 2 B or any later model, you will need a keyboard, mouse, monitor, access to the Internet (Wi-Fi or Ethernet) and an active AWS account.

Here’s a short description of this process. You can find the detailed step-by-step instruction in the official AWS guide or this example.

Step 1. Set up

First of all, you need to set up both Raspberry Pi and AWS IoT. For the board, you will need an SD card with Raspbian or other general-purpose OS, USB power supply, monitor, keyboard, mouse and Internet connectivity. To set up AWS IoT, you will need to create an AWS account (check the Free Tier offers) and access your AWS IoT console.

Step 2. Configure AWS IoT

You need to prepare your AWS account. Using your account’s dashboard, you can create a ‘thing’ that will represent your device, give it a name, create the policy to determine which AWS IoT sources the device can access and register it assigning the necessary certificates.

Step 3. Configure Raspberry Pi

On the hardware side, your Raspberry Pi should have a certificate, private key and root CA certificate installed to authenticate with AWS IoT (read here to learn more) and be able to send messages to AWS IoT. To configure your device to be able , you can use AWS IoT device SDKs, for example, AWS IoT Python SDK or AWS IoT Device SDK for Embedded C depending on your case.

Arduino vs Raspberry Pi

Step 4. Create rules

In order to make AWS IoT act on the data received from Raspberry Pi, you will need to create a rule to specify what AWS IoT should do with the messages coming from the device.

Here’s how it works in a simple IoT application for soil moisture monitoring.

Using Raspberry Pi and AWS IoT in an agriculture application

Precision Agriculture

In the AWS IoT developer guide, you can find an example of connecting Raspberry Pi to AWS IoT services to read and act on the data sent by a moisture sensor.

In this example, Raspberry Pi is configured to collect sensor data on moisture and temperature levels and send the readings to AWS IoT for processing via a lightweight MQTT message. Based on the created rule, AWS IoT figures out when the moisture level goes below the set threshold. Once it does, the service triggers sending an email with the readings to every email subscribed to the relevant topic.

This is a very basic application that can be augmented with other features and functions using different AWS IoT services. For example, you can add Amazon Lambda function to automate some actions or route data to different destinations for analysis using Amazon Kinesis.

Read: How to use Raspberry Pi for small business

Are you looking for ways to unlock the benefits of AWS IoT for Raspberry Pi-based application and don’t have the capacity to figure out all the certificates, policies, rules, directories, SDKs? Or seeking a tech consultant for your IoT project with experience in AWS, MS Azure or Google IoT platform solutions ? Contact Digiteum to talk to our team about your IoT project. Check our IoT software development services and capabilities to learn more.