PiPlanter | Second round of data collection

So as I said in one of my previous posts, I am going to be collecting a lot of data over the next few weeks while the tomato plants grow. I will be doing this to determine when soil is “dry” and how temperature and light effect that process. For the last week I have been collecting data in the configuration seen in my last post and here is the graph it produced you can click to see the full image:

This graph proves a few things. The first thing is that the relative moisture sensor works. As one can intuitively understand, if you don’t add more water into the system, nature will remove water via evaporation. The overall trend of the blue line (the rel mst sensor) is downward, backing up this point.

The problem with this setup was that I was spitting the voltage across the two probes constantly, which along with the water caused the nails to rapidly oxidize, which is something I would like to avoid in the long term. This also may have seriously corrupted the data so besides general trends, this whole set is unusable.

This isn’t necessarily a bad thing though, as I wanted to conduct a second trial with more probes and more dirt.

I decided to go with 4 probes, and here are a few pictures of the assembly process. Assembly process is the same, I just did it at my school:

I cut it into 3cm sections and then drilled holes on the midpoints of the 2nd and 3rd cm as seen in a photo below.

Here are the holes drilled for the nails

Here are the nails inserted into all 4

Here is the wire wrapped around the nail

Once solder is applied, the connection is very strong and conductive

Here’s the gluing process

Here are all of the sensors assembled. I attached headers to the other ends as seen in the last post.

Since i’m using 4 sensors now, and to get around the oxidation problem, I added a NPN transistor to cut the ground current when the sensor isn’t being used so it only turns on when it’s getting polled. Here is the new python code:

It’s pretty much the same thing.

The graph is also very similar, but I won’t post that code as it’s not different enough.

Here are pictures of setting up the whole system:

I used the same soil as seen in the previous post, and added 125mL of water to each sample.

Here’s a video of me explaining the whole process:

Once enough data is collected I’ll post a graph of it here.

Hey! This post was written a long time ago, but I'm leaving it up on the off-chance it may help someone. Proceed with caution. It may not be a good idea to blindly integrate this code or work into your project, but instead use it as a starting point.


  1. Looks good! I’ve been thinking about doing something similar with a strawberry plant I have. I plan a similar setup to this, and was pleased to see your data points showing that the theory does indeed work.

    1. Cool! It’s defiantly worth it, I learned a lot through doing it and now I really don’t have to worry about tending to my plants. Are you going to use a pi?

  2. Yet another update…

    I realized that the resistor has to be smaller than the first 220K i started with, so I tried a 220R where I was able to get rid of the strange output, and as I short the nails it returns about 4 or 5, which isn’t that much, so I tried to go even further down in resistance and with a 10R I am getting a return value of 29 when the nails is shorted…

    Should I go even further down in resistance? Or is this as it is supposed to be returning?


    1. Hello

      I’m using a 330 ohm resistor, and it works fine.
      Do you have something like a potentiometer that you could test if the ADC is working?

      If you have already done this, can you send me a picture of the prove setup you’re using?

  3. I find your project very interesting as I am working on automating the watering of my citrus trees in a greenhouse. I follow most of everything except for the wiring of the moisture sensors & NPN transistor. Do you have a drawing or something that shows how they are all wired? (Maybe a closeup pic of the breadboard pointing out the different parts?

    1. Unfortunately, the project has been deployed, and I now living several hundred miles away. It’s a pretty simple setup and i’m sure some quick experimentation could get it working for you.

  4. sir actually i am a non electrical student, but we are still doing this
    thing for our project… We are using YL 69 soil moisture sensor, and i came to know that
    it already has a digital output in that. Can you just tell me what is its exact purpose?
    and can i use this pin to display output on laptop using raspberry pi 3 model B?
    Or i must definintely use the adc mcp3008?? please reply asap.

    1. I am unfamiliar with this sensor, but a cursory glance shows that the digital out may be a the output of a compactor, which wouldn’t be useful. You most likely will need to use the ADC. Good luck!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.