Node data to HTTP

Just a question, I want to send the data from my nodes to my webserver.
I want to send this data to a HTTP URL, has someone around here already done that and wants to help me with this?

Node-red should be able to do this for you.

Do you know if there is a some sort of example of that, where I can see how it should be done?

I haven’t build this yet, but I did a quick test with a local TCP input socket on port 666 (ah well) that feeds it into a TCP output.

[arjan@MacVoice ~]$telnet localhost 666
Trying ::1...
Won't send login name and/or authentication information.
Connected to localhost.
Escape character is '^]'.
temp.php?val=HOT

This gives me in the apache logs of the web server:

1.2.3.4 - - [09/May/2016:16:56:55 +0200] "temp.php?val=HOT" 501 214

1 Like

Hi Sander,

If you’re gateway is connected to TTN, you can use a small NodeJS application which listens to the TTN MQTT broker, and calls a URL on every message event. See this topic for an example: topic. (the example stores a new entry in a MongoDB database on every node message, replace that piece in making a http call, I didnt try it myself yet)

Good luck, Bart

1 Like

Hi,

Node-red works! I’m now receiving the packets with the MQTT input and sending the packet to my HTTP url with the HTTP request function.

Thanks for thinking with me!

1 Like

FYI: Node-red comes with the latest full version of Rasbian Jessie for those who work with a Raspberry Pi

@sanderhogewerf I did some more modding and now I use a simple convert function that prepares a method and GET url that includes the payload as variable on a PHP string and feeds it into the HTTP Request function. On my web server I’m collecting the variable and storing it in a text file.

NodeRed is really cool :smile:

1 Like

Yes NodeRed is really cool indeed! I never thought it would work so smooth!

Do you also use node-red to decrypt the data? I’m trying Node-red at the moment (indeed really cool tool) with the decrypt-ttn module from willem4ever at Github.com (link to github) but getting the following error at the output:

RangeError: Invalid typed array length

I’ve created the following scheme:

Functionblock contains:
var newMsg = { payload: { rawData:msg.payload.payload } }; return newMsg;

Using this functionblock because decrypt-ttn expects a payload.rawData var which seems to be the payload.payload var in my MQTT response, is this correct?

My MQTT Response:
{ "payload": "qrvM", "port": 1, "counter": 5, "dev_eui": "0004A30B001B5FD7", "metadata": [ { "frequency": 867.5, "datarate": "SF12BW125", "codingrate": "4/5", "gateway_timestamp": 1833891972, "gateway_time": "2016-05-10T12:49:59.351748Z", "channel": 5, "server_time": "2016-05-10T12:49:59.36473891Z", "rssi": -75, "lsnr": 5.5, "rfchain": 0, "crc": 1, "modulation": "LORA", "gateway_eui": "B827EBFFFECF29A7", "altitude": 0, "longitude": 6.48105, "latitude": 51.94165 } ] }

Send message:
mac tx cnf 1 AABBCC ok mac_rx 1

I’ve seen the same issue. It looks like the decrypt-ttn node doesn’t work with the new (1.0) backend data structure - even if you feed it a msg.payload.rawData object.

@w4e, any plans to update it?

I don’t decrypt the data in Node-red. I decode it in the backend of my application (java).

The payload is already decrypted by TTN …

1 Like

See below example for my Autonomo reporting each minute 2 bytes of data which is output voltage of the LiPo battery, the counter which increments every minutes is used to show the active time. The payload is an 16 bit integer … Like I wrote before, the decrypt-ttn is no longer required when you use staging.

1 Like

echo -n qrvM | base64 -D | xxd
0000000: aabb cc …

Aha! I was looking at the base64 encoded data and thinking it was encrypted :). Thanks @w4e.

1 Like