SigFox to AWS

Introduction: SigFox to AWS

I.INTRODUCTION

1.The Author

My Name is Hooi Yong Hua and i am from Singapore Polytechnic , Diploma of Computer Engineering .

I am part of a group that consists of 3 members ; Low Jun Qian , Takuma kabeta and myself .

This instructable is part of a project to send data from sensors over the internet to a end device and conduct

business analytics. Our Project supervisor is Mr Teo Shin Jen.


2. Objective

Send analogue data from a sensor(DS18B20 ) using a Arduino with Sigfox Shield over the internet to sigfox servers then push the data to AWS (Amazon Web Services Cloud) and store it in AWS Dynamo DataBase ( DynamoDB )

3. Purpose

To simplify the instructions for testing Sensor to Arduino to Sigfox to AWS data transfer and collate all information in one place . For more details , especially about sigfox to AWSIot Connectivity , it is highly recommended to check out the original article by AWS https://aws.amazon.com/blogs/iot/connect-your-dev...

3. Required Skills :

1. Familiar With Arduino IDE , including adding Library and uploading code to arduino board . 2. Basic knowledge of Amazon Web Service , Especially Creating Stack , DynamoDB and Creating Rules .

3. Have already activated Sigfox Subscription and able to send messages ( Data ) from Sigfox Device to SigFox Cloud

II. Set - Up

A.Hardware

1. Arduino Uno x1

2. Sigfox Arduino Shield : UnaShield_RC1692HP-SIG ( Version 1A ) x1

3. Radio Antannae x1


4. USB B to A Cable ( to connect Arduino to PC ) x1

5. Sensor Set-up ( BreadBoard , Temp Sensor DS18B20 , 3x Male to Male Connectors ; 1 voltage [red] 1 Ground [Black] 1 Data [White] )

B.Software

1. Arduino IDE ( Version 1.8.1 was used in this tutorial )

2. Arduino Library calledUnabiz Arduino Master Library with Send - Light - Level Example Installed

C.Account ( Online ) & Subscriptions

1. Sigfox Server Subscription ( Comes with Sigfox Devices )

2. Amazon AWS Account with access to cloudformation ( Stack Creation ) & DynamoDB

IV References :

https://aws.amazon.com/blogs/iot/connect-your-dev....

Step 1: Arduino Set Up

A. The first step is to upload the example sketch send light level to the arduino .

To do so open the arduino IDE , click on the following words in order : File > Example > unabiz-arduino-master ( under subsection Custom Libraries ) > send-light-level . Refer to Figure 5 If any of the aforementioned words that are to be clicked are missing , reinstall the unabiz arduino master library ( Steps in Appendix 1 ) . Repeat step 1 .

B.Change the deviceid to your sigfox device .

The line of code to be changed is ( shown in Picture )

static const String device = "xxxxx"; // Set this to your device name if you're using UnaBiz Emulator.

C. Verify and Upload code to Arduino Sigfox Device .

( Remember to select the correct board ( in this case arduino uno ) and Serial Port )

Step 2:

Step 3: Arduino Serial Monitor

At the Arduino IDE , select tools followed by Serial Monitor . It should display Message.addfield and Radiocrafts.sendmessage : . The Radiocrafts.sendmessage : is followed by the sigfox deviceid

Step 4: Login to Sigfox

1 . Login at https://backend.sigfox.com/auth/login

Step 5: Sigfox Device Page

2. Click at the Device Tab . Secondly , Check the last seen colum ( C ) to make sure sigfox is still actively transmitting data.

If after around 15-20 minutes the Discrepancy between the current time and time shown there has not decreased , there might be a problem with the sigfox .

Then click on the Sigfox Device in use under the Device Type Column (B) .

You will be brought to the Device Type Section

Step 6: Sigfox Callback

Select Callback from the purple left pane ( Circled in Red )

Step 7: Sigfox New Callback

Click the word New on the top right hand corner below the logout button ( Circled in red ) .

