How to connect multiple devices to same Thing in AWS-IOT?
Asked Answered
U

5

14

I am working on a project to install 100+ nodes of temperature sensors in an area, all of which perform the same function. The data they publish is the sensor id and the reading. I am using AWS-IOT for the backend.

Now, to do so, I think I will need to create 1 'thing' per node in aws-iot which I believe is extremely hard to maintain and unscalable.

So my question here is, how to connect multiple nodes to same 'thing' in AWS-IOT so that the cluster is easy to manage. Is there any alternate way to manage the cluster efficiently? Any inputs are welcome. Thanks.

Unmerciful answered 1/6, 2016 at 18:53 Comment(0)
H
6

Faced with a similar dilemma and the impracticality of creating too many 'things' on the AWS IoT administration console; I've done some research and found that connecting multiple devices to the same 'thing' is strongly discouraged by AWS.

Anyway its not possible to keep two different nodes using the same MQTT id connected to the same thing (the last connected node with the same id kicks out the previously connected node), although you can use your client ID with the help of some code.

I learned that actually you don't need a 'thing' to connect to AWS IoT, just a certificate will do; and that you can create elements on AWS IoT service by code.

So, in summary; facing a similar question myself, I ran across this information below, found it useful in my case and sharing it here. https://forums.aws.amazon.com/thread.jspa?threadID=234102

Handfasting answered 11/5, 2017 at 20:12 Comment(5)
I disagree that this is impossible. We have only one "thing" on AWS IoT, with one set of certificates. All our devices in the field use the same set of certificates. They each have their own "client ID" though, so we can tell which is which. I'm not saying this is best practice, just that it's indeed possible.Dysfunction
@SeanMcCarthy Can you provide the steps to do that? I'm new to IoT and want to connect all my devices to a single thing. Have been struggling for 2 days straight.Primrose
@ChiragMittal all your devices must send their MQTT data to different MQTT topics. The thing just provides the security certificates and policy attached to those certificates. Sort of like a key for a lock, or a username/password to get to AWS IoT. But each device must send to a different topic. Ask a new question, rather than asking a question in the comments, please.Dysfunction
@Handfasting you may right ..we can connect iot nodes using x.509 certificate but should i manage 1000 certificates for 1000 nodes?..how can i manage single certificate with aws best practices way..Rely
@SeanMcCarthy i actually want to do something similar - the things will eventually be multiple kubernetes pods - so there mihht be replicas - each set is a single thing - ill need to try thatOmen
G
3

It would seem that the only way to do that would be to create your own gateway that aggregates the data before sending it to AWS IoT. You can't have multiple MQTT connections with the same client ID.

Use the API to automate assignment of certificates and private keys to nodes. The sensor ID may be used as the thing name and MQTT client ID. It takes some work up front, but then you can leverage AWS IoT for all the housekeeping moving forward.

Georas answered 24/6, 2016 at 16:23 Comment(0)
R
2

You can use the same Thing with multiple clientId. You can use the sensor id as the clientId.

Radian answered 1/5, 2017 at 8:56 Comment(1)
I agree this is possible. We have only one "thing" on AWS IoT, with one set of certificates. All our devices in the field use the same set of certificates. They each have their own "client ID" though, so we can tell which is which. I'm not saying this is best practice, just that it's indeed possible.Dysfunction
N
1

You connect your sensors to AWS IOT, subscribe to a device Topic and start publishing data. And you start receiving data from all the sensors.

Now see, what is the problem here??? Problem: We don't know, which device sent which data?

Solution: There can be 2 solutions to this problem.

  1. You create multiple things and get data from the sensors separately from the separate device topic individual.(Which you already rejected)
  2. Second, solution is to embed the device id or clientID in the data which sensor is sending to AWS IOT. And create a Rule for that device topic on the AWS IOT to extract the data from the topic and save it in the DB with correct client ID. In this case Client ID will be used to distinguish data from the different sensors similar to primary key.

I hope this helps.

Thanks

Numinous answered 16/7, 2017 at 15:7 Comment(2)
I agree this is possible. We have only one "thing" on AWS IoT, with one set of certificates. All our devices in the field use the same set of certificates. They each have their own "client ID" though, so we can tell which is which. I'm not saying this is best practice, just that it's indeed possible.Dysfunction
I agree. It's not a best practice. Ideally, it should all be different. So that a Different digital twin is created for every device.Numinous
T
0

Use different clientId can distinguish the client. But looks like the is only a shadow data for the thing.That means shadow data can only be used when there is a single device associated with the thing. If there are multiple devices associated with the thing, then shadow data is not applicable.

Transmittance answered 8/3, 2019 at 10:1 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.