Convert a 16 bit integer to 16 discrete outputs

Hi @cdoctor.

Some time ago I just finished a project with an arduino nano that communicates with the PCF8575 port expander via an i2c bus.
A detailed explanation is at GPIOs two way port expander via USB.

In short, the device analyzes the status of the ports on the PCF8575 and sends them via USB in the form of a series of numbers (integer), with the addition of letters at the beginning.
The letter indicates whether it is a first or second group of ports at a specific i2C address that is referred to PCF8575.

So, the message is: A00100001.

This means that at the first i2c address (A), the status of ports (ports) is 00100001.
Ports are numbered from right to left.

I created a node for this analysis.
Node is a node-red-contrib-PCF8575-extractor.
You need to install it manually.

Node analyzes whether the first character is (A, B, C, D, E, F, G or H), whether the 2nd to 9th characters are numbers 0 or 1, and that the message length is 9 characters.

The analyzed value goes to 8 outputs with associated value.

Try installing and testing if it might be useful to you.
You have an example in Menu-> Import-> Example -> ...

Feel free to edit the node according to your needs.

Greeting!

2 Likes