How to use a Breadboard!

Used by hobbyists and professional engineers alike, breadboards allow us to quickly build all sorts of circuits!

Breadboards got their name because in a time long ago, engineers used to use wooden cutting boards! They would hammer in nails and wrap wires to make connections. Not only was it tedious, but the cooks got frustrated that their breadboards kept getting stolen and used for definitely-non-food-purposes, so eventually someone invented the plastic breadboard to keep kitchen utensils safe. Hooray!

Similar to wires, plastic breadboards use conductive metal and insulating plastic to create paths where electricity can flow (the metal parts), and breaks where it cannot flow (the plastic parts).

If we were to look underneath a breadboard and peel off the backing, we would see something like this:

What do you notice?

The middle of the breadboard is different than the outsides. On outside of the breadboard, on both the left and the right sides, there are two long strips of metal. These are called “Power Rails”, or “Power Buses”, and one of the strips by itself is called a “Power Bus.”

Flipping the breadboard back over, the top, where we make our circuit connections, looks like this:

Looking at our Power Buses, there are colored lines next to them. While these are just guidelines (ahhhh sorry for the terrible pun, lol), the colored lines are super helpful for keeping track of how we connect our battery or power supply to the breadboard. Typically blue means negative, or ground (“gnd”), and red means positive.

The middle gap of the breadboard is called the trench. This separates the two identical middle halves of the breadboard. The trench is sized so that components with more than 3 pins can fit across.

The rows of the breadboard are marked with numbers, in this case numbers 1 – 30. The columns are marked with letters A, B, C, D, and E. Each row has a set of 5 holes that are connected by the piece of metal we saw on the bottom, as well as metal pins on the inside that hold wires and component pins in place. Some of the hole groups that are electrically connected are shown on the photo above with red rectangles.

Now let’s make some circuits! We’ll need four (male-to-male) jumper wires and the following parts:

Next, we’ll connect the battery to the power rails. If your battery case does not plug directly into the breadboard, grab two jumper wires for this.

The battery case that you are using might change how you connect your battery to the circuit, and that’s okay! The important part is that you connect the positive side of teh battery to one power bus, and the negative side of the battery to the other. Be sure that both sides of the battery are in different power buses (if you feel the battery getting warm it may indicate that it is short-circuited, this would be the place to double check).

Next, let’s connect our light! Grab your remaining jumper wires and your LED.

Insert the LED legs so that both legs are in two different rows (reminder: rows are marked with numbers). Connect the positive side of the battery to the longer LED leg. Connect the negative side of the battery to the shorter LED leg.

Voila! If the LED is connected to the battery in a circuit, it will light up!

Try moving your LED to a different part of the breadboard. Observe what happens!

Does wire color matter? Try two different colored wires and see what happens!

Finally, let’s end our exploration by tracing the path of the electricity.

Electric current is defined to flow from positive to negative. That means our electric current, which is made up of moving charges, flows out of the positive side of the battery, through the wire and into the breadboard power bus. It flows through the power bus, then up and out the red wire to the breadboard row where it can travel up the LED where it does work (and loses some energy) to make the LED turn on.

Then the (less energetic) electric current flows out of the LED through the shorter leg, into the breadboard row where it flows into the black wire. It then flows out of the black wire and into the second power bus, through the power bus and back to the negative side of the battery.

Our circuit is a circle! The moving charges that leave their home must also come back, but they come back more tired and into the back-door (which is to say, the negative side!).

Other helpful terms:

  • Current: The amount of charge flowing past a point in our circuit.
    • Current units are given in Amperes/Amps, or A
  • Voltage: The potential energy, or pushing force, across a component in our circuit. A higher voltage means more pushing force.
    • Voltage units are given in Volts, or V.
  • Resistance: How much a particular component resists the flow of electricity.
    • Resistance units are given in Ohms, or O
  • Capacitance: How much current a battery can provide over time.
    • Capacitance units are given in Amp-hours, or Ah.

There are two ways to connect components:

1. In series: connect components in line with one another, or head-to-tail.

2. In parallel: connect components in loops, or head-to-head.

Going Further!

You are now ready to tackle more circuits! Try adding more lights, or using different components. What happens when you add different kinds of components together? How many ways can you combine multiple components ?What sorts of projects could you use these circuits for? Share your creations with us, we always love to see and share!

