question

smallsolar avatar image
smallsolar asked

I2C relay board or GPIO

I purchased an i2c relay board (DockerPi 4 CHannel Relay) that I hoped to use with my RPI running Venus OS to control some DC circuits based on temperature, battery voltage, etc. When I bought it, I wasn't aware of the differences between controlling the relays with i2c vs the GPIO pins (still not really clear on it). I see many instructions for installing extra relays that are controlled via node red etc by mapping the GPIO pins but not really anything on an i2c controlled relay board.


Is it possible (for an average diy enthusiast) to use this board in the manner I am desiring, or should I just look for a different GPIO relay board that others have already used to make this work?


TIA

Venus OSRaspberry PiNode-REDRelay
2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

2 Answers
Rob Duthie avatar image
Rob Duthie answered ·

Hi

Look at this. This is what i have design and tested to date.

Victron Raspi Hat.pdf


victron-raspi-hat.pdf (673.2 KiB)
1 comment
2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

smallsolar avatar image smallsolar commented ·

I did see your board and was thinking of going that route if I had to buy a new one. How would one go about getting your board? I know some said to just use your schematics and print one's own.

Edit: Now that I look at your schematics more closely, I see that your board also uses i2c control. Do you have some example flows in node red for relay control?

0 Likes 0 ·
johnny-brusevold avatar image
johnny-brusevold answered ·

I use this card and control via node-red in venus-os. Have tested 3 cards at once, which worked satisfactorily.

Relaycard

3 comments
2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

smallsolar avatar image smallsolar commented ·
Did you have to do anything special to get the i2c controls of the relays working?
0 Likes 0 ·
johnny-brusevold avatar image johnny-brusevold smallsolar commented ·

@SmallSolar

You can set state on the relays with the venus-os built-in 'i2cget' command from the command line.

Now I use a python library to set the hex value on the PCF8574 chip, but I don't remember exactly which one, but I can eventually find out. There are several I have tested and they all worked fine.

The one I've used uses i2cbus and another that uses gpiobus, if I remember correctly.


To check the set state on the relays, I now use i2cget and 'node-red-contrib-bit' to read the hex value and convert to relay number.

It's simple and works well, so I haven't bothered to program further for more direct control.

https://flows.nodered.org/node/node-red-contrib-bit


relay.png

0 Likes 0 ·
relay.png (91.5 KiB)
smallsolar avatar image smallsolar johnny-brusevold commented ·

Thanks! I had searched for "i2c venus os" but couldn't really find anything that made me think it would work. After seeing your post, I searched "i2c node red" and there are a bunch of results. Looks like I may be able to make this board work!

1 Like 1 ·