AWS Gateway – WiFi Micro Gateway for Amazon® AWS®

Hello, I have a problem with the connection between AWS Gateway - WiFi Micro Gateway for Amazon® AWS® and Ubidots.
JSON file type is not supported and one of the solutions is to create a function in aws Lambda.
Could anyone help me?

Thanks for stopping by our community!

I believe you’re referring to NCD’s WiFi Micro Gateway? Great product.

To be able to help you, can you please elaborate more on how are you trying to achieve the connection between AWS IoT and Ubidots?

  • You have the data in AWS IoT already and are looking for ways to send it to Ubidots
  • You have data in AWS IoT already, tried our AWS Plugin and are facing an issue with it. If so, can you please share where the data is missing?

This will help us determine the best solution alternatives.

Thank you.
If it is the NCD Gateway for Amazon.
the connection between AWS IoT and Ubidots is through plugins. the connection is currently active. however we cannot view the device in Ubidots in the devices part.

Ubidots support told us that JSON message formats were not supported. and that it was required to be covered through the AWS Lambda service.
In AWS IoT we can see the temperature emitted by the sensor and the Gateway.

point 6 of these instructions is the one that fails us and we cannot connect, apparently due to file incompatibility.

Got it. Indeed, you need to make sure you’re sending the right JSON payload for the Ubidots plugin to work.

Can you share a screenshot of:

  • The payload that your gateway is sending to AWS IoT Core
  • The SQL statement in AWS IoT Role that’s forwarding data to the Kinesis stream that forwards data to Ubidots

These two can help us establish whether it’s possible to convert your payload into an Ubidots-friendly one, as shown below:

I think that if that is the detail, try to upload images to this message but it does not load them.
I can share the message in JSON from the gateway by posting the topic to the AWS IoT core.

and the kinesis connection is active, however it cannot share the screen.

{
“format”: “json”,
“payload”:

{

“state”: {

  "reported": {

    "Gateway_Config": {

      "mac": "CC:50:E3:96:0D:68",

      "ip": "192.168.1.164",

   "xbee_address": "00:13:A2:00:41:91:48:F9",

      "network_id": "7FFF",

“preamble”: “0”,

      "tx_power": "4",

      "xbee_ready": "1"

    }

  }

}

}

,

“qos”: 0,

“timestamp”: 1610729857528,

“topic”: “$aws/things/CC50E3960D68/shadow/update”

}

********now I share the file with you when it receives the information from the sensor

{
“format”: “json”,
“payload”:

{
“state”: {

 "reported": {

 "nodes": {
      		"00:13:A2:00:41:8E:96:43": {
        	"transmission_count": 1,
       	 "battery_level": 3.29406,
     	 "type": 4,

     "node_id": 0,

     "rssi": 100,
        	          "temperature": 17.62
  
 }

  }

}

}

}
,
“qos”: 0,
“timestamp”: 1610729931630,
“topic”: “$aws/things/CC50E3960D68/shadow/update”
}

******* If there was another way to share the screens, I would gladly send them to you.

These JSONs are enough for us to reply, thanks. There are 2 things that are not being sent correctly:

  • Topic: Currently you’re sending data to $aws/things/CC50E3960D68/shadow/update, but the plugin is configured to get data from the topic ubidots/v1/+. You need to either change the configuration in the device to match the expected topic, or change AWS IoT Rule SQL Statement to match your topic.

  • Payload: Currently you’re sending a JSON that contains many keys and values, which is not compatible with the expected payload, as described in our last message. Your need to either change the configuration in the device to match the expected format, or change AWS IoT Rule SQL Statement to extract the required keys from your JSON, and send them in the expected format.

Let’s assume you can’t change the topic nor the payload of the device, so let’s try to adapt the SQL statement:

  • Topic: To match the topic, let’s change the AWS IoT Rule from:

SELECT topic(3) as device, * as payload FROM 'ubidots/v1/+'

to something like:

SELECT topic(3) as device , * as payload FROM '$aws/things/+/shadow/update'

This will grab all data sent to the $aws/things/+/shadow/update topic.

  • Payload: Now let’s try changing the payload. A quick look at AWS IoT SQL Reference shows that it is possible to manipulate incoming JSON:

You can use the following extensions to ANSI SQL syntax to make it easier to work with nested JSON objects: “.” Operator

This operator accesses members in embedded JSON objects and functions identically to ANSI SQL and JavaScript. For example:

SELECT foo.bar AS bar.baz FROM 'topic/subtopic'

If a JSON property name includes a hyphen character or numeric characters, the simple ‘dot’ notation will not work. Instead, you must use the get function to extract the property’s value.

So let’s use the same principle to reduce your payload to the expected one:

New SQL Statement:

SELECT topic(3) AS device, get(get(get(get(payload,"state"),"reported"),"nodes"), "00:13:A2:00:41:8E:96:43") AS payload FROM "$aws/things/+/shadow/update"

Output:

{ "device": "CC50E3960D68", "payload": {"battery_level": 3.29406, "node_id": 0, "rssi": 100, "temperature": 17.62, "transmission_count"; 1, "type": 4}}

With this new statement, the data is created in Ubidots:

A few things to note though:

  • Because NCD sends the MAC address as a “key”, not a “value”, it is not possible to extract it programmatically using AWS IoT SQL. This makes it mandatory to know the MAC of the node beforehand, which is not scalable.
  • We will release a new AWS IoT plugin, which will allow you to decode the incoming payload at will, replacing the pain of SQL, with the power of Python 3 :smiley:

I had already tried publishing that topic, I don’t know if it doesn’t work or if I’m writing it wrong. The fact is that he does not send me an answer. I send you the subject as I publish it to know if there is the error.

ubidots / v1 / {DEVICE_LABEL}

ubidots / v1 / CC: 50: E3: 96: 0D: 68

I will start to check if I can change the configuration of the gateway and if not, modify it as you send me the option. I really appreciate your help.

Cheers

Here is info about AWS payload