And of course, please let us know if you have any questions, we are here to help!

Other useful tutorials:

Happy making!

Raspberry Pi Irrigation Controller

F7PVGADHZV3TCB3.LARGEGardening improves health and quality of life, connecting us to our local environment. Plus, you can eat organic fruits and veggies at very little cost. Alas, remembering to water can sometimes take a backseat to our busy lives. Fortunately, home automation is easier than ever with inexpensive and accessible microcontrollers like the Raspberry Pi 2 Model B and Arduino.

This tutorial details the construction process for a remotely controlled solenoid irrigation valve. In other words, a home computer controls the water flow of an outdoor hose spigot, or bib. The materials cost is about $30-40, excluding the Raspberry Pi (RPi). Cheaper parts can be found with patience and creativity.

The design is intended as a simple introduction to building a complete, personalized home irrigation system. It is also intended to encourage simple DIY solutions to everyday problems. Make modifications and upgrades to suit your needs, resources, and skill level. To conserve water, include drip irrigation and a soil moisture sensor.

Note: This project involves high voltage which requires extreme caution. Always check power connections before touching exposed wires.

Materials

FA20S0WI0LCOO0B.LARGE

Raspberry Pi, GPIO Cable, GPIO cable adapter + breadboard

This tutorial assumes the RPi has all GPIO libraries. To install outdoors, the RPi also needs a WiFi adapter and to be accessible by SSH or other remote login.

Solenoid Irrigation Valve
This tutorial uses a 24 VAC solenoid for a 3/4″ hose spigot.
Some background: there are two main types of solenoids: AC or DC.

  • An AC solenoid valve turns water on when voltage is applied, and turns it off when the power is off. The drawback is that it uses AC voltage, requiring an adapter to convert the wall voltage, 120 VAC, into the 24 VAC voltage needed to trigger the valve. Outdoor Installation likely requires an extension cord.
  • A DC solenoid valve allows for a battery powered system. It can easily be modified to be wireless and powered by renewable energy using a medium solar panel (~10 W). However, most DC irrigation valves are latching solenoids and require switching the valve lead polarity to turn water on and off.

I chose an AC valve for the first prototype because I already had a few parts.. and adequate rechargeable batteries can be expensive.

— Solid State Relay
The Solid State Relay, or relay, is the intermediary switch between the RPi and the solenoid valve. This tutorial uses a Crouzet Model OAC5-315; its input is 3 – 8 VDC and its output is between 24 – 120 VAC at 1A.

N3904 Transistor

4.7 kOhm Resistor

PCB Board
Sized to fit the relay, GPIO pins, transistor and resistor.

AC Power Adapter (120 VAC to 24 VAC)
Use an extension cord and/or longer leads to install outdoors.

— 22-gauge stranded wire (insulated), min. 10 feet

— Waterproof container
I used a leftover project box wrapped with waterproof tape. Cheap/free containers are easy to find; Talenti ice cream containers are an example, and also happen to contain delicious ice cream. With small containers, be sure exposed AC connections are completely covered in epoxy to protect the RPi.

— Optional: Waterproof connectors, waterproofing tape/lots of duct tape

FQ7ILN7I0LCOO0E.LARGETools

Soldering iron, solder, solder sucker

Wire strippers

Epoxy
Check that it is safe for outdoor use. Marine-grade epoxy may be best for long-term outdoor installation.

— Screwdriver

— Optional (but highly recommended): Multimeter

— Depending on your system container, a drill might also be useful.

Build It!

FE74HWMI0LCOO0F.LARGEHardware Intro: Solenoid Setup

  1. Add wire leads to the AC power adapter (if there are none); use at least 3-4 ft of wire.
    This AC power adapter has screw-type connectors. Recommended to coat these in epoxy.
  2. Verify that the solenoid works by connecting the leads to the power adapter.
    The valve makes a “clicking” sound when it is turned on.
    For thorough testing, repeat with the valve connected to the hose spigot.
  3. F5HUWP0I0LCOO0H.LARGEOptional: Extend solenoid valve leads using the waterproof connectors.
    Twist wires together inside the connectors, check the connection (aka continuity), then epoxy the openings.


    Remember, never touch exposed wires when power is on. Always double-check power connections.

Hardware Pt. 1

F55BJ37I0PYY1SJ.LARGE