Step 8: Sigfox Create Callback Type

5 . Select AWS IOT from the list of callbacks Type available . ( Its the second position ) . You will be brought to the next page

Step 9: Sigfox to AWS CloudFormation

Select the Launch Stack Button ( A ) .

You will be redirected to the AWS CloudFormation Create Stack Page , ( Create a Template ) subsection .

( If you have not logged in to aws prior to this you will have to do it now )

Take Note of External ID (B ) as it will be used later

The Region(C) for singapore is ap-southeast-1 Refer to https://docs.aws.amazon.com/general/latest/gr/ran... for other regions.

Step 10: AWS Stack Creation 1

Make Sure the button beside " Specift an Amazon S3 template url (A) .

Select the word NEXT in the bottom right corner (B).

you will be brought to the next page ( Specify Detail Subsection )

Step 11: AWS Stack Creation 2

In this page (Specify Details ) you have to fill out 5 boxes , namely Stack Name , AWSAcountID , ExternalID , Region and TopicName .

Detailed instructions are found below . Click Next after you are done ( at bottom right corner ) .

Firstly for Stackname use SigFoxIotConnector .

Secondly for External ID , Use the Information taken note of in Step 6 External ID , Use the Information taken note of in Step 6

Thirdly for Region , Use Ap-Southeast-1 ( For Singapore ) or refer to this link : https://docs.aws.amazon.com/general/latest/gr/ran...

Fourthly for TopicName use sigfox .

Lastly for AWS Account ID it will be discussed in the next step

Step 12: AWS Account Number Location

open AWS Console in a seperate page by clicking this link : https://ap-southeast-1.console.aws.amazon.com/con... ( or by any other means )

Click the support button located at the top right hand corner causing the menu will drop down

Then click the support center located in the drop down menu.

Step 13: AWS Account Number Location

This will bring you to the support center page , which shows the accountID at the Top right hand corner , below the support button.

Transplant the number ( AWS Account Number) to AWS AccountID in Step 9 and click Next located at the bottom right corner in that page .

Step 14: AWS Stack Creation

9. This page ( Options ) is not necessary for this tutorial . click next at the bottom right corner takes you to the Review Page

Step 15: AWS Stack Creation Final

At the Review Page , check that all information input is accurate , and under the subsection capabilities check the box beside

the sentence " I acknowledge that AWS CloudFormation might create IAM resources. "

Finally press the create button ( Bottom Right Corner of Screen ) to create the stack .

You will return to the Cloud Formation Management Console .

Step 16: AWS Stack Details

t the Cloudformation management console , the newly created stack should show CREATE_COMPLETE in the status column after 2-10 minutes

Click the stack name to view details about it .

Step 17: AWS Stack Details 2

Locate the Output Section and click the arrow preceding it .

Copy the ARN Role's Value Column and check to make sure the other values are correct .

Step 18: Sigfox Callback Creation Final

Switch Back to the SigFox Website's Callback Setup ( Step 7 ; From Where llaunch stack button is located) and fill up all the remaining boxes except custom payload config .

Copy the Aforementioned ARN Role to this one .

For the Json Body , Copy and paste the code below.

After all that is done Select OK . The next page shows the callback connections for the selected sigfox device

Step 19: Sigfox Callback Creation Check

Make Sure there are no errors and the [POST] link under the information section is similar to the image.

Step 20: AWS-Creating DynamoDB Table

Select DynamDB in the amazon menu then click create table

Step 21: AWS- Creating DynamoDB Table 2

Fill all the blank boxes .

For Table Name , put sigfox ; For Partition key , put deviceid , followed by checking the sort key box and put timestamp .

click create to finish ( do not touch any unmentioned settings ) . Wait for awhile for the table to be fully generated .

Step 22: Accessing AWSIot Console

Open the AWS Console , choose AWS Iot , select Rule and then select create Rule

Step 23: AWS DynamoDB Creating Rule

