Node-red
- This topic has 14 replies, 5 voices, and was last updated 7 years, 9 months ago by
Ricky Terzis.
-
AuthorPosts
-
January 31, 2017 at 7:57 am #16573
Akshay Bhavsar
ParticipantHi there,
I am new to this.
How to receive data from MTDOT to MultiConnect Conduit and showing on Node-Red as shown on following linkBut at 5:50, the guy has copied code from wordpad file for particular function. I don’t know how to get that and how can I write my own function. If there is any reference then please indicate.
Your help would be great.
Thanks
AkshayJanuary 31, 2017 at 8:46 am #16577Leon Lindenfelser
ModeratorHi Akshay
You can drag a function node into NodeRED and write code in it. You can write the function code in your favorite editor then cut and paste into the function node. The video also shows a method of importing. Do whatever works best for how you like to work.
Here is a link for writing functions in NodeRED
https://nodered.org/docs/writing-functionsKind regards,
LeonJanuary 31, 2017 at 9:43 am #16579Steve Kovarik
ModeratorAkshay
Here is a link to the full “Flow” created at 5:50 in the video.
This includes LoRaIn Node–>F(n) Node—>Debug NodeAnd is intended for use with the MTDOT-BOX or EVB when selecting
“LoRa Demo” mode of operation to parse out sensor data.https://webfiles.multitech.com/mmm/LoRa_Demo_ParserFlow.txt
Thanks for watching
January 31, 2017 at 6:00 pm #16607Akshay Bhavsar
Participant@Leon I know the link, but there isn’t any full example for it, such as assigning data type and stuff.
var data_type = { none : 0x00, led1 : 0x01, led2 : 0x02, lux_max : 0x03, lux_min : 0x04, lux_curr : 0x05, baro_max : 0x06, baro_min : 0x07, baro_curr : 0x08, temp_max : 0x09, temp__min : 0x0A, temp_curr : 0x0B, accel_max : 0x0C, accel_min : 0x0D, accel_curr : 0x0E, configuration : 0x0F, gpio_in : 0x10, gpio_out : 0x11, current_max : 0x12, current_min : 0x13, current_curr : 0x14, gps_latitude : 0x15, gps_longitude : 0x16, gps_time : 0x17, gps_date : 0x18, gps_lock : 0x19, qos_up : 0x1A, qos_dwn : 0x1B, rf_out : 0x1C, data_mark : 0x1D, }; var data_struc = { data_valid : 0, block_start :0, temperature : 0, x_pos : 0, y_pos : 0, z_pos : 0, baro_pressure : 0, lux : 0, pkt_timer :0, rf_pwr : 0, sf_val : 0, rssi_up : 0, snr_up : 0, rssi_dwn : 0, snr_dwn :0 , lat_deg : 0 , lat_min : 0, long_deg : 0, long_min : 0, num_sats : 0 , gps_status : 0, }; context.global.data_out = context.global.data_out || data_struc; var pData = context.global.data_out; var msg_pntr = 0; var temp = 0; while (msg_pntr < msg.payload.length){ switch (msg.payload[msg_pntr]){ case data_type.lux_max: case data_type.lux_min: case data_type.lux_curr: pData.lux = msg.payload[++msg_pntr] << 8; pData.lux |= msg.payload[++msg_pntr]; pData.lux = pData.lux * 0.24; msg_pntr++; break; case data_type.baro_max: case data_type.baro_min: case data_type.baro_curr: pData.baro_pressure = msg.payload[++msg_pntr]<<16; pData.baro_pressure |= msg.payload[++msg_pntr]<<8; pData.baro_pressure |= msg.payload[++msg_pntr]; pData.baro_pressure = pData.baro_pressure * 0.25; msg_pntr++; break; case data_type.accel_max: case data_type.accel_min: case data_type.accel_curr: pData.x_pos = ((msg.payload[++msg_pntr] << 24) >> 24) * 0.0625; pData.y_pos = ((msg.payload[++msg_pntr] << 24) >> 24) * 0.0625; pData.z_pos = ((msg.payload[++msg_pntr] << 24) >> 24) * 0.0625; msg_pntr++; break; case data_type.temp_min: case data_type.temp_max: case data_type.temp_curr: pData.temperature = msg.payload[++msg_pntr] << 24; pData.temperature |= msg.payload[++msg_pntr] << 16; pData.temperature = (pData.temperature >> 16) * 0.0625; msg_pntr++; break; case data_type.configuration: pData.pkt_timer = msg.payload[++msg_pntr]; msg_pntr++; break; case data_type.current_max: case data_type.current_min: case data_type.current_curr: msg_pntr++; msg_pntr++; msg_pntr++; break; case data_type.gps_latitude: pData.lat_deg = (msg.payload[++msg_pntr] << 24) >> 24; pData.lat_min = msg.payload[++msg_pntr]; temp = msg.payload[++msg_pntr] << 8 ; temp |= msg.payload[++msg_pntr]; pData.lat_min = pData.lat_min + (temp * 0.0001); msg_pntr++; break; case data_type.gps_longitude: pData.long_deg = (msg.payload[++msg_pntr] << 24); pData.long_deg |= (msg.payload[++msg_pntr] << 16); pData.long_deg = pData.long_deg >> 16; pData.long_min = msg.payload[++msg_pntr]; temp = msg.payload[++msg_pntr] << 8; temp |= msg.payload[++msg_pntr]; pData.long_min = pData.long_min + (temp * 0.0001); msg_pntr++; break; case data_type.gps_time: msg_pntr++; msg_pntr++; msg_pntr++; msg_pntr++; break; case data_type.gps_date: msg_pntr++; msg_pntr++; msg_pntr++; msg_pntr++; break; case data_type.gps_lock: msg_pntr++; pData.gps_status = msg.payload[msg_pntr] & 0x0F; pData.num_sats = msg.payload[msg_pntr++] >> 4; break; case data_type.qos_up: pData.rssi_up = msg.payload[++msg_pntr] << 24; pData.rssi_up |= msg.payload[++msg_pntr] << 16; pData.rssi_up = pData.rssi_up >> 16; pData.snr_up = (msg.payload[++msg_pntr] << 24) >> 24; pData.rf_pwr = (msg.payload[++msg_pntr] << 24) >> 24; msg_pntr++; break; case data_type.qos_dwn: pData.rssi_dwn = msg.payload[++msg_pntr] << 24; pData.rssi_dwn |= msg.payload[++msg_pntr] << 16; pData.rssi_dwn = pData.rssi_dwn >> 16; pData.snr_dwn = ((msg.payload[++msg_pntr] << 24) >> 24) / 4; msg_pntr++; break; case data_type.rf_out: pData.rf_pwr = (msg.payload[++msg_pntr] << 24) >> 24; msg_pntr++; break; case data_type.data_mark: if (msg_pntr == '0') { pData = data_struc; pData.block_start = 1; msg_pntr++; } else if (msg_pntr == (msg.payload.length - 1) && (pData.block_start === 1)) { pData.data_valid = 1; msg_pntr++; } else { pData = data_struc; msg_pntr = msg.payload.length; } break; default: pData = data_struc; msg_pntr = msg.payload.length; } } pData.sf_val = parseInt(msg.datr.replace("SF"," "),10); context.global.data_out = pData; return pData;
@steve Thanks man. It has created above code, but still I am not able to see data on Node-RED at debug window.
When I deploy I am getting following error, what that means and how can I correct it ?
” mqtt-broker: staging.thethingsnetwork.org:1883 ”
Thanks guys
AkshayJanuary 31, 2017 at 6:43 pm #16610Akshay Bhavsar
ParticipantHi guys,
Don’t worry about the above error, I figure it out.Now the problem is I am note able to receive data on debug window of Node-RED. I am successfully able to join MTDOT-Box-G-915 to MultiConnect Conduit. When I run LoRa Demo from theMTDOT-Box-G-915 and send the the data not able to receive it on Node-RED.
I have imported the code as @Steve Kovarik has suggested.
So, What can be the issue ?
Thanks
AkshayFebruary 1, 2017 at 4:30 pm #16621Akshay Bhavsar
ParticipantHi Steve,
Is there any updates on this or the code you have provided might have something wrong in it. MTDOT-BOX-G-195 do join conduit box. When I run IP address of conduit box and check system log and under the LoRa tab it does shows the connection. I have used your code( as mentioned above thread) in Node-RED and send data from MTDOT-BOX, but do not able to see that in debug window.
Your help would be great.
Thanks
AkshayFebruary 1, 2017 at 5:36 pm #16622Steve Kovarik
ModeratorHi Akshay
I just downloaded and installed the flow from the FTP link I provided, and
it worked fine. Another idea is to drag out a “Debug Output” node and
connect it to the “LoRa Input” node and see if you receive anything in the
debug tab. This will prove the gateway is receiving LoRa packets and can
display them in the debug tab.February 1, 2017 at 5:47 pm #16623Akshay Bhavsar
ParticipantFebruary 1, 2017 at 5:47 pm #16624Akshay Bhavsar
ParticipantFebruary 1, 2017 at 5:50 pm #16625Akshay Bhavsar
Participanthttps://drive.google.com/file/d/0B8vP1Z3v0Sw8d3Y0ZDRTWVlEZ2M/view?usp=sharing
Look like link tab doesn’t work.
May 2, 2017 at 8:37 am #18876Sandoche Balakrichenan
ParticipantI added the javascript provided in the ftp link above. And on sending the message from EVB, i get the following error:
“TypeError: Cannot read property ‘replace’ of undefined”
May 2, 2017 at 8:59 am #18877Sandoche Balakrichenan
ParticipantIn addition, i am trying to push the data from EVB to the influx database.
I can see the EVB messages in the payload, but they are not inserted into InfluxDB.
But, when i inject with a simple timestamp from node-red, the message is stored in InfluxDB.
Is the issue related to the formatting the EVB message?
May 2, 2017 at 9:01 am #18878Sandoche Balakrichenan
ParticipantHere is the image for my question above : https://ibb.co/j6Xpt5
May 3, 2017 at 8:51 am #18901Sandoche Balakrichenan
ParticipantIn addition, i am trying to push the data from EVB to the influx database.
I can see the EVB messages in the payload, but they are not inserted into InfluxDB.
But, when i inject with a simple timestamp from node-red, the message is stored in InfluxDB.
If i modify the java script provided by @Steve Kovarik to get only the temperature, it works.
There is some issue wit this line in the java script :
pData.sf_val = parseInt(msg.datr.replace(“SF”,” “),10);
the variable “msg.datr” seems to be the issue.
July 13, 2017 at 12:41 pm #19936Ricky Terzis
ParticipantHi…i also had the same question and i think you should follow as suggested above that you can drag a function node into NodeRED and write code in it. You can write the function code in your favorite editor then cut and paste into the function node.
-
AuthorPosts
- You must be logged in to reply to this topic.