If the schematic makes sense, skip the next three hardware steps (Hardware Pts 1 – 3).

FH4GQX8I0LCOSVB.LARGEPay attention to the layout of the PCB pads and use them to make connections simpler and more direct. Plan where components are connected prior to soldering. It may be easier to solder components in a different order.
1. Solder the relay to the PCB board.
The labels on the relay tell you the function of each pin. Here’s the datasheet for further reference.
1.a. Solder a wire lead to each relay pin, leaving 6 in. or more for the AC leads. 

F788JF3I0PZ2MGQ.LARGE2. Solder the RPi GPIO pin 18, 3.3 VDC pin, and ground pin to PCB board pads.

3. Solder the transistor to the PCB board, keeping each of the legs electrically insulated.

4. Solder one end of the resistor to the middle transistor leg (base pin) and the other end to GPIO pin 18.
Any other available GPIO pin works as long as you change the code to correspond to your chosen pin.
For best results, use one 4.7 kOhm resistor and connect as shown in the photo to the left.

FP5I646I0PZ2ONK.LARGEHardware Pt. 2 

  1. Connect the RPi ground pin to transistor pin 1, or emitter pin.
    Connect from the flat side of the transistor with a wire, the PCB pads, or a combination. For stranded wire, it helps to twist the ends before pushing them through the PCB holes.
  2. Connect transistor pin 3, or collector pin, to the negative DC relay pin.
  3. Connect the RPi 3.3 VDC pin to the positive DC relay pin. 


Hardware Pt. 3

  1. FESTW3ZI0PZ38JX.LARGEConnect one valve lead to one AC power source lead.
    Twist wires together and coat in solder. AC current alternates directions, so either lead will work for both the valve and AC power source.FHUMWX2I0PZ38IE.LARGE
  2. Connect the remaining valve lead to one of the relay AC output pins.
  3. Connect the remaining AC power source lead to the other relay AC output pin.
  4. Check all electrical connections with a multimeter.
    If available, check continuity. Otherwise, plug in the AC power source and check that there is ~ 24 VAC across the relay AC pins.
    A friendly reminder: Never touch exposed AC connections when the power source is plugged in.
  5. Coat all exposed AC connections in epoxy, including the relay AC pins.
    For safety purposes and to adhere connections.

Software

The software program turns the valve on and off by applying a voltage across the DC terminals of the relay.

1. With that basic principle in mind, here’s a simple code to get you started:

#Import the necessary libraries
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM) 
#Setup pin 18 as an output
GPIO.setmode(GPIO.BCM)
GPIO.setup(18, GPIO.OUT) 
#This function turns the valve on and off in 10 sec. intervals. 
def valve_OnOff(Pin):
    while True:
        GPIO.output(18, GPIO.HIGH)
        print("GPIO HIGH (on), valve should be off") 
        time.sleep(10) #waiting time in seconds
        GPIO.output(18, GPIO.LOW)
        print("GPIO LOW (off), valve should be on")
        time.sleep(10)
valve_OnOff(18)
GPIO.cleanup()

F6I6KS9I0PZ38QU.LARGE2. Run the code in the terminal window of the RPi using the following:

sudo python FileName.py

3. Run the program before connecting the AC power source.
Use a multimeter to check that the voltage across the DC relay pins fluctuates from ~ 0VDC to ~ 3.3 VDC in ten second intervals.

4. Plug in the AC power source and run the program again. Listen for the solenoid to click on and off.

Waterproofing

  1. Double and triple-check all your connections with a multimeter.
  2. FRLCNBBI0PYXZIF.LARGECoat remaining exposed connections in epoxy
    Give yourself a way to remove the RPi + GPIO cable from the rest of the circuit so the RPi can be used for future projects (if so desired).
  3. Place the RPi and PCB board components in a waterproof container.
    Find a way to seal the external power cables. The first prototype uses waterproof tape to cushion wires and seal the box. Drilling holes in the box and sealing with epoxy is another quick and easy option.. get creative!
  4. Optional: To organize loose wires, twist insulated wires around each other, use zip ties or innovate another method.

Test & Improve!

That’s it! Rewrite the program to water your garden as needed. The easiest way is to keep the program as a timer. Change the program to increase the watering time to suit your plant needs and the wait time to >12 hours (>43,200 s).

ValveFinalPhoto2

