SORACOM Developers

Getting Started

Send data using SORACOM Funnel AWS IoT adapter

Introduction

SORACOM Funnel (Funnel) is an adapter that transfers data from the device directly to a specific cloud service.

In this guide, we will summarize the data transmitted from the device into the AWS IoT, filter the data with the AWS IoT rule engine, and perform the notification by Amazon SNS (Simple Notification Service) as an example, using Funnel’s AWS IoT I will explain the basic usage of the adapter.

overview

AWS IoT has various functions such as device management, but in this guide we will process the data sent from Funnel using the function called “rule engine” which distributes data. If you change the setting of the rule engine, you can specify data distribution and action according to the purpose of the system. For example, it can be used for notifying when the temperature acquired by the sensor exceeds a specific value.

Here, the flow from setup to operation confirmation will be explained along the following steps.

The premise of this guide is as follows.

Set up AWS SNS

In this guide, data arrived at AWS IoT is sorted by rule engine, and if there is data that matches the condition, e-mail will be sent by SNS. First set up Amazon SNS for email notification.

Please refer to AWS documentation and create SNS topics and subscribe.

Set up AWS IoT

Next, set up the AWS IoT to receive data from Funnel.

Confirm endpoint

Open the AWS IoT management console and click Settings in the lower left of the menu screen.

setting

The endpoint assigned to your AWS account will be displayed, please make a note of the contents. For example, when setting up AWS IoT in the AWS Tokyo region, the following end points are assigned.

<Random character string>.iot.ap-norththeast-1.amazonaws.com
endopoint

Create rules

AWS IoT processes the data sent from the IoT device according to the rules and executes the action. This time we will create a rule to notify the SNS if the device’s IMEI is a specific value.

From the menu on the left side of the screen, click the Rule> Create a rule button and make the following entries: We filter only messages delivered under a topic named myTopic that contain a specific IMEI and send the entire message with the SNS mail function when there is a corresponding one .

overview
action list

If you can specify aws_iot_sns for IAM Role Name, click Update Role. Finally click the “Add Action” button.

action list

When the setting of Action finishes, it returns to the first screen. Finally, clicking the “Create Rule” button completes the rule creation.

action list

For instructions on creating rules, please refer to the document of AWS.

Set up Funnel

After setting up Amazon SNS and AWS IoT, we will move on to SORACOM side setting.

Registration of authentication information

In SORACOM, certificate and external cloud service authentication information etc. are registered in “authentication information store” and used for Beam and Funnel authentication. In order to access AWS IoT from Funnel this time, Credential (Access Key, Secret Access Key) of the AWS account is registered in the user console. The procedure is as follows.

credetial registration

SIM group setting

Funnel settings are done on a per SIM group basis. Follow the procedure below to transfer data to AWS IoT.

Item Setting contents
Enable/Disable switch ON (enable)
Destination service choose AWS IoT
Destination URL {Endpoint assigned to your AWS account}/myTopic/#{imsi}
Authentication information Designate what you registered in the previous step
Transmission data format (do not specify)
funnel group setting

Placeholder

You can use placeholder for the forwarding URL of the funnel. Placeholders are automatically replaced by IMSI, IMEI, and LoRa device IDs. The available placeholders are as follows. Please be aware that what can be used depends on the communication method.

Send data

With the procedure so far, you are ready to transfer data from Funnel to AWS IoT and send notification via SNS. Finally we will check the operation.

To confirm the operation of this time, use the device communicating with Air SIM and the MQTT client of AWS IoT.

Open the AWS IoT management console, select “Test” from the menu on the left side of the screen, and open the MQTT client. On this screen, you can test to receive and transmit data to AWS IoT. For details, refer to the AWS documentation.

When accessing the MQTT client for the first time, it may take a while for the operation to become ready. In that case, please wait a while and access it.

When the MQTT client is displayed, type myTopic / # in the Subscribe to a topic section. This will allow you to receive all messages delivered under a topic named myTopic.

aws mqtt client

The environment for checking the data reception status is now in place. Next, we send data from the device that can communicate with Air SIM to Funnel.

Let’s try to send the following JSON format data as HTTP request body this time.

{
    "deviceid": "iot123",
    "temp": 54.98,
    "humidity": 32.43,
    "coords": {
        "latitude": 47.615694,
        "longitude": -122.3359976
    }
}

Below is an example of request and response when Raspberry Pi sets a USB dongle and sends data via HTTP. If 204 No Content is returned as a response, data transmission is successful. If another HTTP response code is returned, check the format of the transmission data based on the error code.

pi@raspberrypi:~ $ curl -v -H Content-Type:application/json -d '{"deviceid" : "iot123",    "temp" : 54.98, "humidity" : 32.43, "coords" : { "latitude" : 47.615694,  "longitude" : -122.3359976 }}' funnel.soracom.io

* Rebuilt URL to: funnel.soracom.io/
* Hostname was NOT found in DNS cache
*   Trying 100.127.65.43...
* Connected to funnel.soracom.io (100.127.65.43) port 80 (#0)
> POST / HTTP/1.1
> User-Agent: curl/7.38.0
> Host: funnel.soracom.io
> Accept: */*
> Content-Type:application/json
> Content-Length: 156
>
* upload completely sent off: 156 out of 156 bytes
< HTTP/1.1 204 No Content
< Date: Thu, 30 Mar 2017 11:12:43 GMT
< Connection: keep-alive
<
* Connection #0 to host funnel.soracom.io left intact

At this time, on the MQTT client of AWS IoT Management Console, the message is displayed as follows. Also, if rules are set correctly, mail will also be sent from SNS. If both can be confirmed, operation confirmation is completed.

aws mqtt client

If you can not receive a message or if you do not receive the e-mail please check the following points.

Application example

The advantage of Funnel’s AWS IoT adapter is that it only transmits the data sent from the device to the entry point of Funnel, which enables AWS IoT to cooperate with various AWS services. It also supports TCP / UDP / HTTP protocols and can communicate with protocols that match device and system requirements. In addition, you can embed # {imsi}, # {imei} as a variable in the path of the URL in the setting item of Funnel as the transfer destination URL. By using this function, it is possible to automatically set SIM’s IMSI and IMEI as topic names, and it is easy to do with a specific SIM or device.

Specific examples of usage are as follows.

Funnel is specialized in uploading data to cloud services, and it does not support downlink communication to devices. Please use SORACOM Beam when using the AWS IoT Thing Shadow feature.

Getting Started

SORACOM Air for Cellular

SORACOM Air for Sigfox

SORACOM Beam

SORACOM Canal/Direct/Door

SORACOM Endorse

SORACOM Funnel

SORACOM Gate

SORACOM Harvest

SORACOM Inventory

SORACOM Junction

SORACOM Krypton

SORACOM Lagoon

Service Detail

Developer Tools

pagetop