Advanced search FAQ Register Login

It is currently Sat Jan 20, 2018 10:05 pm

 

Postby darrenmorton93 » Tue Jul 11, 2017 3:41 pm

Hi Guys,

I know these things are out there and can be bought but i fancy giving it a go. I have various emergency lights in my car as I provide Traffic Management Services. All lights run off a 12v supply and are currently connected to a 5 way adapter with a push button.

I was planning on using my Raspberry Pi 3 Model B with a 12v 8 channel relay (https://www.modmypi.com/electronics/rel ... lay-module) then building a simple GUI with 8 control softkeys. I know how to connect the lights to the relay and how to power the relay. What I am unsure about is how I connect the relay to the raspberry pi and how I program it so that when I press softkey 1 it activates relay 1 and so on.

Is anyone able to point me in the right direction or assist?

Thanks

Darren

darrenmorton93
n00b

Posts: 3

Joined: Tue Jul 11, 2017 3:23 pm

Postby BMS Doug » Wed Jul 12, 2017 9:14 am

Image

Remove the Jumper (Green in the picture).
Connect 12V+ to VCC.
Connect the Gnd of the 12V supply to GND

Connect Pin 1 to the GPIO you wish to use to activate relay 1
Connect Pin 2 to the GPIO you wish to use to activate relay 2
Connect Pin 3 to the GPIO you wish to use to activate relay 3
Connect Pin 4 to the GPIO you wish to use to activate relay 4
Connect Pin 5 to the GPIO you wish to use to activate relay 5
Connect Pin 6 to the GPIO you wish to use to activate relay 6
Connect Pin 7 to the GPIO you wish to use to activate relay 7
Connect Pin 8 to the GPIO you wish to use to activate relay 8
Connect COM Pin to the Pi GND GPIO pin.

BMS Doug
31337

Posts: 273

Joined: Tue Sep 08, 2015 3:55 pm

Location: London

Doug.

Volunteer Moderator.

Postby BMS Doug » Wed Jul 12, 2017 9:23 am

darrenmorton93 wrote:I was planning on using my Raspberry Pi 3 Model B with a 12v 8 channel relay (https://www.modmypi.com/electronics/rel ... lay-module) then building a simple GUI with 8 control softkeys. I know how to connect the lights to the relay and how to power the relay. What I am unsure about is how I connect the relay to the raspberry pi and how I program it so that when I press softkey 1 it activates relay 1 and so on.

Is anyone able to point me in the right direction or assist?

Thanks

Darren


GUI With softkeys:
Will you be using a touchscreen display or an app on your phone (or Both)?

I have controlled stuff in the past by running a lightweight webpage on the Pi and connected my Pi and phone via WIFI to control physical outputs.
That was so long ago that the methods have probably changed a lot since but the concept is easy enough.

There are also many apps available for iphone or android for switching relay outputs on a pi.

BMS Doug
31337

Posts: 273

Joined: Tue Sep 08, 2015 3:55 pm

Location: London

Doug.

Volunteer Moderator.

Postby darrenmorton93 » Wed Jul 12, 2017 12:11 pm

Yeah i've got a 7" touch screen that will be connected to the Pi. I'm wanting a simple 8 softkey interface with a feature built in so that when the button is pressed it turns a different colour so I know it's activated. I was looking at trying to produce something through Python or Visual Studio to run?

If possible I was hoping for this to be standalone so not sure how the any of the android apps would work?

darrenmorton93
n00b

Posts: 3

Joined: Tue Jul 11, 2017 3:23 pm

Postby BMS Doug » Wed Jul 12, 2017 1:22 pm

darrenmorton93 wrote:If possible I was hoping for this to be standalone so not sure how the any of the android apps would work?


You could set the Pi up as a WIFI hotspot and connect your phone to that.

darrenmorton93 wrote:Yeah i've got a 7" touch screen that will be connected to the Pi. I'm wanting a simple 8 softkey interface with a feature built in so that when the button is pressed it turns a different colour so I know it's activated. I was looking at trying to produce something through Python or Visual Studio to run?

If possible I was hoping for this to be standalone so not sure how the any of the android apps would work?


Probably the easiest way would be to use scratch: very simple to program, interfaces easily with the GPIO pins.

BMS Doug
31337

Posts: 273

Joined: Tue Sep 08, 2015 3:55 pm

Location: London

Doug.

Volunteer Moderator.

Postby darrenmorton93 » Wed Jul 12, 2017 1:33 pm

Scratch. I'll take a look and see. What kind of coding am I looking at for interfacing with the GPIO pins. I saw some Python code that went along the lines of:

GPIO.Setup(2, GPIO.OUT)
GPIO.Setup(3, GPIO.OUT)

then each button would execute the code as below:

#RELAY ON
GPIO.output(2, GPIO.HIGH)
GPIO.output(3, GPIO.HIGH)

#RELAY OFF
GPIO.output(2, GPIO.LOW)
GPIO.output(3, GPIO.LOW)

Would it be similar to this?

darrenmorton93
n00b

Posts: 3

Joined: Tue Jul 11, 2017 3:23 pm

Postby Dave » Wed Jul 12, 2017 2:14 pm

Scratch is basically a a visual way of coding, but if you wanted to actually do the coding then a couple of common python libraries that get used are:

GPIOZero - https://gpiozero.readthedocs.io/en/stable/
and
Raspberry-GPIO-Python - https://sourceforge.net/p/raspberry-gpi ... /Examples/

Dave
ModMyPi

User avatar

Posts: 2078

Joined: Wed Jul 22, 2015 11:36 am

Forum Administrator & Technical Support

Who is online

Users browsing this forum: No registered users and 1 guest

Board index

The teamDelete all board cookies • All times are UTC [ DST ]