Using node-red with ST NUCLEO L073RZ Sx1272

I have been working with the great LoRaWAN combo from STMicroelectronics – a low-cost dev board based on a ARM®32-bit Cortex®-M0+ CPU, coupled with the Sx1272 on an Arduino-compatible shield.

Using the online mbed compiler – https://developer.mbed.org/compiler/ , I modded the demo code – LoRaWAN-demo-72 – to add simple output to an OLED display – see attached photo.

My node-red install runs on a server hosted by https://www.scaleway.com/ that costs around €3/month. I designed a very simple activity monitor – the design of which may help others.

To the basic node-red install, I added node-red-contrib-ttn and node-red-dashboard.

file

The dashboard output looks like this:

file

Here is the node-red code:

[{"id":"c7f3f3bf.3a9a5","type":"function","z":"794a77ef.208d58","name":"Extract data","func":"count = {}\nrssi = {}\nsnr = {}\n\n//var b = new Buffer(msg.payload_raw);\n//count.payload = (b[1] << 8 | b[2]).toString();\n//var r = b[3] << 8 | b[4];\n//if ((r & 0x8000) > 0) {\n// r = r - 0x10000;\n//}\n//rssi.payload = r.toString();\n//snr.payload = (b[5]).toString();\n\ncount.payload = msg.counter;\n\nrssi.payload = msg.metadata.gateways[0].rssi;\nsnr.payload = msg.metadata.gateways[0].snr;\n\nreturn [count, rssi, snr];","outputs":"3","noerr":0,"x":170,"y":260,"wires":[["5533ce08.ffeea"],["12293833.30e738","74ff1ba5.03d634"],["72d06acb.dc1194","efcfc380.ceda4"]]},{"id":"1a8f347b.d8cdbc","type":"ttn message","z":"794a77ef.208d58","name":"stloramsg","app":"36e8961a.558d8a","dev_id":"stlora099","field":"","x":100,"y":180,"wires":[["c7f3f3bf.3a9a5","6d23bd50.971d44","56b3ab07.9b66f4","fdc7c21d.f6384","c5500bb7.c34b58"]]},{"id":"5533ce08.ffeea","type":"ui_text","z":"794a77ef.208d58","group":"4d6a022d.e892ec","order":7,"width":0,"height":0,"name":"txtCount","label":"Count","format":"{{msg.payload}}","layout":"row-spread","x":380,"y":200,"wires":[]},{"id":"12293833.30e738","type":"ui_text","z":"794a77ef.208d58","group":"4d6a022d.e892ec","order":5,"width":0,"height":0,"name":"txtRssi","label":"RSSI","format":"{{msg.payload}}","layout":"row-spread","x":370,"y":240,"wires":[]},{"id":"72d06acb.dc1194","type":"ui_text","z":"794a77ef.208d58","group":"4d6a022d.e892ec","order":6,"width":0,"height":0,"name":"txtSnr","label":"SNR","format":"{{msg.payload}}","layout":"row-spread","x":370,"y":320,"wires":[]},{"id":"6d23bd50.971d44","type":"ui_text","z":"794a77ef.208d58","group":"4d6a022d.e892ec","order":1,"width":0,"height":0,"name":"txtDevice","label":"Device","format":"{{msg.dev_id}}","layout":"row-spread","x":380,"y":40,"wires":[]},{"id":"56b3ab07.9b66f4","type":"ui_text","z":"794a77ef.208d58","group":"4d6a022d.e892ec","order":3,"width":0,"height":0,"name":"txtDataRate","label":"Data Rate","format":"{{msg.metadata.data_rate}}","layout":"row-spread","x":390,"y":120,"wires":[]},{"id":"fdc7c21d.f6384","type":"ui_text","z":"794a77ef.208d58","group":"4d6a022d.e892ec","order":4,"width":0,"height":0,"name":"txtCodingRate","label":"Coding Rate","format":"{{msg.metadata.coding_rate}}","layout":"row-spread","x":400,"y":160,"wires":[]},{"id":"c5500bb7.c34b58","type":"ui_text","z":"794a77ef.208d58","group":"4d6a022d.e892ec","order":2,"width":0,"height":0,"name":"txtFrequency","label":"Freq.","format":"{{msg.metadata.frequency}}","layout":"row-spread","x":390,"y":80,"wires":[]},{"id":"74ff1ba5.03d634","type":"ui_chart","z":"794a77ef.208d58","name":"","group":"4d6a022d.e892ec","order":8,"width":0,"height":0,"label":"Signal Strength","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","ymin":"-150","ymax":"0","removeOlder":1,"removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"x":400,"y":280,"wires":[[],[]]},{"id":"efcfc380.ceda4","type":"ui_chart","z":"794a77ef.208d58","name":"SNR","group":"4d6a022d.e892ec","order":9,"width":0,"height":0,"label":"Signal:Noise Ratio","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","ymin":"0","ymax":"10","removeOlder":1,"removeOlderPoints":"500","removeOlderUnit":"3600","cutout":0,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"x":370,"y":360,"wires":[[],[]]},{"id":"36e8961a.558d8a","type":"ttn app","z":"51e5ce7c.989ce","appId":"YOUR APPID","region":"eu","accessKey":"YOUR ACCESSKEY"},{"id":"4d6a022d.e892ec","type":"ui_group","z":"","name":"Device Detail","tab":"71cb76aa.9d5c98","order":2,"disp":false,"width":"6"},{"id":"71cb76aa.9d5c98","type":"ui_tab","z":"","name":"devices","icon":"dashboard"}]

 

Leave a Reply