7ewis
Posts: 130
Joined: Wed Dec 26, 2012 11:30 am

How do I connect something to the GPIO pins?

Thu Jan 23, 2014 10:52 am

I've had a Pi for over a year now, and have never even touched the GPIO pins, and have run out of things to do using only the software side.

But, I honestly don't have a clue about electronics, and it seems to be one thing that is seriously lacking in the Raspberry Pi community. I have done some research, but have never come across a guide that explains how to physically connect wires etc. and why I need to do it.

My project is to connect an RF Transmitter to the Pi using the GPIO pins, and then setup a webserver allowing me to remotely send commands to the transmitter which in turn controls RF Plugs.

I already have a Lighttpd web server setup, and need to order the extra hardware asap. (Initially I was going to buy an expensive RF USB Transmitter, but it's out of stock).

So, can someone please ELI5... what do I need to buy? How do I connect it?

This is what I have:
Nexa Remote Switch Pack (and obviously the Pi etc.)

This is what I think I need:
Quasar 433Mhz RF Transmitter Module
and, I believe some Jumper Cables, and possibly some cable to act as an aerial?

So, if I buy the RF Module, can I connect that directly to the GPIO pins (plug it in) or do I need 'jumper cables' to plug in and then connect them to the Pi? Do I need a specific type of cable? How does it connect to the Pi, and the Module (Do I need to solder, or what?).

Do I need a 'breakout board' or anything else? Is the RF Module compatible with the Nexa Plugs?

Sorry for all the questions, I want to buy everything I need and get this worked out as soon as I can!
Thanks
Raspberry Pi - Model B (512MB)

User avatar
joan
Posts: 14841
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: How do I connect something to the GPIO pins?

Thu Jan 23, 2014 11:03 am

I suggest one of the top two of these starter kits.

http://www.smart-elex.co.uk/RaspberryPi ... CCESSORIES

That 433 device is SMT which means it is tiny and impossible to solder unless you are pretty competent.

You can get rx/tx pairs in breakout board format on eBay for a few pounds.

7ewis
Posts: 130
Joined: Wed Dec 26, 2012 11:30 am

Re: How do I connect something to the GPIO pins?

Thu Jan 23, 2014 11:11 am

joan wrote:I suggest one of the top two of these starter kits.

http://www.smart-elex.co.uk/RaspberryPi ... CCESSORIES

That 433 device is SMT which means it is tiny and impossible to solder unless you are pretty competent.

You can get rx/tx pairs in breakout board format on eBay for a few pounds.
Thanks for the suggestion, but what do I need specifically? Do I need a breakout board or ribbon cable etc? Or just some wires and the RF Module.

What is SMT, and how do I connect it to the Pi then if I don't have to solder it?

What are rx/tx pairs? I don't want to buy anything unnecessary as this Pi is solely for controlling the RF Sockets, once I've learnt how to use the GPIO pins I may buy additional equipment in the future to use on another Pi.
Raspberry Pi - Model B (512MB)

User avatar
joan
Posts: 14841
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: How do I connect something to the GPIO pins?

Thu Jan 23, 2014 11:16 am

I've not done what you want to do so can't help with the specifics of what you want.

I'm fairly sure others have and have posted in these forums so it looks like a bit of googling will be needed.

User avatar
Hove
Posts: 1205
Joined: Sun Oct 21, 2012 6:55 pm
Location: Cotswolds, UK
Contact: Website

Re: How do I connect something to the GPIO pins?

Thu Jan 23, 2014 11:28 am

Google this:

Code: Select all

remote power switch site:raspberrypi.org
- loads of hits on the forums. I tried the same for Nexar and got zero hits, so you definitely need to look in detail about how others have done it.
www.pistuffing.co.uk - Raspberry Pi and other stuffing!

7ewis
Posts: 130
Joined: Wed Dec 26, 2012 11:30 am

Re: How do I connect something to the GPIO pins?

Thu Jan 23, 2014 11:49 am

Hove wrote:Google this:

Code: Select all

remote power switch site:raspberrypi.org
- loads of hits on the forums. I tried the same for Nexar and got zero hits, so you definitely need to look in detail about how others have done it.
I looked through the search page, and there still isn't anyone specifically explaining how to do it, some people just tell you what pins to connect to, some assume you already have the Module setup, and some just look like a bodge...

If I buy a jumper cable, can that plug in directly to the pins on the Pi? Then on the RF side, can I just wrap it around a hole in the transmitter? And attach a piece of wire to act as a reciever?

I don't want to take apart cables, or mess around with expanding the amount of pins etc. it would be so much easier if the transmitter could plug directly into the pins, like a flash drive goes into a USB port!

is an aerial even necessary? I doubt the Pi will be over 10m away from the socket anyway.
Raspberry Pi - Model B (512MB)

User avatar
Hove
Posts: 1205
Joined: Sun Oct 21, 2012 6:55 pm
Location: Cotswolds, UK
Contact: Website

Re: How do I connect something to the GPIO pins?

Thu Jan 23, 2014 12:11 pm

I suggest you read through the MagPi magazine http://www.themagpi.com (free online) - that has projects from the very basic connecting to GPIO pins, through to advanced projects akin to your household power management. You need to know about the basics before you even think about the details of the advanced project like remote household power management. Once you understand the GPIO stuff, then the many articles about household power remote control on the forum will make a lot more sense and you'll be able to make progress successfully by yourself and learn a lot of interesting stuff along the way, and perhaps have fun rather than just getting frustrated.
www.pistuffing.co.uk - Raspberry Pi and other stuffing!

boyoh
Posts: 1443
Joined: Fri Nov 23, 2012 3:30 pm
Location: Selby. North Yorkshire .UK

Re: How do I connect something to the GPIO pins?

Thu Jan 23, 2014 2:11 pm

Learning electronics is a must if you want
Use the Pi to It's full potential. But you
Must start from the bottom . Reading
And building circuits on a bread board
Is the only way to learn. Remember
The Pi is useless unless you have
Something to program The project
Must be designed , before you
You write the program to run the project

To connect to Pi GPIO pins you can use
26 pin ribbon cable from the Pi to a
A bread board with a adapter .
It is possible to connect directly to
Pi out put pins ,using jumper leads
You can get them with Male to Male
Male to Female / Female to Female
Ends on them. But I don't recommend
To a beginner

Learning electronics there is no Magic Formula
Other than reading and building
By the way do you live in the Uk If so Maplins for the jumper wires
BoyOh ( Selby, North Yorkshire.UK)
Some Times Right Some Times Wrong

boyoh
Posts: 1443
Joined: Fri Nov 23, 2012 3:30 pm
Location: Selby. North Yorkshire .UK

Re: How do I connect something to the GPIO pins?

Thu Jan 23, 2014 2:20 pm

This might help you under stand how to
Set a GPIO in/put pin to receive a
A input signal, And why 10k resistor
Is kneaded


Why is the resistor needed on GPIO in/put
There is a logic state called Tri-state (3-state) logic

State ( 1 ) called floating neither 1 or 0 .
To use it to receive a Active 1( High )
You must fit a 10k hold down resistor
From the GPIO to 0v- .
To use it to receive a Active 0 ( low )
You must fit a 10k resistor from the
GPIO to 3.3v+


When using a GPIO in/put pin, it must not be left floating
BoyOh ( Selby, North Yorkshire.UK)
Some Times Right Some Times Wrong

7ewis
Posts: 130
Joined: Wed Dec 26, 2012 11:30 am

Re: How do I connect something to the GPIO pins?

Thu Jan 23, 2014 2:44 pm

Hove wrote:I suggest you read through the MagPi magazine http://www.themagpi.com (free online) - that has projects from the very basic connecting to GPIO pins, through to advanced projects akin to your household power management. You need to know about the basics before you even think about the details of the advanced project like remote household power management. Once you understand the GPIO stuff, then the many articles about household power remote control on the forum will make a lot more sense and you'll be able to make progress successfully by yourself and learn a lot of interesting stuff along the way, and perhaps have fun rather than just getting frustrated.
I have read through some of the magazines and *still* can't find someone that can tell me how I connect to these pins!

My project isn't exactly advanced though is it? Surely it's one of the most simple projects you could do with the pins? With a single LED you need a breakout board and a resistor, I literally just have one thing to connect... at least I think!
Raspberry Pi - Model B (512MB)

scotty101
Posts: 3930
Joined: Fri Jun 08, 2012 6:03 pm

Re: How do I connect something to the GPIO pins?

Thu Jan 23, 2014 2:49 pm

Image

http://learn.adafruit.com/adafruit-pi-c ... t/overview

I would suggest something like the Adafruit pi cobbler. It uses a ribbon cable to connect to the raspberry pi and it breaks out the signal on to a breadboard where you can construct any circuits you wish to build.
The tutorials on the Adafruit website are excellent and should give you enough information to start with your basic single LED all the way up to more advanced projects.
Electronic and Computer Engineer
Pi Interests: Home Automation, IOT, Python and Tkinter

7ewis
Posts: 130
Joined: Wed Dec 26, 2012 11:30 am

Re: How do I connect something to the GPIO pins?

Thu Jan 23, 2014 2:57 pm

boyoh wrote:Learning electronics is a must if you want
Use the Pi to It's full potential. But you
Must start from the bottom . Reading
And building circuits on a bread board
Is the only way to learn. Remember
The Pi is useless unless you have
Something to program The project
Must be designed , before you
You write the program to run the project

To connect to Pi GPIO pins you can use
26 pin ribbon cable from the Pi to a
A bread board with a adapter .
It is possible to connect directly to
Pi out put pins ,using jumper leads
You can get them with Male to Male
Male to Female / Female to Female
Ends on them. But I don't recommend
To a beginner

Learning electronics there is no Magic Formula
Other than reading and building
By the way do you live in the Uk If so Maplins for the jumper wires

Thank you for your reply. Why wouldn't
you recommend the jumper leads for
a beginner? Surely it's easier to
connect it directly than have extra
unnecessary equipment? But I guess
I will look at that option too then.
Would I still need jumper leads to
connect the breakout board to the
RF Module, or can they be plugged
in directly to the board? What jumper
leads would I need to connect directly?

I am from the UK, and work next to a
a Maplins so it would be easy to buy
everything from there.
Raspberry Pi - Model B (512MB)

7ewis
Posts: 130
Joined: Wed Dec 26, 2012 11:30 am

Re: How do I connect something to the GPIO pins?

Thu Jan 23, 2014 3:01 pm

boyoh wrote:This might help you under stand how to
Set a GPIO in/put pin to receive a
A input signal, And why 10k resistor
Is kneaded


Why is the resistor needed on GPIO in/put
There is a logic state called Tri-state (3-state) logic

State ( 1 ) called floating neither 1 or 0 .
To use it to receive a Active 1( High )
You must fit a 10k hold down resistor
From the GPIO to 0v- .
To use it to receive a Active 0 ( low )
You must fit a 10k resistor from the
GPIO to 3.3v+


When using a GPIO in/put pin, it must not be left floating
Ah okay, I think I understand. But if
I connect the RF Module directly
I don't need a resistor? Why is that?

If I decided to use the breakout
board, I would need a ribbon cable
the board, and a resistor? Is that it?
Raspberry Pi - Model B (512MB)

7ewis
Posts: 130
Joined: Wed Dec 26, 2012 11:30 am

Re: How do I connect something to the GPIO pins?

Thu Jan 23, 2014 3:05 pm

scotty101 wrote:Image

http://learn.adafruit.com/adafruit-pi-c ... t/overview

I would suggest something like the Adafruit pi cobbler. It uses a ribbon cable to connect to the raspberry pi and it breaks out the signal on to a breadboard where you can construct any circuits you wish to build.
The tutorials on the Adafruit website are excellent and should give you enough information to start with your basic single LED all the way up to more advanced projects.
The Adafruit site does look quite useful, but ideally I don't want to have to solder anything. I don't have much experience doing it, and don't have any soldering equipment in the area I intend work on the project. Can I buy a board that doesn't need soldering and comes premade so I can just plug it in?
Raspberry Pi - Model B (512MB)

Si.
Posts: 24
Joined: Mon Apr 30, 2012 2:53 pm
Contact: Website

Re: How do I connect something to the GPIO pins?

Thu Jan 23, 2014 3:09 pm

Hi, I have some material about using the serial port in my "Raspberry Pi Cookbook". I also blogged a bit about using it to connect to an Arduino, here: http://www.doctormonk.com/2012/04/raspb ... duino.html Although this uses the USB port, the principal is the same (as is the Python).

The electronic connections are pretty straight forward, assuming the transceiver is 3V, then Rx to Tx and vice versa and anything coming out of the serial port will also be transmitted. To control RF switches, you probably only need to transmit. If this is the case, then you can connect the TXD of the Pi even to a 5V RF transmitter's Rx pin without the need for level conversion.

The problem is knowing the protocol that the RF remote uses to control the RF switches. If you can find a datasheet and see what it is expecting then great. Its quite likely to be proprietary and so that may not be possible. If this is the case, then one option is to use the receiver to sample what happens when you press a button on the existing RF remote and record the signal for later playback, but you will either be guessing at baud rates, or bypass the serial port entirely and just write code to sample the receiver RF command on a digital input, save it in to an array for later playback (quite advanced).

A real low tech approach is to 'hack' the existing remote hardware and wire relay contacts across the button. Not elegant, but it works! Then all you have to do is activate the relay from a GPIO pin. Controlling a relay from GPIO is something that I cover in the Raspberry Pi Cookbook (recipe 9.5).

Also, just to chime in on the general breadboard and bits thread within a thread, I designed this kit which also contains a raspberry leaf to pop over your GPIO pins and make life much easier:

http://www.monkmakes.com/#!/~/product/c ... d=32645469
Image

Hope some of this helps.

Si.

boyoh
Posts: 1443
Joined: Fri Nov 23, 2012 3:30 pm
Location: Selby. North Yorkshire .UK

Re: How do I connect something to the GPIO pins?

Thu Jan 23, 2014 3:48 pm

I think you misunderstand me about using the
Jumper wires on the Pi header pins
I will put it another way , Take care when using
The jumper wires on the header pins

1. You could easily get the wrong pin

2, . You could easily bend the pins

3. You work next door to Maplins.

4, Problem solved Pop in to Maplins

5 Tell them what you want & what you want to do

6, While you are in there, Get a book on learning
About electronics and OHMS LAW,
A few resistors/ diodes/ led's /
You might find a starter electronics learning
Kit

After you have built a few projects and seen
Them working, You will kick your self and say
What is all the fuss about electronics.
BoyOh ( Selby, North Yorkshire.UK)
Some Times Right Some Times Wrong

boyoh
Posts: 1443
Joined: Fri Nov 23, 2012 3:30 pm
Location: Selby. North Yorkshire .UK

Re: How do I connect something to the GPIO pins?

Thu Jan 23, 2014 4:48 pm

This is a photo of my lay out
I designed the Interface board
To work between the Pi and the
Bread board, All 26 pins are
Fitted on the interface board
An are numbered, Also I fitted
4 opto Isolators to separate
The different signal voltages
Opto Isolators give total Isolation
Between differ signal levels
The board is Vero board / strip board
All pins soldered
Could be a project for you later on
Attachments
Pi Board 006.jpg
Pi Board 006.jpg (36.72 KiB) Viewed 9923 times
BoyOh ( Selby, North Yorkshire.UK)
Some Times Right Some Times Wrong

toxibunny
Posts: 1382
Joined: Thu Aug 18, 2011 9:21 pm

Re: How do I connect something to the GPIO pins?

Thu Jan 23, 2014 5:44 pm

1. Get a pi cobbler, breadboard, 10 LEDs and resistors, and a couple of breadboard-friendly push buttons. Get them from the shop and ask them to show you how you'd use them.

2. Do a small thing on the breadboard involving flashing leds, buttons, and pull-up and pull-down resistors. Write your own code for it. Make sure you succeed at this first before moving on.

3. At this point you'll grok how to use GPIO. For your wireless automation project, you should use the ready-made modules you can get cheaply on ebay. For a finished project of any sort, you will need a soldering iron and stripboard/perfboard/prototyping PCB...


Keep it *very* simple to start off with - one LED lit safely is a good start. Electronics is an absolute morass and it's easy to spend weeks and weeks and weeks reading theory without getting anything done because it's just too complex.

Good luck!
note: I may or may not know what I'm talking about...

boyoh
Posts: 1443
Joined: Fri Nov 23, 2012 3:30 pm
Location: Selby. North Yorkshire .UK

Re: How do I connect something to the GPIO pins?

Thu Jan 23, 2014 8:56 pm

I think you are waiting for a Magic answer to your project
I'm sorry there is no answered ,that you seem to understand.
Forget complicated projects that you don't understand yourself
You seem to want to launch a Rocket with out a launching pad
You said you have had the Pi for 2 years , that is a long time
My advice is build a few simple circuits on a breadboard
Using a few resistors / led's / Transistors
Get that projects book of simple circuit from Maplins
And get building

Regards BoyOh Selby UK
BoyOh ( Selby, North Yorkshire.UK)
Some Times Right Some Times Wrong

toxibunny
Posts: 1382
Joined: Thu Aug 18, 2011 9:21 pm

Re: How do I connect something to the GPIO pins?

Fri Jan 24, 2014 1:47 am

OHere's an interesting link, OP : http://www.skagmo.com/page.php?p=projects/22_pihat


Pros: no soldering or any additional components *needed* to make it work.

Cons: possibly illegal. ;P


Have you watched any YouTube tutorials on connecting stuff to the gpio, OP?
note: I may or may not know what I'm talking about...

7ewis
Posts: 130
Joined: Wed Dec 26, 2012 11:30 am

Re: How do I connect something to the GPIO pins?

Fri Jan 24, 2014 11:21 am

toxibunny wrote:OHere's an interesting link, OP : http://www.skagmo.com/page.php?p=projects/22_pihat


Pros: no soldering or any additional components *needed* to make it work.

Cons: possibly illegal. ;P


Have you watched any YouTube tutorials on connecting stuff to the gpio, OP?
I have seen that before, as my Nexa plugs should be coming today, I think I'll give it a go! Think it may need a wire to act as an aerial though, but if it works on a short range without it then that would be great!

I have seen videos of people using the pins, but never actually making something and connecting to the pins on video. Guess I'll have a look for it now!
Raspberry Pi - Model B (512MB)

7ewis
Posts: 130
Joined: Wed Dec 26, 2012 11:30 am

Re: How do I connect something to the GPIO pins?

Fri Jan 24, 2014 11:26 am

boyoh wrote:I think you are waiting for a Magic answer to your project
I'm sorry there is no answered ,that you seem to understand.
Forget complicated projects that you don't understand yourself
You seem to want to launch a Rocket with out a launching pad
You said you have had the Pi for 2 years , that is a long time
My advice is build a few simple circuits on a breadboard
Using a few resistors / led's / Transistors
Get that projects book of simple circuit from Maplins
And get building

Regards BoyOh Selby UK
There could be a magic answer though! If someone replied and said 'All you need to do is connect a jumper lead into the pins (it literally plugs in), then wrap the other end of the wire around the hole in the transmitter, and it is connected! Then pair it with the Nexa, and your done!' I honestly can't imagine it being too much more difficult than that.

I'm more of a software person, I know how to build a PC, but that just like Lego... it's very easy! I can wire a plug, but then again that's quite easy too. I find this diffcult because there aren't any specific guides that are standard, every tells me different ways of doing things.
Raspberry Pi - Model B (512MB)

7ewis
Posts: 130
Joined: Wed Dec 26, 2012 11:30 am

Re: How do I connect something to the GPIO pins?

Fri Jan 24, 2014 11:44 am

toxibunny wrote:1. Get a pi cobbler, breadboard, 10 LEDs and resistors, and a couple of breadboard-friendly push buttons. Get them from the shop and ask them to show you how you'd use them.

2. Do a small thing on the breadboard involving flashing leds, buttons, and pull-up and pull-down resistors. Write your own code for it. Make sure you succeed at this first before moving on.

3. At this point you'll grok how to use GPIO. For your wireless automation project, you should use the ready-made modules you can get cheaply on ebay. For a finished project of any sort, you will need a soldering iron and stripboard/perfboard/prototyping PCB...


Keep it *very* simple to start off with - one LED lit safely is a good start. Electronics is an absolute morass and it's easy to spend weeks and weeks and weeks reading theory without getting anything done because it's just too complex.

Good luck!
Thank you, the thing is though I don't really have time to experiment and learn the basics of electronics etc. as this isn't actually for me, and I need to get it done as soon as possible.

I just don't understand what the breakout board is for, and why I would need it. And then I don't know what cables I need or how to connect them, if I knew how to connect everything together I think I'd be okay, but there seems to be some many different add ons for the Pi, some come premade, some need soldering, some need cables being taken apart...

Initially I wanted to use a USB Transmitter, as it's so much easier, you just plug it in and it's done! I don't know why the pins have to be so complicated... Why can't I just attach some wire to the Pi, attach the other end to the RF Transmitter and it would work, with no soldering or special boards.
Raspberry Pi - Model B (512MB)

7ewis
Posts: 130
Joined: Wed Dec 26, 2012 11:30 am

Re: How do I connect something to the GPIO pins?

Fri Jan 24, 2014 11:51 am

boyoh wrote:This is a photo of my lay out
I designed the Interface board
To work between the Pi and the
Bread board, All 26 pins are
Fitted on the interface board
An are numbered, Also I fitted
4 opto Isolators to separate
The different signal voltages
Opto Isolators give total Isolation
Between differ signal levels
The board is Vero board / strip board
All pins soldered
Could be a project for you later on
Why do you have so many connections though?

Why can't you just use the direct connection to the Pi? Do the boards just give you more pins effectively? So I can use the pins directly, and only need an extra board if I wanted to connect more things (Which I don't).
Raspberry Pi - Model B (512MB)

