Create a simple dashboard in node-RED

  • 9 January 2017
  • 14 reacties
  • 6943 keer bekeken

Badge
For this tutorial Node-RED is used in combination with the Developer Portal (kpn.com/loradeveloperportal). A physical LoRa device is not neccesary, instead the ‘test connection’ button from the developer portal is used. This is the first tutorial in this format, feel free to comment and/or give suggestions on how to improve.

Set up Node-RED
A Node-RED server is needed and can be set up as described in https://github.com/iotacademy/NodeRed_KPN_LoRa/wiki/Setting-up-a-NodeRed-Server-in-Bluemix. When you are finished go to the node-RED flow editor. For this example things are kept simple and there is started with a 'http' node. Set the method to POST and give the url and the node a relevant name:

. This is where the test messages will arrive. Attach a debug node to verify the received data.



Set up Developer Portal
Since it is now possible to receive LoRa messages it is time to connect a LoRa device. Go to kpn.com/loradeveloperportal and create an account (if you don't have any already). Log in and add a device. You will be asked to give a device name and a destination. Give it a nice name and for the destination you need to use Node-RED. The link for the destination should be something like: https:// (your project name).eu-gb.mybluemix.net/lorapost (depended on the url you gave in the 'http' node).

This is our
first LoRa device. It is not attached to a physical one, but we can send test (uplink) messages to Node-RED. Select the 'Edit' button and hit the 'Test Uplink' button.

Give some payload, for example 30 and hit 'Test connection'. This will send a message to Node-RED. To check if this is true go to the Node-RED flow editor and select the 'debug' tab. Here you should see a message with payload_hex "30".


Let's assume we have a temperature sensor attached to our LoRa device and we want to visualize this data. It is possible to create a simple dashboard.

Extract data from message
Firstly the payload_data is extracted from the original J-SON message. We use a function block with the code
code:
msg.payload = msg.payload.payload_hex;
return msg;


Attach a debugger to check if the correct message is extracted.

Create dashboard
After extracting the temperature it is possible to create a dashboard. In Node-RED go to options (the three horizontal lines in the top right corner) and select 'manage palette'. Select 'install' and search for dashboard and install 'node-red-dashboard'. After reloading the page you should be able to see the new dashboard nodes. Connect a 'gauge' and a 'chart' node to the function node. Your flow should look similar to:


Configure the dashboard nodes, use convenient names. Set the X-axis and Y-axis as you want. Configure the group to make it fit into your user interface.
Hit deploy and go tohttps:// https://(your project name).eu-gb.mybluemix.net/ui. Here you should see a chart and a gauge. Use the developer portal to send some test temperatures. If everything goes as planned you should see the data displayed in your dashboard.


Overview
After reading this topic it should be clear how to create a simple dashboard for your LoRa data using Node-RED. If you have any questions/additions/remarks please post them in the comments. Also, feel free to post your own tutorial/usecase on this forum!

Handige links


- LoRa: Starters Guide
- LoRa: Forum and Manuals
- LoRa: Geolocation
- LoRa: Dictionary & Definitions
- FAQ: Frequently Asked Questions
- Tools: www.LoRaTools.nl

14 reacties

great tutorail!

however the function block is not working for me.
if I copy paste your code in my function block i get undefined in my debug window :(
is this code still working or am i doing something wrong?
Badge
Hey Jeroen,

Glad to hear you like the tutorial.
I see the J-SON message sended from the Lora server changed a little bit.
Maybe if you try this code in your function node:
msg.payload = msg.payload.DevEUI_uplink.payload_hex;
return msg;


Good luck!
Hoi allemaal,
Ik heb het bovenste gedaan maar werkt met testen dus niet.

Node-Red Server is ingesteld op https en port 443. Dit werkt ook
Certificaat is gemaakt met openSSL Deze werkt ook als ik de url van het certificaat gebruik. Zonder foutmelding in de browser.
Ik vraag mij al, of dit wel kan met OpenSSL.

Foutmelding:?:?:?:?
Server returned HTTP response code -1

Response info:
Error in sending rest post to developer url https://anprscan.dyndns.org/, for device 0059AC0000181952, payloadhex 30. Error details: sun.security.provider.certpath.SunCertPathBuilderException unable to find valid certification path to requested target
Misschien dat iemand weet wat hier aan de hand is.
Bedankt
Reputatie 7
Badge +11
Hi @swissmade,
Op de url anprscan.dyndns.org is volgens mijn informatie geen SSL certificaat aanwezig/geïnstalleerd en kan geen target worden bepaald. Zie ook: https://www.sslshopper.com/ssl-checker.html#hostname=anprscan.dyndns.org

Pas met een geldig certificaat kan het werken. Dat moet ook lukken met OpenSSL verwacht ik.
Hoi Tim,
Dit certificaat is wel aanwezig mits ik de server aanzet.
Alleen deze is op port 1880 wat volgens mij is geblokt door jullie firewall.
Ook het omzetten naar port 443 van de server heeft geen effect.



En hier weer de foutmelding.
Het lijkt dat et certificaat niet kan worden gevonden.
Error in sending rest post to developer url https://anprscan.dyndns.org/, for device 0059AC0000181952, payloadhex 000000. Error details: sun.security.provider.certpath.SunCertPathBuilderException unable to find valid certification path to requested target
Reputatie 7
Badge +11
Hi @swissmade, aha, dat verklaart het! Bedankt voor het delen van de schermafbeelding.
Er is geen goed certificaat geïnstalleerd, er is een intermediate/chain certificaat nodig! Als SSL Shopper geen waarschuwing meer geeft, bent u klaar om te gaan.
Hi Tim
Gaat dit lukken met OpenSSl??
En als enig idee hoe dit kan worden gedaan. Het is voor een Node-Red Server.
Reputatie 7
Badge +11
Volgens mij moet dat kunnen. In de documentatie van OpenSSL kom ik informatie over intermediate certificate en chain files tegen.
Goede tutorial. Ietwat verouderd, de settings op de IBM site zijn wat veranderd. Maar nog steeds goed doorheen te komen.
Heb de tutorial gevolgd, maar krijg tijdens het testen de volgende foutmelding:
Server returned HTTP response code -1

Response info:
Error in sending rest post to developer url https://loratest-dev.eu-gb.mybluemix.net/loratest, for device 0059AC0000181010, payloadhex 30. Error details: com.mendix.modules.microflowengine.MicroflowException 404: Not Found at DevLoRa_UpLink.SendExactLoraMessToDev (CallRest : 'Call REST (POST)') at DeviceMngmt.SendTestUplinkMessage (SubMicroflow : 'SendExactLoraMessToDev') at DeviceMngmt.IVK_SendTestMessage (SubMicroflow : 'SendTestUplinkMessage') Advanced stacktrace:

Ik heb alles nog eens gecheckt.

URL = https://loratest-dev.eu-gb.mybluemix.net/loratest
Enig idee? Certificaten?
Never mind mijn vorige post. In Node-red niet goed gedeployed. Maar nu andere problemen. Met mijn HTTP client kan ik keurig een HTTPS request doen richting de node-red server. Krijg keurig response. Maar vanuit de KPN portaal niet. Dit is de error message:

Server returned HTTP response code 0

Response info:
{"DevEUI_uplink":{"Time":"2018-05-06T03:27:28.546+0200","DevEUI":"0059AC0000180B78","FPort":"2","FCntUp":"3","ADRbit":"1","MType":"4","FCntDn":"3","payload_hex":"30","mic_hex":"5f95a77a","Lrcid":"0059AC01","LrrRSSI":"-100.000000","LrrSNR":"5.750000","SpFact":"12","SubBand":"G0","Channel":"LC7","DevLrrCnt":"4","Lrrid":"080603DB","LrrLAT":"52.069241","LrrLON":"4.349416","Lrrs":{"Lrr":[{"Lrrid":"080603DB","Chain":"0","LrrRSSI":"-100.000000","LrrSNR":"5.750000","LrrESP":"-101.024590"},{"Lrrid":"080E00C8","Chain":"0","LrrRSSI":"-118.000000","LrrSNR":"-4.000000","LrrESP":"-123.455406"},{"Lrrid":"080602C9","Chain":"0","LrrRSSI":"-119.000000","LrrSNR":"-9.500000","LrrESP":"-128.961838"}]},"CustomerID":"123456789","CustomerData":{"alr":{"pro":"SMTC/LoRaMote","ver":"1"}},"ModelCfg":"0","AppSKey":"a002tnre9d662017ad916032313527d9"}}

Any thoughts?
Some addition to my last post. My certificates seems to be Okay according to ssllabs.
Reputatie 7
Badge +11
Hi @Elfred, goed bezig geweest! Fijn om te horen dat de guide nog te volgen is ondanks enkele veranderingen.

Uw SSL certificaat ziet er goed uit en mag de oorzaak niet zijn. Wat gaat er precies verkeerd? Zo te zien krijgt u het gehele bericht door op de node-red server, inclusief payload. De uplink en downlink test functies op de developer portal kunnen soms problemen geven.

Als u twijfelt of de application server de berichten wel juist ontvangt is het een optie om tijdelijk een andere HTTPS endpoint erop te zetten zoals webhook.site. Daarmee sluit u de werking van uw device en de developer portal uit.
Hi, ik heb de tutorial doorlopen en met wat vallen en opstaan alles zo goed als het gaat aan het werk gekregen.
Ik heb netjes een NODE-RED pagina aangemaakt. Op wat kleine onduidelijkheden is dit allemaal prima gelukt.

D.w.z. ik ontvang data vanuit de uplink zoals hier voorgesteld echter krijg ik altijd de time out. Het vreemde is dat ik de data wel ontvang in de NODE-RED omgeving.

Server returned HTTP response code -1

Response info:
Error in sending rest post to developer url https://renaissance.eu-gb.mybluemix.net/lorapost, for device 0059AC00001803ED, payloadhex 12. Error details: java.net.SocketTimeoutException Read timed out

Merk op de data wordt wel netjes ontvangen en op de Dashboard ook netjes weer gegven.

Enige idee wat ik fout doe.

Met vriendelijke groet
Johan
Het lijkt erop, dat er een "http response" punt mist in het Node-RED diagram.
Voeg dus een "http response" out toe en verbind deze met de "http" in punt.
Dit levert een werkende sheet op.
Leuke tutorial.

Reageer