4. Assign the Name Sigfox , * to attributes and lastly put sigofox at the topic filter .

Step 24: AWS DynamoDB Adding a Action

Next you need to create the action . Select Add Action and in turn choose " insert a message into DynamoDB " .

Step 25: AWS DynamoDB Adding a Action 2

Use the same name ( sigfox ) to fill in the Table Name .

The Hash and rain key should automatically generate itself .

Fill in Hash Key Value with ${device} and RangeKeyData Value with ${ timestamp()}under the write message .

Lastly , Fill in the box labeled " Write message data to this column " with payload ( Not circled )

Pic is shown below

Step 26:

Step 27: AWS DynamoDB Role Creation

Next is to create a new role . under the IAM role name , enter dynamodbsigfox , click create role then click add action

Step 28: AWS DynamoDB Role Creation End

Finally click Create Rule to wrap things up . ( add the bottom right corner )

Step 29:

Now go back to DynamoDB Table and see the table being filled up

Note : If nothing displays on the table , 1 potential problem might be that the AWS console is in the wrong region make sure the region the aws console is located in is the same as the region indicated in the Stack Creation

Be the First to Share

    Recommendations

    • For the Home Contest

      For the Home Contest
    • Game Design: Student Design Challenge

      Game Design: Student Design Challenge
    • Make It Bridge

      Make It Bridge

    4 Comments

    0
    d0dja
    d0dja

    Tip 4 years ago

    Just as a matter of interest, the CloudFormation script that Sigfox provides to set up an AWS IOT Connector is either moderately broken (maybe just out of date) or does not cater for a slightly more complicated AWS environment.

    It creates an ARN (Reserved Name) that it ties to a role, but it needs a permissions policy to be set up against the role running the Lambda that creates the stack. You may find your stack deploy keeps failing.

    The solution is giving the role (something like "iap-cloudformation-lambda-execution-role") a whole bunch of permissions in IAM (Identity Manager) by giving it a permissions policy.

    Something like:


    {"Version": "2012-10-17",
    "Statement": [
    {
    "Sid": "VisualEditor0",
    "Effect": "Allow",
    "Action": [
    "iam:GetContextKeysForCustomPolicy",
    "iam:GenerateCredentialReport",
    "iam:GetAccountPasswordPolicy",
    "iam:SimulateCustomPolicy",
    "iam:UpdateAccountPasswordPolicy",
    "iam:GetServiceLastAccessedDetailsWithEntities",
    "iam:GetUser",
    "iam:GetRole",
    "iam:CreateUser",
    "iam:ListAccessKeys",
    "iam:CreateAccessKey",
    "iam:CreateRole",
    "iam:PutUserPolicy",
    "iam:PutRolePolicy",
    "iam:DeleteUserPolicy",
    "iam:DeleteUser",
    "iam:DeleteRole",
    "iam:DeleteRolePolicy",
    "iam:DeleteAccessKey",
    "iam:GenerateServiceLastAccessedDetails",
    "iam:CreateAccountAlias",
    "iam:DeleteAccountAlias",
    "iam:GetCredentialReport",
    "iam:GetServiceLastAccessedDetails",
    "iam:GetAccountAuthorizationDetails"
    ],
    "Resource": "*"
    }
    ]
    }

    Oh, don't miss the final tip in the instructable about ensuring you create the stack in the same region as your IOT Core where the rule will run…

    0
    SPChong
    SPChong

    5 years ago

    Excellent work, on Sigfox -> AWS, by a Singapore Poly student! (Sorry, deleted posts when trying to edit...) In my case, the problem was a typo: Partition key (deviceid) & Json (device) mismatch.

    0
    zakaevier
    zakaevier

    5 years ago

    Hi Mr Chong , The [POST] message is similar to mine . At step 24 i made a small error about what to type into the attributes . change the " * " to * . Check the attribute section in the rule created for sigfox in the AWS Iot .

    0
    Swansong
    Swansong

    5 years ago

    Thanks for sharing :)