7ewis
Posts: 130
Joined: Wed Dec 26, 2012 11:30 am

Re: How do I connect something to the GPIO pins?

Fri Jan 24, 2014 12:01 pm

Si. wrote:Hi, I have some material about using the serial port in my "Raspberry Pi Cookbook". I also blogged a bit about using it to connect to an Arduino, here: http://www.doctormonk.com/2012/04/raspb ... duino.html Although this uses the USB port, the principal is the same (as is the Python).

The electronic connections are pretty straight forward, assuming the transceiver is 3V, then Rx to Tx and vice versa and anything coming out of the serial port will also be transmitted. To control RF switches, you probably only need to transmit. If this is the case, then you can connect the TXD of the Pi even to a 5V RF transmitter's Rx pin without the need for level conversion.

The problem is knowing the protocol that the RF remote uses to control the RF switches. If you can find a datasheet and see what it is expecting then great. Its quite likely to be proprietary and so that may not be possible. If this is the case, then one option is to use the receiver to sample what happens when you press a button on the existing RF remote and record the signal for later playback, but you will either be guessing at baud rates, or bypass the serial port entirely and just write code to sample the receiver RF command on a digital input, save it in to an array for later playback (quite advanced).

A real low tech approach is to 'hack' the existing remote hardware and wire relay contacts across the button. Not elegant, but it works! Then all you have to do is activate the relay from a GPIO pin. Controlling a relay from GPIO is something that I cover in the Raspberry Pi Cookbook (recipe 9.5).

Also, just to chime in on the general breadboard and bits thread within a thread, I designed this kit which also contains a raspberry leaf to pop over your GPIO pins and make life much easier:

http://www.monkmakes.com/#!/~/product/c ... d=32645469
Image

Hope some of this helps.

Si.
Thank you.

I do only need to transmit, so what do you mean when you say this: "connect the TXD of the Pi even to a 5V RF transmitter's Rx pin without the need for level conversion." Does that mean I can connect the transmitter directly to a pin, one for power, one for data?

How would I find the protocol, what does it depend on? I know that the Nexa plugs are very popular, and I haven't yet purchased a transmitter, so I can buy a certain one if it is needed. There are some guides on pairing Nexa plugs, so I don't think it should be too difficult.

I'll have a read, thanks.

Regarding the breadboard. Do I *need* one, and will it benefit me at all? I don't need the pins for anything else apart from this project.
Raspberry Pi - Model B (512MB)

Return to “General discussion”