ValveFinalPhoto

This system was originally designed to be controlled by a RPi-powered soil moisture sensor. To combine the two projects, copy the valve function into the soil moisture sensor program. Update the valve function to turn on if the soil moisture reading is below a certain threshold. Follow the hardware setup as outlined in the soil moisture sensor tutorial. Connect components to the existing PCB board if there is enough space, otherwise get another PCB board for the soil moisture sensing circuit.

Now that you understand the fundamentals, customize and upgrade the system to suit your own needs! Possible extensions include monitoring and/or controlling the system with your phone, or using renewable energy technology for power (e.g. photovoltaics + battery).

Raspberry Pi Soil Moisture Sensor

Conserving freshwater is one of those seemingly constant struggles, especially with a human population exceeding seven billion. In the United States, between 80 – 90 % of freshwater is consumed by agriculture, making it the perfect industry to implement more efficient ways of using water! Installing a soil moisture sensor is one way to optimize irrigation systems and reduce water consumption. Soil moisture sensors measure the amount of water in the soil so that your plants get water only when needed.

The following tutorial is a simple capacitive soil moisture sensor that uses a co-planar capacitor from the Zero Characters Left blog. The sensing circuit can be constructed for less than $25.00 w/ little or no prior experience in hardware or software prototyping. Experiment with and modify the system to create a version that suits your own needs!

Also, you can power this entire system using a portable solar USB charger.. 🙂

Materials

IMG_4855

— Raspberry Pi Microcontroller

  • This tutorial is based on a fully set-up Raspberry Pi, including GPIO libraries + GPIO cable w/ breadboard connector.I also recommend setting it up for wireless + SSH

1 MegaOhm resistor

  • This resistance was the best for my system, but a different resistor value might work better for your own setup. Experiment w/ different value resistors and see what happens!

— Co-Planar Capacitor (here)

— Solid core or stranded 22-gauge wire

  • Recommended to get stranded wire b/c conducts better & is less likely to break.

— Breadboard, breadboard wires + GPIO breadboard converter

  • This is the bare minimum needed to built the system. I recommend that you use better/more permanent connections once you have tested the system and made sure that it all works as expected.

Tools

IMG_4854

— Soldering iron, solder & solder-sucker (or solder wick)

  • A soldering iron is (almost) essential for this project, especially for attaching wire leads to the co-planar capacitor. You can purchase a soldering iron, solder and solder wick (removes solder) for ~ $20-30, or find a local makerspace/hackerspace that will let you come in and use an on-site soldering iron.

— Wire Strippers
— Epoxy
— Optional (but highly recommended): Multimeter (for testing and debugging!)

Operational Principles

  1. Soil is made up of four main components: organic matter, sand, silt, and clay. Between these are air gaps that can be filled with water. Here’s a diagram of different soil water contents:soilsaturation
  2. Water conducts electricity better than air. This information allows for tons of different types of soil moisture sensors. This design uses a capacitive sensor: the capacitance of the sensor changes based on the amount of water in the soil.

Sensor & Circuit Design

An RC circuit provides a quick & simple way to measure changes in the sensor capacitance due to changes in soil water content.
A little bit of jargon: “RC” stands for Resistor Capacitor. An RC circuit generates a time-varying current depending on the initial voltage, the initial current, and the circuit resistance and circuit capacitance. AKA: the output of the RC circuit depends on how much power you put into it and on the resistors and capacitors in the circuit.. which makes sense as that’s all there is in the circuit!RN_TimeConstant
Every RC circuit has an associated time constant, which is the time it takes the capacitor to reach ~ 63% of its maximum charge.  The time constant equals the total circuit resistance times the circuit capacitance:  τ = R * C
The graph on the right shows how the voltage across the capacitor changes over time.

The time constant is used to measure changes in the sensor capacitance. As the capacitance changes, so does the time constant. The equation above tells us that the time constant is directly proportional to capacitance, i.e. the time constant increases as the capacitance increases, and vice versa.

In this system, the co-planar capacitor is the soil moisture sensor (or SMS). Theoretically, when the sensor is in air or dry soil, the time constant is small b/c the capacitance is low. In water or saturated/wet soil, the time constant is larger b/c the capacitance is higher.

Here’s the circuit schematic:

SMS_SchematicV2

