In this chapter of the Zero to Maker workshop, we'll be designing printed circuit boards or PCBs, learning some handy tips on how to make your own designs work the first time and how we can get them manufactured. If you're new to this workshop, Jared and myself will be taking you on a fast-paced and practical journey to learn a wide variety of maker skills so that you have the tools and knowledge to make anything. Follow along as we develop our own projects and share insights into the process.
For those that are new to the series, my project is PlantPulse, an automated way to monitor and maintain a plot of plants. In the last chapter, we used the breadboard and protoboard to assemble our circuit. Now, we'll design the same circuit on a two-layer PCB. We'll be using KiCAD, an open-source PCB design software tool, and the general flow when designing a PCB is as follows.
Draw the schematic. This is where we add all of our components and the connections between them. Assign footprints. Here we go from symbols in our schematic to assigning real dimensions with outlines and the connectors to our PCB. Board layout. This is where we take our footprints and the connections from our schematic and combine these into our final PCB. And once we finish your step, I'll walk you through some of the checks we can take to make sure we haven't made any silly mistakes.
Once you submit your design and get it made, your design is locked in and you can't change it. So, these checks will try and save you some hassle, but be aware PCBs are really cheap, so don't be afraid to fail and learn. Now we know what we're doing, let's get started. We should have a good understanding of what we think we will include in our PCB. Thankfully, I've already gone and drawn out each of the parts in the previous episode. And here's my sketch.
We've got our Soil Moisture Sensor, our ESP32, an atmospheric sensor, and our Power Timer connected to a LiPo. So, let's open KiCAD, create a project, and then we'll open the schematic drawing tool. And let's start out by adding my major components. In the schematic, we create an overview of how all the components connect. We don't care about the size and shape of our components, just a representation of the parts and the connections between them. And let's start by adding all of our major components now.
So, our soil moisture sensor is just three wires that we need to connect. I'll plan to use pin headers to connect the sensor to the board, so we just need to put a three-pin connector on our schematic. That's the connector for the soil moisture sensor. So, let's add that with the add symbol tool. Off the top of my head, I know that simple connectors start with CONN, C-O-N-N, underscore, then the amount of pins we want. If it's a single row, it's 01 by, which we say is X, and then 3, which is 03. And that gives us this nice little range here. I'll click on the pin option.
A soil moisture sensor's three wires consist of a yellow signal wire, a red power or 3.3 volt wire, and a black ground wire. And I'll add some text next to the symbol here to show the actual connections on the sensor. So, one signal, two is voltage or red, and three is ground or black. And instead of just one soil moisture sensor, we'll have four. So, we'll go ahead and copy and paste this three times. I also have an atmospheric sensor, and it has four wires I need to connect. I'll use the same pin header method as before, but this time I'll search CONN, which is C-O-N-N, underscore, 01X04. And this symbol has four connections, and we'll label that with the appropriate text. And those are our first parts. So, let's add our ESP32, the brains of the operation. But where's the symbol for it? KiCAD won't include all of the symbols for your project, and using two rows of pin headers isn't clear, and we can mix up the connections very easily. We do have a couple of options. Find one online and download it, or we can make our own. And making your own is so easy, and I would recommend DIYing it for simple modules like the ESP32 here.
So, let's make our own symbol. First up, we need a place to put it. I'm going to create a library and select projects since this will be just within this one PCB. But if you want to do lots of projects, you can make and maintain your own library so you can reuse symbols. And then the name, I'm just going to call this one ESP32S3. And then we'll add the rest of the pins. If it's a quick project, make it look the same as the module or chip. This is the easiest way. Or, convention is that power pins face up, ground down, inputs on the left, and outputs on the right. We've got all of our pins in, so we'll just quickly organise it and make it look neat. Then we'll add it to our schematic and get on to the rest of our components.
The battery connector uses two pins, and the power timer has six pins, using the same processes as before. And I think I'll squeeze one last feature in there, a voltage divider to measure the battery. A voltage divider is simply two resistors, and I'll add them by searching R, using the adding tool. I'll quickly change the resistance value of those to 10k for 10,000. Great, that's all of our components into the schematic. And we can't forget, you made your project, be proud. Fill out the title block. Now let's connect everything together. This is as simple as dragging the pins together to place a wire, and we'll make all of the connections from our drawn diagram from before.
Now, let's make sure the schematic is laid out well. It should read like text, left to right, top to bottom. Inputs and power on the left, processing in the middle, and outputs on the right. When it comes to PCB design, I'm pretty picky, so I'll take the schematic to the next level, add some niceties, and walk you through why you might want to include them. So this is the net labels. These swap out the long wires for direct connections. But be careful, if you misspell a power net's name, they will not link. KiCad won't help or correct it. And any calculations. I've just jotted down my process for figuring out the values for this voltage divider. And finally, test points. They're a very convenient way to be able to test our PCB after they've been made. I know as a beginner, I didn't put test points on many, so it was really hard to get multimeter probes into the really fine connections on some of the parts I used.
And of course, we have to check our schematic. There's two great ways to do that. The first, we can check our connections with the net selection tool. This highlights all connected wires in pink. It's very useful for checking power nets and net labels. And second, electrical rules check, or ARC. This shows if there are any errors in how we've connected the components. It looks like there's a missing connection on the ESP32. I don't need this pin, so I'll place a no connection symbol on there. So that's our schematic. All of the parts are connected and checked, so let's add the physical shape of them. Footprints. When picking or creating footprints, it's easier if you have the physical part in front of you to orient everything. If you don't, that's okay. Data sheets and other official resources are the best source of truth for details. But note, watch out for different units of measurements. We often see millimetres and inches, but we also see another similar one called mils, a thousandth of an inch.
We can select a bunch of components and assign multiple footprints at a time. Here, I'll select all of the soil moisture sensors, and then I'll head to the connector pin 2.54 and select that for our soil moisture sensors. I'll scroll down. I'll have a look a little bit further down the list and select the four pin variant for our atmospheric sensor. I'll be looking for a nice size resistor footprint here. Note, we could also use surface mount resistors, but personally, I don't keep a stock and through-hole are generally more available. I have a great little baggie of them at home. Now, we don't have a footprint for the power timer. Again, we can either download and install one, or we can make our own custom footprint. And again, it's quite easy.
Let's start by creating a footprint library, and we want to create a through-hole or THT part. We'll quickly change the grid to 2.54 millimetres. That's the pitch of the connector. I've got the reference material open on a second monitor, and I can see the distance between each of the pins is 2.54 millimetres or 0.1 of an inch. Next up, let's add the pads. These are how our component connects to the PCB. Through-hole goes all the way through the board and lets the solid to the other side, and surface mount uses flat metal pads to join onto that same side. I've quickly checked the resources and the pins are in their correct positions. Now, I'll add an outline and the mounting holes so that we can secure it to our PCB. Then, to make sure that we don't put anything above or beneath it unintentionally, I'll add what's called a courtyard. This will throw an error whenever we put components in spaces that it shouldn't be. I'll go through a quick checklist, make sure our pins and mounting holes are in the correct position, our silk screen looks clean and is informative, and I've got a courtyard so that we don't put components where we're not expecting without throwing an error.
Now, let's save and add this to our list of footprints. ESP32 doesn't have a footprint, so I've gone ahead and created one for that. One final check, we'll go through and view all of our components, making sure that they look correct. We've assigned all of our footprints, now we can save and we'll move on to our PCB layout. Now that we have our schematic, which tells us how everything is connected, and our footprints that tells us what everything looks like, we can put it all together and design the final PCB. To start, let's click on the PCB button here. We start with the blank canvas and to import the footprints and connections between parts, we need to click on the update layout button. It combines the connections from the schematic and shape of the parts from the assigned footprints, so we can start laying everything out.
And as I start moving components around, it's worth mentioning a couple of thoughts going through my head. Do we need to fit the electronics into a specific space or is there a certain size that the PCB needs to be? If we have to, we should start by drawing the outline of the board which defines the size of the PCB itself and start putting components inside of it. Or if space is less of a consideration, we can organize the parts in groups, similar to how the schematic is drawn. This gives our design a good flow so the connections between sections won't be as long and as messy, for the most part. I'll use a mixture to make sure the board is small and laid out nicely. We need to remember that we need to assemble this somehow and we'll leave a little bit of extra room between components so that we're guaranteed to get a soldering iron in and save headaches later.
I'll draw a quick outline so that we can view the board in 3D. If we have 3D models uploaded for components, we can see them in here or we can even make the silkscreen represent it, like with the power timer in ESP32. It's always good to check the 3D viewer to make sure something like a USB connector will have space to fit. And PS, you can export a 3D file from our PCB viewer and import it into CAD programs like Onshape to help design enclosures or just see how everything will fit together. Let's start by joining each component together. These connections are called traces, and they're a lot like jumper wires, but we'll be building them into the PCBs. We also get to pick how thick the wire is. A thicker wire can handle more current, so if this was a power-hungry servo, the power trace should be bigger and thicker. We can use the inbuilt trace width calculator to find out how thick our traces need to be. But our signal wires, like this soil sensor's output, don't pass much current, so we can use a thinner trace.
You'll notice a lot of things connect to ground. If we add a ground pore on the back layer, this will turn the entire back layer into one giant ground sheet or wire, making all of these connections for us. These through-hole parts certainly have pads on the back. So let's wrap up by routing all of our connections. We'll go through and make sure we've got all of our soil moisture sensors routed, then our atmospheric sensor, our power timer, and anything else in between. In general, we want to make sure our traces stay on one side of the board. Again, I'm going to quickly clean things up and explain what I've done. All of the changes to the PCB I've gone ahead and made are pretty much just visual. It'll help us use the board a bit easier. And then we need to add our board outline and mounting holes. Make sure to round the corners. Make sure you give yourself credit on the board. It's probably more important than the schematic, and there's three tiers of doing that. We can use the inbuilt text tool to build a quick and cute little bit of text here, or we can use a plugin called KeyBuzzer to generate super clean text. We even get to pick and choose how the shape looks, whether it's filled, or whether it's hollow text. Or we can import our own custom artwork. I've prepared this logo, and we can also import other images, PNGs, and vectors, for example. You can definitely get creative and print whatever you want on the board.
Before generating the manufacturing files, we should check our board. Click on Design Rule Check or DRC to make sure our board is in a manufacturable state. Here we've got a couple of areas where the resistor is on the same layer as our power timer, but that's fine. We'll be using headers to get it a little bit further off the board between the power timer. We'll open the 3D viewer one last time so that we can check our components are in the right spots, and text won't make the board harder to assemble and disgusting. Now let's generate our manufacturing files. For PCBs, these are called Gerbers. And make sure to generate both the layer and drill files, then zip them together. And that's our boards designed. Oh, we still have to order them, so we need to send them off to a PCB fabrication house. There are tons of choices for fab houses you can get your PCBs made out, and the forms are pretty much the same. When ordering, we can select different board thicknesses, colours, even the types of materials they use, lead vs lead-free surface finishes, and even the base material the PCBs are made out of, normal FR4 fiberglass, aluminium, or other specialty materials.
And it's definitely worth a mention, lots of fab houses can assemble your boards for you, provide the part numbers you want to use, their positions on the board, and they'll arrive pre-assembled. Our PCBs have arrived! I designed these PCBs just before making this video, so they do look a little bit different. And of course, I'll have to solder the components onto them, like in the previous chapter. This is by far the cleanest way to assemble our electronics. I hope that's given you some insight into designing your own PCBs, and there's so much more to learn. PCB design is quite a rabbit hole, and there are tons of other considerations we didn't even mention. Using surface-mounted components and more than two layers are usually the next step on most makers' journey. Thanks for tuning in, and happy making!
Makers love reviews as much as you do, please follow this link to review the products you have purchased.