Gardencore - temp, light, moisture readings for your garden

Good communication is important in any relationship. I wish my plants were better at it.

The GardenCore

I’m building a spark-core-based all-in-one garden monitoring system. It will send temperature, light, and soil moisture readings to a phone.

On my flight to Minneapolis, I sat next to a guy named Dan. Dan is involved in community based agriculture but was struggling to find sensors available at a low cost. I think the idea of a DIY open source sensor would be terrific. More inspiration came from my own experiences/failures with gardening: This is one of two plants I own that is still alive (thanks Martin!). The other is a cactus. I started with five plants.


I’m starting with an arduino and then moving to the core.

I envision it as a 3 prong stake. Two prongs for the resistance based moisture sensor, a third for the soil temp since soil resistance will change with temp. Light sensor placed on the side because incident light is a better measurement for my purpose. There will be a solar panel…somewhere.

I looked at GardenBot (a great open source gardening system), seeed studio (open source moisture sensor), and adafruit (for help with the temp sensor). I’m using gardenbot’s moisture sensor circuit for my prototype but will be modifying seed studio’s moisture sensor for the final ver.

Coming up… I’m going to layout a PCB and get things set up on the core.

feedback/questions/comments/whateva super welcome :sunny:

code link (github)

Hello! I’m Ramya. I’m interning / hanging out with the Spark team in Minneapolis for a few weeks. My role is to use the core in 1-2 projects, give feedback, and leave the real hardcore work to the other team members. :wink: I’m going to use this post to keep you updated on my first project.


Very nice! At first glance I want to make it smaller and save you some money… maybe this could be done as a first step, just build the temp sensor within the area that’s plated on one probe (isolated from the probe).

I could see getting one of these. I have a plant that I received as a gift from my grammy. She has since passed away, but the plant has lived on sprouting babies too. This plant is very special to me and I kind of obsess over it keeping it alive. I could definitely see adding one of these to it just for more data!!! :slight_smile: At one point I was over watering it and it would have been nice to know that. Sometimes you just forget to water as well. Or a general purpose meter for your yard, to let you know when it’s time to get the sprinklers running (before the lawn dies).

One idea is, if you know what kind of water treatment works well for a plant… put this device into “learning mode” and after a while of that (a week?) switch it to “alarm mode”… online graphs will help in coming up with limits… this could be done manually too.

Good luck!

edit: Almost forgot, you may want to use a small SOT-23 version of that temp sensor… or the MCP9701 is a good low cost choice… and put a dot of thermally conductive epoxy over it after mounting so the moisture doesn’t oxidize between the terminals and mess up the sensor.

Thanks for the feedback! :smile:

I started a PCB, the layout is here:
Man, eagle is so tricky sometimes. It took me a while to figure out how to remove the top solder mask for the prongs.

I don’t expect the traces from the temp sensor to interfere with the resistive sensing. I added the temp sensor at the bottom of one prong and left some space such that it can be bent down to lay flat against the pcb. There are 3 LEDs which I imagine could light up if a plant needs water, light, or needs to be cooled/heated. My thought process was that I don’t want this to be too intrusive. That being said, I’m also thinking of a small 16x2 LCD screen attached to a pot. Maybe with some ascii smiley faces on it to indicate status. We’ll see…

Here’s a screenshot if you don’t have eagle, to give you the basic idea:

@ramya, nice :wink: Here’s kind of what I was thinking, copper on top and bottom, tracks up the middle…

You would obviously need to tighten up your pad sizes for the TO-92 package temp sensor. Do you think there will be any resistance to pushing it down in the dirt with that large of a component on there? Roots and such might snap it off… maybe consider preassembling the SMT SOT-23 component for this one area, and offer the rest as a diy kit.

Another idea for something to add to the gardencore would be some sort of output to hook up to a small pump. Then you could have it in vacation mode and water whenever it is getting too dry. I’m a beginner, so I don’t know what would be best for it, maybe something like a servo plug?

@BDub Thanks for your suggestion! SMT is a really good idea. I thought the TO-92 package would be small enough to push down, if it was laying flat, but you’re probably right. Added a button, the SMT temp sensor, and moved some things around. Should be on github soon.

yeah! I wanted to keep it pretty simple, but maybe having access to the 3.3V, GND, and 1-2 digital pins would be good so people can add whatever they want! Maybe an open collector. I added some pin holes to the new version of the board. Basically I’m not sure I want to make the pump myself but if the option is there…I’m sure someone will add on to it :wink:

No problem. If you want to take it to the professional level, you might consider this potting compound.

It’s meant to be squirted through a static mixer tube, but that’s really for large batches of products and may not offer you the fine control you need.

I think what would be sufficient to cover the SOT-23 sized temp sensor, would be to squirt this out (part a and b come out at the same time) in a little dixie cup, then mix that up with a Qtip. Then take the Qtip/Cotton swab and use it to place a dab of this potting compound over the sensor… fully coating the pins.

Let this cure at room temp, or it will get fairly liquidy and spread out too much. If you hit it with a heat gun it will cure faster, but only after it turns to water :slight_smile:

Another thing you could use it some conformal coating in a spray can, just be sure to mask off the rest of the board before you spray it over the temp sensor.

Just thinking a bit about this… you may be able to get away with putting the temp sensor in the air above ground and avoid these issues. Over time soil this close to the surface would be fairly close to the ambient air temp… unless the sun is beating on it. Some experimenting would need to take place I think. Maybe two sensors would be needed to get the full picture of what’s going on temp wise.

Hi BDbub. So much information, thanks. Reading your post made me reaaal happy.

You’re right, some more experimentation would be needed. I assumed the soil has a greater heat capacity than the air because it has water in it. I found this chart (figure 3) that shows ground temps as a function of soil depth. At a depth of 2-4 inches it seems it would not differ too much from the air temp. However, measuring the soil instead of air means the reading will change more slowly, be less prone to random fluctuations in temp due to changing cloud cover, leaves getting in the way, etc. I also looked at this page that has soil and air readings taken in Washington. This guy found that the soil and air temp differed by about 5 deg F day to day…but he was measuring air at 2m. I’m going to chew on it more :yum: and then time for experimentation!!

Maybe I will apply conformal coating over the moisture sensor since currently it is susceptible to corrosion even though it’s ENIG plated (although maybe it will interfere with its functionality since it’s an insulator? not really sure will need to test). I’m thinking it’ll be best to switch to stainless steel probes as much as I like the idea of everything being on one PCB which makes it easy to manufacture.

Thanks again BDub. Over the weekend I learned that people call buffalo wild wings “bdubs”…

Aww…I am leaving Minneapolis tomorrow. Lots of things have happened since last time I posted :seedling:

  1. Testing with the core

While waiting for the PCBs, I started working with the firmware on the core, trying to make sure the code worked. I had to make a few changes.

I haven’t used C before. I wanted to print data from the light sensor to see if it was working properly. There were some issues with printing an int to string - it worked after I copied an implementation of itoa into the body of my program. To see what was printed out, I downloaded coolterm since I have a mac. If you have windows, use hyperterminal or PuTTY.

  1. The PCBs came in!

…thanks to Will. The black solder mask looks great.

LOOK, it fits!! I shouldn’t be this excited. I knew it would. Whatever.

  • I Realized I should have added labels to the spark core pins. I kept looking at the eagle file to figure out what goes where
  • On a similar note, I realized I didn’t mark the + and - for the LEDs. Oops.
  • The “prongs” are going to have to be longer because right now the core is very close to the dirt. An alternative strategy is placing the core & light sensor on a clip that attaches to the side of a pot and having wires lead to a buried soil & moisture sensor:
  1. Testing with Arduino

I wanted to make sure I didn’t make any mistakes with the PCB so I soldered everything and connected it pin by pin to the arduino. This is where pin labels on the PCB would have been super helpful. But everything worked and the SOT-23 sensor is has a low profile and looks great! (ty @BDub )

Next steps…
I’m gonna go back to the east coast and further refine the software, do some serious testing in REAL DIRT, and integrate wifi.

1 Like

@ramya that looks sweet! Congrats on ordering your PCBs and continued progress.

Regarding the fluctuations in air temp: I think since the soil temp is more or less a larger heat slug which doesn’t change too fast… you could just average the data from the air temp sensor and it would be approximately the soil temp. Obviously down in the soil is going to work as well :wink:

Conformal coating won’t be too much of a temperature insulator, and since much of the PCB is in the soil it will also conduct the temperature of the soil and bring that to the sensor. One trick for those temp sensors is to make a little ground plane on the pin that is connected to the die, that will act as a thermal coupler (not to be confused with a thermocouple). Not sure which temp sensor you ended up with, but the MCP9701 likes to have it’s ground pin connected to a copper plane for this purpose. See page 2 here.

Averaging the sensor data is pretty easy (tested, working):

// 1/16th Dilution Filter
// BDub 8-23-2013
// 1/16th of the new reading gets added to the ongoing 
// running total of 16 virtual readings, with a little 
// correction for the truncation process.  Very fast 
// filter for slow 8-bit uC's that don't have multiply 
// or divide instructions.
// avg = (new + (avg * 16) - avg +/- offset) / 16;
// avg = (new + (avg * 15) +/- offset) / 16;

#define TEMP_PIN A0
uint16_t rawTemp = 0;
uint16_t avgTemp = 0;
int16_t offset = 0;
uint32_t lastTime = 0;

// The larger the update interval, the heavier the filter will be.
uint32_t UPDATE_INTERVAL = 1000; // in milliseconds

void setup()
  // for debug
  // seed the average reading
  avgTemp = analogRead(TEMP_PIN);

