Week 4: Electronics Design
Assignment Details
individual assignment:
• use an EDA tool to design an embedded microcontroller system
using parts from the inventory,
and check its design rules for fabrication
• extra credit: simulate a circuit
• extra credit: try another design workflow
• extra credit: design a caseWhen deciding what to make for this week’s assignment, I decided to look for intermediate breadboard projects, because I thought that would be a good level of complexity for me to try to turn into a PCB. One project that came up many times was a soil moisture monitoring kit. I recently impulse-bought a bunch of plants from Facebook marketplace (bringing the total number of plants I own to 15) so I thought it would be a fun idea to make a plant monitoring kit. This also happens to continue the plant theme from last week!
Here and here and here are examples of people making similar projects with breadboards. Each one used a moisture sensor made up of two conductive prongs. The moisture is detected by measuring the resistance between the prongs. When water is present, the soil is more conductive, so the resistance will be lower compared to dry soil. The sensor I based my design off of is the SparkFun soil moisture sensor. I’ve included links to the datasheet, DigiKey listing, and their hookup guide below.
SparkFun soil moisture sensor
Initial Ideas and Sketch
- Of course this would be more fun if the PCB was shaped like a flower that would blend in to a garden 🌷
- I decided to include a microcontroller that way I could add phone notifications or reminders to water my plants if needed
- I wanted to have LEDs as moisture indicators, and envision the number of LEDs corresponding to the level of dryness of the soil
- I also decided to include a photoresistor so I could potentially measure the light that the plant was receiving
- The other extra addition I put on the board was two buttons. I was thinking maybe they could be used to toggle between the LEDs displaying the moisture and light values. But, because there is a microcontroller connected, the code can be changed to give the buttons whatever function I wanted.
After I had a decent idea of what I wanted to include, I started trying to figure out how to make the schematic.
Making the Schematic
Probe Circuit
First, I made the probe circuit. I copied the schematic on the SparkFun moisture sensor datasheet except I used the “test point” symbol from the KiCAD library so that I could easily design my own footprint for the probes.
Microcontroller
Then, I worked on adding and connecting the microcontroller. I decided to use the Seeed Studio XIAO ESP32C3 because, when looking at the FabLab inventory site, this was the only one with WiFi and Bluetooth and it also is nice and small. At this point, I needed more symbols than the KiCAD default library had, so I followed the steps to download the FabLab KiCAD library. This didn’t include a symbol for the Xiao ESP32C3 (at least as far as I could find) so I ended up taking the schematic from the Seeed Studio website: https://wiki.seeedstudio.com/XIAO_ESP32C3_Getting_Started/ This page was also very helpful for figuring out how to wire the XIAO in the schematic.
For example, the pinout diagram was helpful. I knew I wanted the moisture signal to go to an analog pin so the microcontroller could read the changing values from the sensor (rather than just on/off that comes from a digital pin). I picked pins D1 and D2 for the moisture signal and photoresistor signal because they are the only other analog pins that don’t have another function as well (D0 is the bootstrapping pin, for example).
Not Measuring Constantly
Something I learned when reading about other people’s similar projects was that running current constantly on the probes would cause them to corrode quickly, as well as obviously using more power than needed. So, I wanted to measure the moisture only at certain times. So, I connected the top of the probe circuit to a net called SENSE_PWR which connected to one of the digital pins (instead of to VCC/+3.3v like in the SparkFun example). This means the circuit will only measure when that pin is on. I also connected the photoresistor to the same pin.
Power
The XIAO has it’s own USB-C port, which meant I didn’t need to worry about how the PCB would get power, I just had to connect to the VCC from the Xiao. The finished PCB could be plugged in to the wall via USBC, or to a battery pack with a USB output. KiCAD’s ERC (Electrical Rule Checker) doesn’t like when the schematic has power pins but nothing that it thinks is powering them, so I put PWR_FLSG labels on the power and ground pins in the schematic.
LEDs
Many of the examples I saw had just one LED that indicated if the plant needed to be watered. I wanted to have multiple, partially because I thought it would look nicer with my flower design and also because I then could turn them on to show how much the plant needed to be watered. Because I wanted to control them individually, each LED needed its own pin and resistor. I wanted to use red LEDs because I thought that would be a good flower color, and so I googled what resistor value would be best and ended up choosing 330 Ohms. This is what the LED section of the schematic looks like.
Buttons
I followed an example I found online and wired the buttons to 10k pull-up resistors and to two of the other pins. I don’t have a set purpose for the buttons at the moment, but I thought it would be nice to have them in case I decided I wanted to do something with them. Maybe they could switch between making the LEDs show the moisture and light levels? Or turn on/off watering reminder notifications? Or one of them could let the microcontroller know when the plant was watered? So many options.
Photoresistor
Again, I followed an example I found to wire the photoresistor. I connected it to a voltage divider. So, as the light changes, the photoresistor’s resistance changes, and the voltage at the node changes, which goes to analog pin D2.
Decoupling Capacitors
I added 100nF capacitors near the VCC pin and the two pins that take the photoresistor and moisture sensing signals. These will help reduce noise.
Final Changes and Checks
- I put unconnected symbols on all of the pins I wasn’t using so that KiCAD wouldn’t complain about them.
- Then, I ran ERC and there weren’t any issues!
- I ended up having to run it again later because I changed the names of some of my nets and things got weird. It is nice to have a sanity check to make sure things will work.
Footprints
Next, I assigned footprints to all of the components on the PCB. For the basic components, I picked standard 1206 footprints. I used footprints from the FabLab library where I could and generic options otherwise.

