Dear All :
- The switch has topic is no2_pn, but hv error...why?
- In the code Line 20 that is correct?
- Or in the code has another error?
Thank u.
Dear All :
Thank u.
The error is because no2_pn
is a String value so it needs to have "
around it. The same is true for "no2_cali_val"
and "no2_array"
.
if (msg.topic == "no2_pn")
Dear Sir :
I hope the output is no2_array, not "no2_array".
So how to do?
Thank u.
I'm sorry - I did not spot that no2_array
was a locally defined variable.
So "no2_pn"
and "no2_cali_val"
are String types and need quotes.
no2_array
is a local variable so does not need quotes.
Dear Sir :
Thank u.
Thanks again.
Please share your code (not a screenshot, paste it in and format it as a code block using by wrapping it with ```.
What error are you now getting?
Dear Sir :
//var i;
//var j;
var no2_array=[];
if(msg.topic=="no2_pn")
{
if(msg.payload==true)
no2_array[0]=0; //+
else
no2_array[0]=1; //-
}
//
if(msg.topic=="no2_cali_val")
{
//1j=msg.payload;
no2_array[1]=(msg.payload<<8);
no2_array[2]=msg.payload&0xFF;
}
//
msg.payload="no2_array";
return msg;
Thank u.
I have edited your last post, but next time that you post any code, please use three back ticks and not quotations.
Like this ```
and not """
No, no2_array
is a variable and not a string, so you don't need string quotes around it.
So instead of msg.payload="no2_array";
you need msg.payload=no2_array;
Dear Sir :
Thank u.
This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.