thingsboard / thingsboard

Open-source IoT Platform - Device management, data collection, processing and visualization.
https://thingsboard.io
Apache License 2.0
17.4k stars 5.14k forks source link

node red and thingsboard #1253

Closed hanno1234 closed 5 years ago

hanno1234 commented 5 years ago

hi everyone, i am currently busy with a project where i read data from a PLC with node. but the problem is i have to be able to access the node red dashboard over the internet(which i decided against), instead i tried using mqtt output to send to thingsboard(exactly what i wanted) but i am not seeing annything in the latest telemetry section of TB. Has anyone done this before or have alternative solutions?

shanevanj commented 5 years ago

What device/Language are you using? I have an example using C/C++ and the Arduino IDE if that soft any use?

hanno1234 commented 5 years ago

i am simply using the modbus read node to read the data of the plc but that is not the problem ... the problem is sending the data from node red to thingsboard using mqtt

hanno1234 commented 5 years ago

using mqtt out in node red i put in the following

server: https://demo.thingsboard.io port: 1883 username: access token topic: v1/devices/me/telemetry

and in thingsboard i just created a new device and used its access token

shanevanj commented 5 years ago

Make sure you set the password to NULL

hanno1234 commented 5 years ago

still not apearing in the telemetry.... it says conected in node red though.

shanevanj commented 5 years ago

Okay so once connected - make sure token is same at device token (must be exact)

hanno1234 commented 5 years ago

yes i copied the device token to the username in node red

shanevanj commented 5 years ago

Also check node logs for the mqtt node and see if it its reconnecting or staying connected - if reconnecting there is an error in the JSON telemetry document you are sending.

It must either be {"a01":27} for telemetry item named a01 and value of 27 or {"ts":1542283326048,"values":{"a01":27}} with senders timestamp.

Any other format will be rejected

hanno1234 commented 5 years ago

it seems like it stays conected .. but where can i check those json telemetry ?

shanevanj commented 5 years ago

add a log node to the output of the mqtt node (I think - haven't done this in a while) and check the messages its sending

hanno1234 commented 5 years ago

its sending the right format aswell maybe the problem is at thingsboard... one should just create a device and use its token and the value you send with node red should apear in latest telemetry ?

hanno1234 commented 5 years ago

are you able to send a simple value with inject (node red) to display in the telemetry of the device in thingsboard ????????????

shanevanj commented 5 years ago

Did you check the publishing topic is correct ? Can you maybe give me access to your node red and I can take a look?

hanno1234 commented 5 years ago

[{"id":"bba97c9e.17a5f","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"5eb15a0b.0aea74","type":"mqtt out","z":"bba97c9e.17a5f","name":"","topic":"v1/devices/me/telemetry","qos":"","retain":"","broker":"71b583e8.da15cc","x":591.1000595092773,"y":99.00000762939453,"wires":[]},{"id":"9ba09030.5a15f","type":"inject","z":"bba97c9e.17a5f","name":"","topic":"","payload":"650","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":280.10000228881836,"y":148.00000190734863,"wires":[["5eb15a0b.0aea74","a3233f7.9f1cdc"]]},{"id":"a3233f7.9f1cdc","type":"debug","z":"bba97c9e.17a5f","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":551.1000556945801,"y":180.00000190734863,"wires":[]},{"id":"71b583e8.da15cc","type":"mqtt-broker","z":"","name":"","broker":"demo.thingsboard.io","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]

hanno1234 commented 5 years ago

just paste that in import clipboard and it would show my node red project

hanno1234 commented 5 years ago

[{"id":"7c1ffbb6.a11354","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"6be8bedd.b6afc","type":"function","z":"7c1ffbb6.a11354","name":"PushData","func":"var datasource = { \"data\": [] };\ndatasource.data =\n{\n \"a01\": msg.payload,\n};\nmsg.payload = datasource;\nreturn msg;","outputs":1,"noerr":0,"x":600,"y":220,"wires":[["d713fe47.a71d9","ea3ed506.bf16e8"]]},{"id":"d713fe47.a71d9","type":"mqtt out","z":"7c1ffbb6.a11354","name":"","topic":" v1/devices/me/telemetry","qos":"1","retain":"","broker":"73d24c42.a76ec4","x":823.5000076293945,"y":272.00000381469727,"wires":[]},{"id":"ff7dc2f.2284c4","type":"inject","z":"7c1ffbb6.a11354","name":"","topic":"","payload":"590","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":401.1000556945801,"y":160.00000286102295,"wires":[["6be8bedd.b6afc"]]},{"id":"ea3ed506.bf16e8","type":"debug","z":"7c1ffbb6.a11354","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":776.1000595092773,"y":203.00000190734863,"wires":[]},{"id":"73d24c42.a76ec4","type":"mqtt-broker","z":"","name":"","broker":"demo.thingsboard.io","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"15","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]

hanno1234 commented 5 years ago

i added a function in above

ashvayka commented 5 years ago

using mqtt out in node red i put in the following

server: https://demo.thingsboard.io port: 1883 username: access token topic: v1/devices/me/telemetry

and in thingsboard i just created a new device and used its access token

server host is demo.thingsboard.io not https://demo.thingsboard.io