How to read GPIO as binary

#1

I am a newcomer to Node-Red but learning all the time and managed to get a few things up and running on the dashboard on my Pi.

However my next goal is to read an 8 bit binary code as input to 8 GPIO pins on my Pi, and then turn it into a decimal code(0-255).

It sounds simple but not sure to start. Any ideas/advice welcomed!

0 Likes

#2

Method:
Sum(Gpio1x1, Gpio2x2,Gpio3x4,......Gpio8x128) lowest to highest bit.

0 Likes

#3

Thanks @ghayne I get your principle to do the math. But I have problem adding the numbers in a function. How do I read the gpio status (and add) all 8 all at once? .

0 Likes

#4

No need for a function node, think flow context variables using a change node. Cannot give you an example as I am away from a node-red machine.

0 Likes

#5

Feed all the inputs into a Join node configured something like this

The effect is that whenever an input changes, then 0.1 second later (to give any other changed inputs time to arrive) it will send a message with all 8 values in the payload, identified by their pin numbers. You might need to play with the delay.

0 Likes

#6

Thanks @Colin I have this running now.

0 Likes