Hi, can someone help with this? I’m quite new on lorawan…
I have an NPK sensor Node which sends the payload to my Datacake webhook to get data displayed on a dashboard. But it returns this error “json: unsupported value: NaN”.
I’m using this function provided from the manufacturer/seller
This is more of an integration / javascript issue than a LoRaWAN issue I think.
NaN generally means “not a number”, this can be the result of a failed calculation, such as trying to divide by zero, taking the log of a negative number, etc. But perhaps also the case (depending on the programming language, I don’t know, not familiar with javascript) if you try to get a non-existing item from a map or dictionary. Perhaps the key is case-sensitive, so “N” is not the same as “n”.
Your example string looks like hexadecimal coded data, but its length is not a multiple of two, so something is wrong there. Normally you have two hex digits per byte.
I would double-check with the decoder provided by the manufacturer, get some known-good example data and try to send a simulated uplink. You can find that in the console under
Application / / End Devices / under Messaging
I suspect @Johan_Scheepers will be setting the next step for you to do rather than doing it for you, so you could turn the hex values in to decimal yourself.
But as mentioned by @bertrik, you’ve got a digit missing as the payload you quoted is 67 characters long
So the Battery Voltage could be A0DD
And the payload function needs updating.
And we don’t know where you saw this error message so it may be working OK but having a problem on Datacake.
The first character was extra, now it works by usining this payload function
value=bytes[23]<<8 | bytes[24];
var N=value; //Unit:mg/kg
value=bytes[25]<<8 | bytes[26];
var P=value; //Unit:mg/kg
value=bytes[27]<<8 | bytes[28];
var K=value; //Unit:mg/kg
var value=bytes[29]<<8 | bytes[30];
var batV=value/1000;//Battery,units:V
Hello Manuelstona, I’m new to this IOT and I’m having problems like you had. could you share your uplink and downlink code for your npk sensor? I don’t know how to program at all. thanks in advance. Nathan