If you want to boost or lower the signal, change the value of the resistor to increase/decrease the magnitude of the sensor output.An Odd Observation: When the sensor was in dryish/damp soil and not registering, touching the resistor leads caused the sensor to output a reasonable signal. It also was sensitive to changes in light. These phenomena could be due to finicky connections & exposed wires; RC circuits tend to be sensitive to changes.

Build It!

Hardware:

  1. IMG_4838Solder wire leads onto the soil moisture sensor pads. Test connection w/ multimeter. If the sensor is electrically connected, coat in epoxy & let dry before continuing.
    If you’re using stranded wire + a breadboard, you’ll need to find a way to connect the stranded wire to the breadboard (b/c trying to shove it into the breadboard holes will make you want to pull your hair out). I stripped two breadboard wires and soldered them to the sensor leads. My connections were stil a bit finicky. Try different methods and see what works best. Use available materials and keep it simple!
    For the remaining hardware steps, reference the schematic and the picture below.IMG_4835
  2. Connect the RPi GPIO pins to the breadboard. Connect the 3.3 V output pin to the “+” column along the side of the breadboard.
  3. Connect the GPIO ground pin to the “-” column.
  4. Connect one resistor end to the 3.3 V output (any of the holes in the “+” column). Connect the other end to any of the breadboard rows. Orientation of the resistor leads doesn’t matter.
  5. Connect GPIO pin 14 to the same breadboard row as the resistor. You can use a different GPIO pin, but remember to change it in the software program.
  6. Connect one of the soil moisture sensor leads to the same breadboard row as the resistor + probe. Connect the other lead to ground (any of the holes along the “-” column). It doesn’t matter which lead goes where.
    Here’s a photo of the breadboard setup (3.3 V connection is hidden by GPIO cable):
    IMG_4862

    Software:

  7. Write a code to measure the capacitance of the sensor! Use the fact that the time constant changes depending on the medium in which the sensor is installed (capacitance is much larger in water than in air).
    Or you can just use mine 🙂
    Keep in mind that is a basic program and doesn’t include a GUI. All commands are run on the Pi’s terminal window (LXTerminal). The program prints the raw time constant, which is correlated to soil water content, a time stamp. If the reading is too low, the program also prints a reminder to water the plants. It also stores the raw data in a text file. To end the program, use “Ctrl + Z” or “Ctrl + C”.
    Modify and improve the program based on your own skills/needs. Remember to change the watering threshold based on your own experimental discoveries!
  8. Test the code and determine your ideal threshold.
    a) Test the sensor in water and air first; this provides the upper and lower bounds on the sensor output. If you find that the sensor is not reading in either of these mediums, change the value of the resistor until you get a reasonable signal. Be sure to record the reading for at least 5 – 10 minutes. It is helpful to plot the results in a program like Excel or R.
    b) Place the sensor in a cup of dry soil. Add a small amount of water and measure changes in sensor output over time (wait at least 5 – 10 minutes).
    c) If you are not getting a reading in either medium, try checking the electrical connections on the sensor.
  9. Fix the program as necessary.
    Your signal will likely be different than mine due to minor differences in your sensor and general setup. Use your findings from 8.a) & b) to find an approximate value at which your soil is too dry.
  10. Run the program & use it to maintain consistent watering of your beloved plants! 😀

Optional extension of the project: Making it survive outdoors!

IMG_1201Coat everything (except the sensor) in epoxy! .. Ok, so maybe not. Although, honestly it might work if you’re careful. Otherwise, you’ll want to scrap the breadboard for a PCB board + more 22-gauge wire. Molex connectors or something similar are a handy feature for the sensor.

Build process:

  • Solder the resistor & the sensor leads to the PCB board.
    • Your PCB may have copper lines connecting various pads; use this pattern on the PCB board to your advantage!
    • If your PCB board does not have any pads connected, an easy way to connect components is to run wires along the bottom.
  • Test the system w/ a multimeter or by running the code to be sure that it works as expected.
  • NOW coat it all in epoxy!
  • (Gently) shove the sensor circuit + RPI system into a waterproof container. My mom collects Talenti ice cream containers and they are super awesome for projects like this. Plus it’s a great excuse to eat a container of ice cream 🙂

If you run into any problems or you’re struggling with a particular step, please leave a comment & we can troubleshoot together! And we can help save the world by reducing our personal water consumption, yay!