I am currently reading the ID number of the energy meter with Node JS and serialport library. The power meter ID has the following format xx xx xx xx xx xx. When I send the command and receive the data, I get the following DEC numbers: 0 0 24 1 104 115
. Following the manufacturer's instructions, I have to convert this sequence to HEX. I have added it in an array and exported to the console as follows:
console.log(
(arrID[0]).toString(16)+
(arrID[1]).toString(16) +
(arrID[2]).toString(16) +
(arrID[3]).toString(16) +
(arrID[4]).toString(16) +
(arrID[5].toString(16)
);
and it returned to me as follows 001816873
. This is the wrong ID, The correct ID to show must be 000018016873
. I know the reason is the conversion of numbers with the first character is 0. I look forward to advice from you.