Hi,
I have written a JavaScript decode function.
I can see my data sent from LoRa node at the Device Data tab.
I can also see my data in the table form in grafana or chronograf when my data is put into influxDB. But the problem is that my data just can’t be plotted out into graph form.
I feel like something is missing in the JavaScript decode function. But I just don’t know what.
Below is my function
function Decode(fPort, bytes, variables) {
if(bytes.length == 1) {
if(bytes[0] == 1) {
return {
‘button’: ‘activated’
}
} else {
return {
‘error’: ‘button action unknown’
}
}
} else {
var pkFreq = ‘’;
var cnt;
First, you can’t plot “activated” unless you define that in your data visualization software. Usually, we use “1” or “true”. Its opposite (“non-activated”) state should also be detected and returned as “0” or “false”. You can detect other states (e.g., undefined) but, again, don’t return “button action unknown” but “NaN” or something more standardized.
Second, I presume you’re pulling the time-stamp of transmission out at some point? Not all sensors send such data, but some do - you’ll need to check your technical data. It’s normally safe to assume time received == time of event, but in a congested/very busy area, maybe not. Thus, you should keep track Fcnt at least, to have a feel for what’s going on.
Also, please learn to select your JS code and tag it as “preformatted text”