jammin36
Posts: 3
Joined: Thu Aug 10, 2017 4:01 pm

GPIO State Change

Thu Aug 10, 2017 4:21 pm

Good Afternoon,

Im trying to create a volt free switch utilising the GPIO pins on the PI3 and i wondered.......

1. is it possible to have a volt free relay function ?
2. How would i change the state of the pin / relay
3. Could a program be designed to then manage that switch remotely ?

Thanks in advance

User avatar
karrika
Posts: 1125
Joined: Mon Oct 19, 2015 6:21 am
Location: Finland

Re: GPIO State Change

Thu Aug 10, 2017 5:47 pm

Wow.

Your terminology leaves a lot up for guessing.

Perhaps you are looking for an isolated relay that can be controlled by the GPIO pin.

The relay contacts should be isolated from the Pi so that you can control something else with it.

If this is the question the answer is yes.

As there is a lot of suitable boards out there you can search for Raspberry Pi Relay HAT.

jammin36
Posts: 3
Joined: Thu Aug 10, 2017 4:01 pm

Re: GPIO State Change

Thu Aug 10, 2017 6:32 pm

Apologies for the lack of correct terminology but I'm new to the Pi and I'm still very much learning.

Yes in short I want a volt free contact that changes state on command and would be grateful to know how to do that locally via the Pi itself and remotely using an app or browser where possible.

There appear to be many Hats available so would it be possible to narrow it down to the one that would solve my request?

Thanks

User avatar
karrika
Posts: 1125
Joined: Mon Oct 19, 2015 6:21 am
Location: Finland

Re: GPIO State Change

Thu Aug 10, 2017 6:57 pm

Most relay HATs seem to be out of stock.

Amazon had one like this https://www.amazon.com/Raspberry-Pi-cha ... B06Y4KZXYC

It has 4 relays at GPIO6, 13, 19 and 26.

You should be able to control a relay in Python.

Code: Select all

import RPi.GPIO as GPIO
import time

relaypin = 6
GPIO.setmode(GPIO.BCM)
GPIO.setup(relaypin, GPIO.OUT)
GPIO.output(relaypin, GPIO.HIGH)
time.sleep(10.0)
GPIO.output(relaypin, GPIO.LOW)
For web based control you can extend this with a Python flask server. The flask server could create a web page with a button. The state of the button could control the state of the relay.

If you want to create an app on a mobile phone you could learn to use the Python liblo library for listening to OSC commands.

Both of these remote approaches require quite a lot of learning to get the devices to work as you want. But it is doable. And fun.

Return to “General discussion”