AWS and TTN

I have managed to read my TTN MQTT messages in AWS, but I cannot for the life of me find any way to add the messages to dynamodb. Is there anyone who knows how to do this? I have tried going through the Amazon documentation, but it all refers to the old console, so is completely useless!

Hi @mczakk,
I believe you work with AWS IoT Core? Without knowing the specifics, I would take a look at Rules in the category Act. You should be able to set rules, that save your incoming messages in a database.
Maybe this link Tutorial: Storing device data in a DynamoDB table - AWS IoT Core (amazon.com) is helpful.

@na1k I don’t wish to sound rude, but did you actually read all my question?
In particular the bit where I said that the amazon documentation refers to the old console and is useless?
Please read the question, and understand all of it before posting useless answers

Hi @mczakk , the main part of your post seems to be:

Broad statements like that will get poor responses.
You need to explain which part of the Tutorial you tried, and where it is different. Try to understand the steps being taken, and perform the equivalent step in the new console.
Then, how about writing a revised version of the Tutorial, that would help others?

2 Likes

Hi @Dave_Wal,
Again, I think you are mis-understanding the topic, and are more concerned with the format of questions than with trying to help the poster.
My comment was in response to someone who had read a question in which I said that the Amazon documentation was outdated and therefore not compatible with the current console, who then replied ‘read the documentation’.
As for ‘how about writing a revised version of the tutorial’, that is Amazon’s responsibility, not mine, and how do you suggest I re-write an amazon document when I don’t know how to use the service, and can’t learn as the documentation is wrong?

Whilst the reference quoted was to someone else, it is almost identical to your opening post.

“Completely useless” doesn’t really give any insight in to what is holding you up and it’s not really clear if you mean the TTN console or an AWS but I can infer you mean the TTN one. In that case, as the console is just a view in to the details of the Network & Application servers for LoRaWAN it doesn’t seem a stretch to translate one to the other.

As for a documentation re-write, this is a birds & the bees problem - “where do real instructions come from” - there is a lot of official documentation around but most of it is supplemented with the practicalities & the gotcha’s by people like us trying things out, making notes and then publishing them on here or GitHub or a blog or similar.

As a free service and a free forum, no one is obliged to assist, please consider this when asking for help - we need lots of detail, links to the resources and so forth, logs, version numbers and so forth.

As for the actual problem, the MQTT broker on TTS isn’t special - if you can subscribe to a topic on AWS then you’ve done all you need on the TTS/AWS side and the processing of the incoming JSON (which is fully detailed in the TTS docs) and insertion in to a DynamoDB instance is entirely on the AWS side.

1 Like

@descartes

how do you infer from this that I was referring to the TTN documentation? (my highlights)

I agree that the problem is on the aws side: but, as I asked in my original post, as this is a forum off people who use TTN for all manner of things and thought that there may be a user who had experienced the same problem as me and would be able to help. If there was, and they were willing to help, that would then instigate a discussion in which more exact details could be provided.
But no, instead of anyone offering any guidance the first response is to “read the documentation” (already covered) and any further comment is based on false assumptions.

I didn’t. I inferred you were referring to the TTN console. Not the documentation, never mentioned the docs, only the console.

I think you may have missed the point about how you approach your request for assistance.

And in the absence of any one who’s done it before, the “read the documentation” suggestion still stands because if you’ve got the MQTT working, the rest is ALL down to AWS and has not much to do with their docs referring to the old TTN console. Any of their generic docs on writing code to insert data in to a DynamoDB from a JSON payload should cover it. But now I’m repeating myself. Good luck.

1 Like

Is anyone else really struggling with aws integration? I have created stacks, can occasionally see my data in the aws MQTT test area, but how on earth do i get tghe data into a dynamodb table??
Any help/advice greatly appreciated!!

Hello, i’ve tested to ways to store ttn messages into a dynamodb table. First one is to create a rule in iot core you can filter the uplinks message by using: SELECT * FROM 'lorawan/+/uplink in the rule and then choose the action to insert data in dynamodb. This works fine and you get the hole message into the dynamodb table you defined previously. The other way i’ve tested is to create a lambda function and call the function in the iot rules using the boto3 api to insert the values into the dynamodb:

For example in python something like this:

    consulta = prueba.put_item(
    TableName=os.environ.get('TABLA'),
    Item={
        'dispositivo': {'S': dispositivo },
        'datos': {'S' : json.dumps(decoded_msg)},
        'timestamp': {'S' : tsrecibido},
        'estadistica': {'S' : json.dumps(estadistica_inicial)}
    }
    )

Regards,

Fernando.

If you used the TTN template and have data in IoT Core, you just create your database table and create a rule in IoT Core that sends data to your table.

The hard part is writing the SQL code.

This is code I used for a temperature and humidity sensor.

SELECT

end_device_ids.device_id as deviceid_ttn,

uplink_message.decoded_payload.TempC_SHT as TempC,

uplink_message.decoded_payload.Hum_SHT as Humid,

uplink_message.decoded_payload.BatV,

FROM ‘lorawan/+/uplink’

https://www.thethingsindustries.com/docs/integrations/cloud-integrations/aws-iot/deployment-guide/

1 Like