void loop() {
  // Update the filter every 1 second (default)
  if(millis() - lastTime > UPDATE_INTERVAL) {
    // Set a new last time
    lastTime = millis();
    rawTemp = analogRead(TEMP_PIN);
    // Add or subtract the offset based on new reading
    if(rawTemp >= avgTemp)
      offset = 15;
      offset = -15;
    // You can see this is a fast way to multiply by 15.
    avgTemp = (uint16_t)((rawTemp + (avgTemp << 4) - avgTemp + offset ) >> 4);
    // Debug
    Serial.print("RAW: ");
    if((rawTemp > 99) && (rawTemp < 1000))
      Serial.print(" ");
    else if((rawTemp > 9) && (rawTemp < 100))
      Serial.print("  ");
    else if(rawTemp < 10)
      Serial.print("   ");
    Serial.print(" AVG: ");

BTW I see rev 0.1 Core and 0.2 Core in your pics… I’m guessing you are a beta tester. I never thought about it but it makes sense they would update beta testers with v0.2 hardware :wink: They look awexome on some real PCBs.

Were you planning on running a USB cable power supply to these? Optional 2 pin JST connector might be nice for a battery pack, although wall power is probably the way to go for the long haul.

Nice idea, I was thinking to realize something similar with the Core, to monitor multiple plants (of my small greenhouse) with one core. I would like to start the prototype before Cores arrive using an Arduino uno.
Searching on the internet I was thinking using MCP23017 for the moisture sensor, and realize moisture sensors like the one described here,37975.0.html (don’t know if this is the best way to do it). What do you think?
I still miss the measuring part, (dry soil would be 0 and water would be 100 i guess) …is soil temperature really influencing measurements or environmental temperature and humidity can be used as input as well?
What should be the sizes (length, distance…) of the moisture sensor legs?
Do you have any advices or suggestion for this project?
Thank you

Hey @ramya,
Very nice initiative, good stuff.
The other day a similar arduino based monitoring system has been brought to my attention. You may wanna have a look at what those guys are doing:

The 3 LEDS may be difficult to interpret, especially if they have the same color. Have you considered an RGB LED?

1 Like

@ramya Like it!
Maybe the moisture sensor can be use also for home automation as a rain sensor like this one from my home automation system (which is far more expensive than the core!) with another sensor layout.
Does it also show the water LEVEL while using in pure water ? Another purpose could maybe showing the rainwater level in a tank (have 4500 liters here , height about 1.50 meter, used for
toilet flushing) to refill from water line if no rain for weeks. Any idea for a (simple) sensor?

@mf2105 see page 14 of this manual for a cool peel and stick level sensor.

I think it works based on capacitance or capacitive reactance.

You could also attach a bunch of these cheap float switches to a stick and just submerge the whole thing in your barrel:

Since they would float in sequence, you can create a type of resistor ladder with them and sense your level with just one Analog input. Picture a 20k pull down resistor, and a 100k pull up resistor on an analog input of your choice. With each float switch, you could connect another 100k ohm resistor to 3.3V. The effect would put more and more 100k ohm resistors in parallel as your water level rose. Effectively raising the voltage at the same time. Easy to calculate the voltages.

1 sensor = 3.3V x 20k / (((100k + 100k) / 2) + 20k) = 0.94V
2 sensors = 3.3V x 20k / (((100k + 100k + 100k) / 3) + 20k) = 1.24V
3 sensors = 3.3V x 20k / (((100k + 100k + 100k + 100k) / 4) + 20k) = 1.47V
4 sensors = 3.3V x 20k / (((100k + 100k + 100k + 100k + 100k) / 5) + 20k) = 1.65V

N sensors = 3.3V x 20k / ((100k / (N + 1)) + 20k)

Sensor   Voltage
1	 0.94
2	 1.24
3	 1.47
4	 1.65
5	 1.80
6	 1.93
7	 2.03
8	 2.12
9	 2.20
10       2.27
11	 2.33
12	 2.38

(yeah, I know I’m resurrecting an old thread.)

DIY people might be interested in this:

(side note: for a project like this, weatherproofing and power are probably the two biggest issues.)

Edit: one of the nice things about this sensor is that it’s disposable/replaceable. This is important in a corrosive environment.

1 Like

Necromancy rules are lame :wink: :spark: Core was just born so it’s ALL good ALL the time!! :smile:

1 Like

thanks @ramya for the great ideas. I have read and re-read this thread several times during my build. I am getting the beginnings of my garden core working
Details and ongoing notes can be found here:

I am having a blast with this Garden Project of mine.

1 Like

Did enough google searching and I think I finally found what I was looking for :). Has anyone attempted to use this for automatic lawn watering? I am considering attaching a solenoid valve to this and using it for my lawn or outdoor garden. I wonder if this is too small for such a large area (and I need to worry about weatherproofing too.


Hello. Sorry to dig up this thread but I happened upon this while writing my thread on an automated rain barrel. I think these two could actually work together in the future. One thing I wanted to say is this: if you are interested in extended deployment then I would recommend using a tdr or fdr method. In particular, I think the vegetronix moisture sensor (which uses FDR if I remember correctly) is a good choice. It is fully encapsulated. There is no opportunity for galvanic corrosion as there is in the version discussed here. Now, I’m not saying this is bad, and the vegetronix sensors are more expensive, but if you plan on leaving it in the ground, it’s a no brainier.

I have tested the Vegetronix moisture sensor at work and it does what it claims to do, give you a repeatable return on moisture (using analog voltage). I’d also be interested in other sensors out there that aren’t subject to corrosion but cost less than those by decagon or campbell scientific.

1 Like