Support Forum

Share your projects and post your questions

Register   or   Sign In
The Forum

IO PI MCP23017 powered from 16ch relay board

2437 Views - Created 27/08/2018

27/08/2018

Posted by:
lsobacki

lsobacki Avatar

Hello. Just bought two IO PI Zero boards and im trying to make it work correctly. I have to use 6 - 7 16ch relay boards so i had idea to connect those IO PI boards with relay board pins with 2.54mm socket.
https://drive.google.com/open?id=1yi_txYZxqleixEbXnPuUVVWU2s06g7L9
Otherwise i would have to connect 80, 1m cables from IO PI Zero expander to relays.
I've made also one extra hole in IO PI pcb to solder pcb ground to socket pins. Now ground of IO PI and relay board are connected.
The relay board have 12v power supply and 5v inverter, I had powered IO PI from those 5v, but raspberry didn't found and device.
When i connectect 3,3v from raspberry it worked, all 16 relays are working but still have some questions and one issue.

1) I dont wanna force raspberry to power any device, so i have to power IO PI Board with 5v and 3,3 also ?

2) I use wiringpi to control of this board with command: gpio -x mcp23017:100:0x20 mode 100 out ... till 15 then i used

gpio -x mcp23017:100:0x20 write 100 ( 1 or 0 ) to change state and its working well when i'm turning on relays.

When all relays are ON i can't turn off any of them, until i'll first turn off 15, but then 8 relays are turning off, so i'm consfused.

Theres also Interrupt A and Interrupt B thing, so don't know what to do rignt now.

I'll be glad for help.

27/08/2018

Posted by:
andrew

andrew Avatar

Location:
United Kingdom

andrew Twitter  andrew Website  

Hello

You can power the 5V side of the IO Pi Zero from your relay board but you will need to connect the 3.3V pin to the Raspberry Pi as this is used by the I2C level translator to power the Raspberry Pi's side of the I2C bus.

I haven't used wiringpi for a long time so I am not sure how it works with the mcp23017. We do have a command line program for controlling the IO Pi on our GitHub repository at https://github.com/abelectronicsuk/ABElectronics_CLI/tree/master/iopi_c You can use it for controlling all aspects of the mpc23017 directly from the bash shell. It may be worth giving that a try and seeing if it works any better than wiringpi. We also have IO Pi software libraries for Python, C, C++ and NodeJS.

Interrupts A and B are used when using the IO Pi for digital inputs. You can configure the interrupts to go high or low when a specified pin, or pins, either change state or goes to a preset state. The interrupts are normally used so you can check to see if an input changed without having to keep reading the value from that input continuously. There is a better explanation of how the interrupts work in the datasheet for the MCP23017 on page 24 but as you are using the IO Pi to control relays you shouldn't need to use the interrupt pins.

30/08/2018

Posted by:
lsobacki

lsobacki Avatar

Hello, thanks for reply just after making first post i tooked my chance and soldered 5v from relay board, had 5v and 3.3 both present

and it worked. The wiring pi was not necessary because i found iopi soft on github designed to home assistant, and now it's

working like a charm. Good Work GUYS! Therese only one problem i cannot solve myself. My relays boards are activated low.

Now i have inverterd switches in home assistant. Also when im rebooting Pi all relays blink for a second and it's not good for me

because when i will connect 230v devicec through relays it may cause fuses protection problem when all devicec turn of for a

second. Think the blinking is causes by Changing Pi state while lib is loading but when i looked in iopiswitch.py code i realised

im to stupid in this moment to understand that :-)

30/08/2018

Posted by:
andrew

andrew Avatar

Location:
United Kingdom

andrew Twitter  andrew Website  

If the relays are activated low then the safest option would be to put an inverter on each channel between the IO Pi and the relay board. You could use something like a pair of CD74AC04 hex inverters. They are available in a DIP package so it should be fairly easy to solder them into a bit of Veroboard.

Sign in to post your reply

Note: documents in Portable Document Format (PDF) require Adobe Acrobat Reader 5.0 or higher to view, download Adobe Acrobat Reader or other PDF reading software for your computer or mobile device.