node-red-contrib-i2c icon indicating copy to clipboard operation
node-red-contrib-i2c copied to clipboard

Signed integer only as payload for I²C out node?

Open rei-vilo opened this issue 5 years ago • 2 comments

I'm using the I²C out node against a PCF8591.

  • Address 64
  • Command 40 for DAC output
  • Sent bytes 1
  • Values 0 and 127 are accepted,

But value 254 is refused with the following error message:

"RangeError [ERR_OUT_OF_RANGE]: The value of "value" is out of range. It must be >= -128 and <= 127. Received 254"

Are signed integers allowed only for the I²C out node?

How to send plain an unsigned integer?

Thank you for your help!

Releases

  • I²C node 0.5.5
  • Node-RED 1.0.3

rei-vilo avatar Feb 20 '20 18:02 rei-vilo

As a temporary workaround, I can add an in-between function before the I²C out node.

if (msg.payload > 127) 
{
    msg.payload = msg.payload - 256;
}
return msg;

The implementation of the I²C out node is not consistent with the I²C in node, which outputs unsigned integers 0..255 .

rei-vilo avatar Feb 20 '20 18:02 rei-vilo

Is there any expectation of this being fixed? Anytime soon? True there is a work-around, but it should be fixed no?

Nodi-Rubrum avatar Aug 19 '20 06:08 Nodi-Rubrum