Okey, getting this topic back on track. I’m going to use Python to control the relays with API command.
The interface is Node-red dashboard.
I experienced a lot this weekend with Node-Red and the MPC23008 boards. I have it working for a fusion 4 board, because the API commands for controlling relays is different than with the MPC23008 board.
The thing is: i want to control the relays individual and as suggested by Travis over email, my program must always check the status of the relays before opening / closing another relay. " .
the bit assigned for the relay is simple: 1, 2, 4, 8, 16, 32, 64, 128. Placing a Decimal 9 in front for on / off of the relay. Controlling individual relays: for instance 2 and 4 on results in a bit of 10.
This part i understand. To check the status of the relay is send decimal 9 and i get back the counts of relais active: for instance “10” ( 2 and 4 are on ).
But how would this now work in an automated setting in python?
When i would request to switch a relay on / off the first thing the software does need to do is send a relay status command? See witch relays are already ON, and add the bit value requested to get a new bit value for sending? For instance: 2 and 4 are ON: i would get back value 10, i want to power relay 1 also ON, i would send out value 11. If i want to power OFF relay 1, i again check the total relais status (11), substracts 1, resulting in value 10 that i need to send.
Is this the correct way to do it?!
I made an excell file of the different API codes i need to send when using a 8 I2C port hub in between.
Is this correct?