Sensor node -> LoRaWAN gateway -> TTN -> ThingSpeak -- how?


(Rudiniemeijer) #1

I have nodes sending sensor data to The Things Network. I can see the data in the TTN console. However, that is not where I need that data to be.

What would be the most efficient way to get the sensor data that is entering TTN tranferred to ThingSpeak? I would prefer not to run my own MQTT server (or client acting as a data transfer server), so I was hoping there was a free service 'somewhere' that would get the data from TTN and put it on ThingSpeak. I haven't found it yet, though.

Any tips, stories, help, advise and leads would greatly appreciated.

Rudi


HTTP Integration: pass only payload_fields
(Jac Kersing) #4

There is no need to run an MQTT server, you can use any MQTT client to get the data from TTN and publishing to Thingspeak can be done using REST or MQTT (again client). However you will still need somewhere to run the client code.
One option would be to use a bluemix node.js container to run Node-Red, it looks like the node red starter can be run for free.


(Rudiniemeijer) #5

I'll investigate node red, thanks for that lead. Running a MQTT client to transfer the data is something I would like to avoid. It might not technically be a server-side solution, but it would require a dedicated CPU of some sorts to have the getting and publishing part running.


(Jac Kersing) #6

You asked for a solution to get your data in ThingSpeak so I suggested one. Currently TTN does not provide integration that pushes data to any other site (work is being done to create them) so running your own client is the only way. That is why I suggested Bluemix, you should be able to run a CPU in the IBM cloud for free.


(Rudiniemeijer) #7

In addition to MQTT, there is now an HTTP integration feature. Will this HTTP integration make it possible to send ('POST') data from The Things Network to ThingSpeak? I can see that a POST request to a defined URL will be executed whenever an uplink from a device has been received by TTN. However, as far as I can see, you cannot influence the parameters and payload definition of the URL. Do I miss something?


(Oscar) #8

I am following this conversation because I am on the same position as you are. But I have seen someone has done it from some tweet I am waiting for his response as how he did it. https://twitter.com/Mi_Wie

Find me at oscarmakori@gmail.com incase you get solution


(Pieter Bogema) #9

Maybe this will help out:


(Paul Stewart) #10

Any update to this?

I can use the HTTP integration to do a post update but data is missing (I can see the entries number increase in Thingspeak), so I need to work out either

1) The payload format
2) the correct endpoint URL format to use or
3) send the correct payload format from my node (currently a Sodaq Explorer)

cheers
Paul


(Paul Stewart) #11

@oscar1 and @rudiniemeijer

Did you manage to work this out?

Still wanting to do this myself and be able to teach others, so looking for the simplest solution

cheers
Paul


(Jonas Chr) #12

I also tried the HTTP integration with the following settings in TTN:

Access Key = Default Key
URL = https://api.thingspeak.com/update?api_key=[my_api_key]&field1=temperature
Method = Post
Authorization = [my_api_key]

In ThingSpeak I get the write API Key from my channel, which is [my_api_key]. Under the private view, when I export data e.g. in csv, there is the string "temperature" and not the data of temperature.
How do I get the data?

I also tried the %% operator, but I think that just works with the ThingHTTP App. Maybe it doesn't work in generel to Post data directly into the channel, only with these ThingHTTP App. If that is the case, how do I get the data from this App to a channel in Thingspeak?


(Paul Stewart) #13

Yes I get exactly the same thing happening.

Somehow we need the http integration to be able to grab the payload data out of each message that gets sent to TTN.

That's the part I am missing

Cheers
Paul


(Sylvain Prost) #14

Hello all,

indeed to integrate with the thing speak will require more than just a HTTP integration. The HTTP integration is designed to forward the UplinkMessages to the designated URL and is not "aware" of the content.

Thought you might manage by using the IFTTT integration with the makers channel.

Best,
Sylvain


(Paul Stewart) #15

I have got this working now - IBM Bluemix now makes an easy to install a boilerplate app of NodeRED.

Both TTN and Thingspeak run MQTT brokers, you just need something to let them talk, so I am using a free instance of NodeRED on IBM Bluemix - you do have to enter credit card details, but they aren't charged on the free plan I used.

Then its just a matter of setting up an MQTT input node, do some cleaning up of the output fields to match what Thingspeak needs, then setting up an MQTT output node to Thingspeak.

I am a total novice in this stuff and I got it working so its not too hard. Happy to step through some of the basics if you need it, lots of resources online assume you know stuff, which I didn't.

Use this info for TTN https://www.thethingsnetwork.org/docs/applications/mqtt/api.html
Use this info for Thingspeak https://au.mathworks.com/help/thingspeak/use-desktop-mqtt-client-to-publish-to-a-channel.html
and this for setting up Node RED https://nodered.org/docs/platforms/bluemix

cheers
Paul


Problem to create a HTTP Integration to my REST API
(Tvloon) #17

Secondaire manuel on

Reference page

http://aquapoeder.nl/?page_id=285


(George0469) #18

Can you give a little more information on what you did? I’m new to node-red. not sure how you set it up to receive and relay the MQTT…
Thanks!


(Paul Stewart) #19

I’ll give it a go

image

I send data from a Lora based weather station to both Thingspeak and Weather Underground.

For Thingspeak, each end of the flow has an MQTT, one to subscribe from TTN, and the other to publish to Thingspeak.

The JSON node allows you to parse out the fields from TTN - the FORMAT node “Format for Thingspeak” has a function in it to assign the JSON fields to the Thingspeak fields like this - which then becomes the payload for Thingspeak, exactly how it likes it as per the documentation linked above.

          field1={{payload.payload_fields.Temperature}}&field2={{payload.payload_fields.Humidity}}  etc etc

Temperature and Humidity are produced from my Payload Format in my TTN Application

If you still need help with a specific part, keep asking, happy to help


(George0469) #20

Thank you! I’ve been playing with node-red a bit and it does seem quite easy once you get started. Your diagram will point me in the right direction. Cheers!


(Luka Mali) #21

I have prepared simple ttn2ts proxy that solves the same issue using the HTTP Integration:

Cheers, Luka


(Kelu28) #22

not work for me, value of variable are not in the final URL


(Luka Mali) #23

So sorry, the correct URL is:
http://mali.si/ttn2ts/?api_key=MY_TS_WRITE_API_KEY&field1=temperature&field2=humidity

Cheers,
Luka