Hello Guys
I need some help decoding this payload, I did follow the below example but for the second item which is soil percentage i am not able to get it
Payload
01031C
010501B7005A004A000C00100028000000000000000000000000000088AC
As you can see I have commented others out while trying to work with the “soil_Moisture”.
The value is 01B7 which converted is 439. I am not able to get the value.
Could someone help me with the correct way of doing “left shift” please?
where
01 - sensor_address
03 - functional_code
1C – data_length
0105 -soil Temperature
01B7 – soil moisture
005A - EC
004A - PH
000C - N
0010 - P
0028 - K
0000000000000000000000000000 - empty bits
88AC - CRC
My code is as follows:-
function Decoder(bytes, port) {
//var soil_temperature = (bytes[4]) + bytes[5]*256;
var soil_Moisture = (bytes[6]<<8); + (bytes[7]); I can't get the value of 439
//var ec = (bytes[8]) + bytes[9];
//var ph = (bytes[10]) + bytes[11];
//var N = (bytes[12]) + bytes[13];
//var P = (bytes[14]) + bytes[15];
//var K = (bytes[16]) + bytes[17];
//soil_temperature = soil_temperature; //display at Consol
//field2= soil_temperature; //display at ThinkSpeak IOT Cloud
//soil_Moisture = soil_Moisture/10 ;
//field3= soil_Moisture;
//ec=ec;
//field4=ec;
//ph=ph/10;
//field5=ph;
//N=N
//field6=N;
//P=K
//field7=N;
//K=K
//field8=N;
return{
//field2,
//soil_temperature,
//field3,
soil_Moisture,
//field4,
//ec,
//field5,
//ph,
//field6,
//N,
//field7,
//P,
//field8,
//K,
};
}