SteveSpencer
Posts: 367
Joined: Thu Mar 28, 2013 9:19 am
Location: Nottingham, UK

Re: Relay boards

Thu Jan 24, 2019 10:16 am

You would expect that to be the case, but many relay boards available work on reversed logic from that point of view.
In reality you are pulling something low, and that activates the relay. This allows the use of pull-up resistors so that the overall system comes up with everything switched off, which is generally safest.
Steve S
No, I can't think of anything funny that won't offend someone if they want it to...

Brandon92
Posts: 915
Joined: Wed Jul 25, 2018 9:29 pm
Location: The Netherlands

Re: Relay boards

Thu Jan 24, 2019 10:23 am

Franita wrote:
Thu Jan 24, 2019 9:29 am
Hi kind people, great news, I believe I have managed to get my Pi, mcp23017 and my relay working.... :o BUT it's looking like it's working backwards.....
If I give it..0x00 the relay lights come on
If I give it 0xff they all go off
I thought it was supposed to be the other way round......
How did you connect everything to each other? And configure the relay board.

Franita
Posts: 11
Joined: Wed Dec 26, 2018 11:24 am

Re: Relay boards

Sun Jan 27, 2019 6:26 pm

Very bad news......
It's not working properly.
If i give it a direct command in the sudo window it switches relays on and off. I used the i2cdetect and it returns 20..
If i use the Python program window it does not work. Loaded SMBus but nothing. Will do a diagram of the wiring and post it here ASAP

User avatar
mahjongg
Forum Moderator
Forum Moderator
Posts: 13297
Joined: Sun Mar 11, 2012 12:19 am
Location: South Holland, The Netherlands

Re: Relay boards

Sun Jan 27, 2019 7:34 pm

Read the link I gave in the post before, ( https://www.raspberrypi.org/forums/view ... 8#p1225448) it explains why this happens (the relay board is designed to operate with 5V controls, not with 3V3 controls).
It also explains why doing this might damage your PI, you need to add an extra transistor (2N7000, or BC547 + 1K base resistor) to solve the problem

User avatar
tlfong01
Posts: 1312
Joined: Sat Jun 02, 2018 1:43 pm
Location: Hong Kong

Re: Relay boards

Mon Jan 28, 2019 2:23 pm

Franita wrote:
Sun Jan 27, 2019 6:26 pm
Very bad news......
It's not working properly.
If i give it a direct command in the sudo window it switches relays on and off. I used the i2cdetect and it returns 20..
If i use the Python program window it does not work. Loaded SMBus but nothing. Will do a diagram of the wiring and post it here ASAP

How to use a mcp23017 - Rpi Spy

Are you following Rpi Spy?

https://www.raspberrypi-spy.co.uk/2013/ ... pi-part-1/

https://www.raspberrypi-spy.co.uk/2013/ ... pi-part-2/

https://www.raspberrypi-spy.co.uk/2013/ ... pi-part-3/

Or Lady Ada on CircuitPython?

CircuitPython MCP23017 - AdaFruit
https://learn.adafruit.com/using-mcp230 ... /overview

Python Computer Wiring
Since there's dozens of Linux computers/boards you can use we will show wiring for Raspberry Pi. ...


CircuitPython Installation of MCP230xx Library
You'll need to install the Adafruit CircuitPython MCP230xx library on your CircuitPython
board. ...


Below is a complete example that will blink pin 0 and read the state of pin 1 with a pull-up resistor enabled. Add a button and an LED to your setup, like in the diagram below. Save the program as code.py on your board, then open the serial REPL to see the output. ...
I am an electronics and smart home hobbyist.

Franita
Posts: 11
Joined: Wed Dec 26, 2018 11:24 am

Re: Relay boards

Tue Jan 29, 2019 8:28 pm

Hi tlfong01,
Thanks for your reply, yes I have read just about everything on the Pi & MCP23017 including the links you have given me they are in fact in my Favourites folder....WHAT I HAVEN'T DONE is install the ada fruit stuff which i totally missed so a BIG THANK YOU for that.
I will go and install the ada fruit asap.
I have installed "Wiringpi" and "Wiringpi2" but unfortunately I can't get them to work, But having read all the Internet lots of people are having the same problem it "Wiringpi"

I thank you for the reply and ALL the info you have given me

Regards Frank

Brandon92
Posts: 915
Joined: Wed Jul 25, 2018 9:29 pm
Location: The Netherlands

Re: Relay boards

Wed Jan 30, 2019 2:13 pm

Franita wrote:
Tue Jan 29, 2019 8:28 pm
I have installed "Wiringpi" and "Wiringpi2" but unfortunately I can't get them to work, But having read all the Internet lots of people are having the same problem it "Wiringpi"
Can you give the error that you are getting? And what is currently the issue is? And can you post a diagram, picture of you setup. Maybe we see something that is wrong.

Return to “Beginners”