Header Pin Connections for Raspberry Pi, Arduino, ESP32, STM32 Micropocessors
So those might be inputs like this ultrasonic sensor or rfid tag reader, or they might be outputs like this led display or servo motor and theres a range of different connector types. But in this video id like to describe the most common type, youll encounter and thats. This row of header pins at the top of the board here so first of all, id just like to say a little bit more about how this connector works and the different varieties you might encounter and then im going to show a little bit of a practical Demonstration as to how you can actually solder these connectors onto a board, so these connections are formed by joining a male connector and a female connector together. The male connector has a pin and the female connector has black plastic housing, but you can get male and female connectors both on wires and on pcb boards. So here you can see. Ive got a wire that has three male connectors at one end and three female. At the other and on the arduino uno here, ive got some female headers around the edges, but ive also got a 3×2 male pin on the icsp header and a former connection. All you do is simply take the opposite type of connector and push it in. So if i take my male connectors on my wire, i can push them into the female headers on the board. I can take my female connectors on the wire and push them into the male headers on the board.
Just like that. Now these connectors have whats called a pitch of 0.1 inches, so what that means is that the spacing between consecutive pins is 0.1 inches or 2.54 millimeters. Now that is also the same uh distance as the pins on a standard breadboard like this. So its a very standard uh spacing that is used in electronic connectors as well. You might find that some boards, like this arduino mega, have a double row connector block here and in that case its 0.1 inches in both the across and also the depth dimensions. Now, as well as joining a wire to a board, these connectors can also be used to join wire to wire like this. So just as before, you simply need opposite types of terminals, and then you push them together now theres no kind of interlock mechanism here. So this is only being held together by friction and, in this case, actually thats not a bad connection, but what you might find you want to do is apply a bit of tape around the join there just to make that slightly more secure. Now, if you ever find yourself in the situation where you need to join two female wires together, what you can use is a little double ended, male to male connector like this, and you can kind of use this as a sort of an adapter between them. So you can push one end onto one of the female wires and push the other end onto the other female wire, and there you go ive been able to join two female connectors together by using a little male adapter between them, and they can also be used To join two boards together directly, you may be familiar with the idea of a shield, which is an add on board that has a matching set of pins, that slot onto the board below it.
So here ive got an audio shield for an arduino uno and if i just show you on the reverse, ive got a set of male pins, which should line up perfectly with the female headers on the top of the arduino. And then i can just push them together, and that gives you a very solid, robust, electrical and mechanical connection between those two boards. Now some boards come with the header, pins already soldered onto them and if thats the case, the only thing you have to worry about is getting a cable of the appropriate opposite type to match them. So if your board has female headers like this mega youll need a cable with mail ends. If your board has male pins like this arduino, nano youll need a cable with female ends. Also note this nano has male connectors that are 90 degree, connectors and thats. Actually quite useful as well, because it lets you slot in wires into them from the side. Now, this arduino uno actually has both types of connectors for each clpio pin, which is pretty handy as well. So you can either buy cables with the appropriate ends already attached to them, or you can crimp your own cables. Ive actually already made another video about how to crimp your own cables and its something that id recommend. You learn how to do its cheaper to just buy a very long spool of flexible wire, cut it to the right size and then add the appropriate connectors onto each end than buying ready made cables, which tend to be quite poorly made and pretty expensive and theyre.
Often quite short as well now, sometimes you might have a module that does not come with pre soldered headers, so that means youll have to solder them on yourself like on this raspberry pi pk. Now, in this case, you can choose whether you want to have male pins on the board and female headers on the wire or whether you want to have female headers on the board and plug a male wire into it. So if you go for the option of having male pins on the board, you get a strip of connectors like this, and what i do is to push them into the slot. And then you can simply snap that off there to the appropriate length so that you have the right number of pins and then you solder them in place from the reverse side that the pins are sticking out from. So here ive got the pins, pointing forwards off the board, so you would solder the reverse side, but if you wanted to, you could have the pins coming out the bottom of the board and then you sold onto the top side. Instead, you just need to make sure that you have the pins lined up straight and hold them in place, while you solder one useful way to do that, actually is to use a breadboard, and if you stand the pins up in the breadboard, and then you push Your module that youre soldering onto the top of them that just holds it in place nicely while you, while you solder them into place now.
Alternatively, you might choose to put female headers onto the board instead and use a male wire. Now, if you do that um, what i normally do is to buy a selection box of female headers of different lengths, because, unlike the male strip of pins here, you cant easily snap female headers in the housing. Now. The problem i often find here is that i often dont have the exact length header, so you can see here this ones a bit too short. I think most of these are going to be too short, yeah thats a bit too short as well. What you can do, however, is you: can take a female header strip that is too long and a bit like with the male. So to line up how many you actually need and then take a sharp stanley knife. Oh thats got some stuff stuck to it and just cut uh cut the header away. There youll end up with a slightly rough edge here um, but it wont actually affect the electrical properties of it at all and then just as with the male headers, you solder onto the reverse side, from the side that youve chosen to put the headers into. So you can have the female headers on the bottom or on the top, and then you just sold onto the reverse side of the pins there. Now my preference is generally to solder male pins onto boards and use female connectors on wires.
The reason for this is because i find that if you have male connectors on wires, they very easily get bent and can even snap off inside the female housing. If i just show you that here, if i plug these male connectors in here and apply any kind of sideways uh force on those wires there, those pins will come out bent. Whereas if you have the male connectors on the board and use the female wires um. Because these have been soldered so close to the independence that that acts as a kind of additional rigidity and robustness in those male clothes. They they dont, bend anything like as easily, and i just find that that generates a more secure, joint um that way around. So thats my preference just one other type of connector i wanted to mention. So this is a wemos, d1 mini board. So just like with the raspberry pi pico, it comes unsoldered, but it actually comes with a selection of different pins that you might want to use. So we have male pins, which you can insert either onto the underside or on the top. It also comes with some female headers, which again you could put them on this side or on this side, but it also comes with these interesting ones, so these are double height, headers that have a female top and also male pins. On the other side and the way you use these is to push them through male end.
First, like that, and if i put the other side in as well so weve got two rows of uh equal length pins here and you can see if i just line those up. What that generates is its got male pins coming out the bottom and female pins at the top. Now much like with the arduino, i showed you earlier that gave you the choice of using either the male or the female connector for each gpio. Pin it does that, but it also lets you stack shields on top of the wemos to kind of any height you want really because every time you stack a new shield on top of the female headers here, its male pins go in, but it exposes a new Set of female headers on the top, so the way you attach these is uh. You actually solder on the male side, here, theyre a little bit trickier to solder, because you just want to put a dab just at the base of each of the male pins there. These pins are actually slightly longer than a typical male pin to allow for the fact that youll have a slight blob of solder at the top there, but theyre still good to get a solid connection into the female head of blood. So thats just another type of connector. I wanted to show you so now. Let me demonstrate how youd solder pins to a board like this and ill use. The raspberry pico that i demonstrated earlier so ive got a strip of mail pins im, just going to put them in one side of the board and then snap them off at the appropriate length.
And then, hopefully, if ive worked this out correctly, i should just have enough pins left over to also line up on the other side of the board as well. Yeah, perfect. Okay, now i could solder these pins on this side. You can see that theres labels for what all of the pins are for um, but i think actually it would be better to put the pins sticking out of this side of the board instead. And the reason for that is youll notice that there is a button on this side of the board, which is the boot button im going to need to be able to access that um. I dont want the pins or the cables to get in the way and then what ill do is ill. Just uh push those pins down into a breadboard like this. You dont need to push them all the way, just enough to secure them in place and then, if you look at it from the end youre able to check that youve got a nice uh right angle of those pins, yeah theyre not being splayed outwards or inwards. At all, then, i get my soldering iron, a very standard, soldering iron, nothing special about this im using a chisel tip on the end and im just going to touch a little bit of solder onto the end and then im going to start soldering the pins to The board so im going to start in one corner just here next to the usb connector, just going to touch my soldering iron onto the pad and onto the pin and then just put a little bit of solder on the end and then work my way along.
The line to the next one and lets get a little drop on that one. There we go, and now i wouldnt necessarily say im the best soldier in the world, but um you know: im okay, ive been doing it for a while its one of those things that you really only get uh better at with practice to be honest, um. So to kind of show you my technique, i just attach a few of the pins at each end, just to make sure ive got that nice and lined up um check that that is still straight. Yep looks good and then to show you a little bit more detail. Let me change the camera angle, okay. So what im doing is im touching my the tip of my soldering iron onto both the pin and the pad at the same time, and then just letting a little bit of solder run between them, and it should only take a few seconds on each pin. You dont want to hold the iron there for too long, because you might risk heating up the electronics um. What some people do wrong? Is they sort of touch the solder directly onto the soldering iron and kind of let it melt and run down? But you should try not to do that. What youre trying to do is use the iron to heat up the pin and the pad together and then once youve done, that for a second or two just touch the solder against them, and it should kind of run down and make a nice secure, shiny connection Between them, just to show you that again um, let me do it on the wemos d1 mini so now, im using that double height header thats got the the female connector at the bottom, which im just resting it on vertically its got.
The male header sticking out the top now this is a little bit more fiddly, because youve got those long metal pins coming out the top. But again, all im doing is im taking the tip of the iron im warming up both the pin itself and also the little metal uh plate on the board heating them next to each other, and then touching the solder on them and just letting it um kind Of drip down into the hole just to get a nice secure connection between them, and it could only take like i say, only a few seconds on each one really dont. If its not working dont hold your soldering iron there for too long um, you know take it off and try again, and hopefully i can show you now.