For the probes, I had to create my own footprint. I wanted each probe to be a large conductive prong. To make this, I used the “Add Pad” button and then changed the parameters of the pad until it was the size and shape I wanted. I guesstimated on the size based on the SparkFun datasheet, which said the length of the entire module was 60mm and the spacing of the prongs was ~1in. It also said that the length and spacing didn’t matter that much for the performance, which was reassuring. I think maybe the footprint should have included
PCB Layout
Next, I updated the PCB editor from the schematic and tried to start laying out the PCB. Initially, I started a little randomly: I put the LEDs around the outside in no particular order, put the prongs at the bottom, and grouped the rest around the middle. When I tried to start routing things, I realized I was going to need to be a little more organized.
Before I started routing traces, I wanted to have the shape of the board done. I tried in the KiCAD editor, but was unsuccessful at designing the flower shape. After some Googling I learned I could import a .DXF into the “edge cuts” layer in KiCAD to make the shape without using the editor. I’m much more comfortable in Fusion than KiCAD, so I switched to a sketch in Fusion to make the flower design. This is how that progressed:
Then, I saved the sketch as a DXF and imported it into KiCAD.
Once I imported the design into KiCAD, I realized the dimensions were off - the flower was way larger than the rest of the PCB. Unfortunately, KiCAD doesn’t have a scale feature in their editor, so I had to fix it in Fusion. Once it was imported successfully, I moved the parts around to fit the shape of the flower and then tried to route things again.
To summarize a while of work:
- Routing things takes a while.
- I kept starting and re-starting when I realized it would be impossible to connect the components with whatever layout I was trying.
- I put the photoresistor at the top of the board so that the light it measures would be closest to the light the plant receives. It is close to one of the LEDs, but I think the photoresistor will stick out a little more than the LED and also the base light can be accounted for in the code.
- I learned it was really helpful to go between the pads of components like resistors and capacitors.
- I decided to use the traces to outline the flower and make some patterns on the PCB. This definitely isn’t the most efficient layout, but I wanted the circuit to look nice as well. Hopefully this wouldn’t cause issues with the function of the board.
- I learned that the fastest way to delete a messed up trace is with backspace (I spent a lot of time before I learned that clicking things manually. Not fast.)
- I ended up swapping some of the pins for different things. I was careful not to swap things that needed to have an analog pin onto digital pins. This helped me connect things that needed to be in a specific part of the circuit (like the probes) by moving them to pins closer to where they were located. I’m grateful for the net names for making those swaps easy.
And this was the result!


DRC and Constraints
Then, I realized a big issue with my design. I hadn’t updated the DRC constraints to reflect the capabilities of the lab’s PCB mill. When I did that, there were a couple hundred errors because of incorrect track width and clearance. Also, the current version of the PCB is too big to fit the bed of the mill.
I decided to re-route the PCB in its current size before adjusting the size, because I thought it would be fun to have a larger one.
I’m really proud that I got the circuit to connect and look how I wanted all in one layer, because there were definitely points when that seemed impossible. I think my job would have been easier if I laid the components out in a more efficient way from the beginning. I think I could have thought harder about that, which would have saved some time during the routing phase.
A good next step for this project would be to design a case so that it could be used outside without ruining the electronics, but I don’t think I have time for that this week. This PCB will have to only work for houseplants for now.
Here’s a .zip of my KiCAD project:
















