4H and the Particle Soil Moisture Sensors


It all started when my wife signed me up to give a talk with the kids at my towns local 4H group. The 4H group is a youth group that focuses around nature and the local community. Our group in town works with farm animals, agriculture and just other fun stuff that exposes kids to new experiences.

I wanted to do something with a lab and a small talk but I had a very small budget. I decided that I would just do demonstrations of various projects I’ve already done and have it more focused on computer programming. But something kept telling me to do a lab and focus on a project that 4H could actually use. Since 4H does agriculture projects, building a soil moisture sensor would be something that would work with future projects they might have.

Planning the Project.

Started with a prototype of the project using an existing Particle Photon and some parts I had. Once the prototype was built, finding the parts was pretty tricky but most were pretty cheap and on eBay or Amazon. After communicating with the 4H group leader we decided that there was going to be around 30 or so kids. Obviously 30 sensors gets to be pretty expensive but with some budgeting we could make it work with 15 sensors and have the kids pair up into groups of two for the lab.

I also had another USB hub that I previously purchased that had 5 more connections so I could have all the soil sensors plugged in at once.

The most expensive part was the Particle Photon at $19.99 a piece. So, I reached out via twitter to @Particle and asked if they would maybe want to help out with the lab.

To my surprise they were more than happy to help. (Thx you Joe!). Particle sent me all the photons and even maker kits for the lab for free. They are AMAZING people.

Building & Testing

Before the lab, everything needed to be tested to make sure it worked. This was also a good time to make sure the documentation and my slides were all correct. My kids also helped me and made sure it wasn’t confusing to understand.

Step 1. Adding the Photons to the breadboards.

Step 1

Attaching the Photons. The Photons need to be in correct pin and in the right position. This is also in the presentation where I explain what a breadboard is and how it works and how we interact with the pins on the Photon.

Making diagrams for each step is also important documentation. There is a free software called fritzing which lets you make diagrams and pictures.

Step 1 Diagram

Step 2. Wire Up the Photon

Step 2

Once the photon is attached to the breadboard it’s time to wire everything up. You can wire these sensors up using less wires, but this way was easier for the kids to understand how breadboards work and less chance of them putting components in the wrong pins.

Step 2

The different color wires were used for the main reason that I didn’t have enough of the same color, but I found it keeps it less confusing for kids to learn. This is why there is a white wire for 3v3 and a brown and orange wire connecting to the soil sensor.

Step 3. Adding the soil sensor

Step 3

The soil sensor has a plug that you can just plug the jumper wires in. The only part that got confusing was matching the colors up but most of the kids got this figured out pretty quickly. Having the diagram showing the colors was very helpful.

Step 3

Step 4. Testing

Step 4

The circuit is setup to run the code below. It sets up the green LED to blink when moisture is detected and blinks the red led when there is no moisture and telling you when the plant needs water.

The data is read from the sensor on A0 pin. The value gets submitted every second to the Particle cloud using the soilSensor variable. You can monitor the sensor remotely also by query the soilSensor variable in the Particle cloud.


int soilSensor = 0;
int redLed = D1;
int greenLed = D3;

void setup() {
    Serial.begin(9600);
    Particle.variable("soilSensor", &soilSensor, INT);
    pinMode(A0, INPUT);
    pinMode(redLed, OUTPUT);
    pinMode(greenLed, OUTPUT);
}

void loop() {
    soilSensor = analogRead(A0);
    if(soilSensor > 2000) {
        digitalWrite(redLed, HIGH);
        delay(1000);
        digitalWrite(redLed, LOW);
    } else {
        digitalWrite(greenLed, HIGH);
        delay(1000);
        digitalWrite(greenLed, LOW);
    }
    delay(1000);
}

The flashing is pretty simple to setup and I had no problem uploading the code to 15 different particle boards. Hat’s off to the developers and everyone who made this experience super easy.

I already had the particle installed on my machine from other projects so I simply just login and run $ particle setup and setup the wifi settings so that each one could connect to the wifi where the lab was at. Then using the the particle cloud each Photon was updated with the above code.

Once all the Particle Photons were working I took each one apart and put it’s parts into their own bag. Everything was set for the lab now.

Presentation

The presentation starts off with just a quick about me and I talk a little about programming. Showed them a sample website that used the sensor information and since time is limited, the remaining talk moves on to building the circuit.

You can view my slides. There are more detailed instructions on how to build the circuit step by step in the slides.

Conclusion

It was a blast doing this presentation and lab with the kids. They were all very excited and you could tell they were into it. It’s nice to give back and maybe some day one of these kids will go off and invent something that changes everyone’s lives.

Here are some pics from the lab.

Lab

Lab

Lab

Special Thank You!

I wanted to give a special thank you to all the 4H kids and parents. Thank you to all those that give up their time on the weekend to help teach kids and expose them to new and different experiences.

A special shout out to Particle. They donated the Particle Photons for the lab and without them it wouldn’t have been possible. Thank you!