Saturday, July 4, 2020

Garden Logger

How many hours of sun does each raised bed in the garden get? How moist is the soil? How fast does it dry out, and how does that correlate with the air temperature?  And, how does all of that correlate with the productivity of a given crop type?

The first step towards finding those answers is to collect data. I'm starting simply with just measuring the hours of full sun and logging it to an SD card once per minute. The circuit consists of a CdS photocell in a  half bridge configuration connected to one of an Arduino's analog inputs. The resistance of the photocell is calculated in the Arduino sketch which was probably isn't a great idea, since it's going to need to be post-processed anyway. I have yet to figure out how to calibrate the photocell so that the results can be displayed in units of luminous intensity, but, regardless I should have just logged the output in raw A to D bits.

The date and time of day is stored in a Real Time Clock (RTC), which is part of the logger that I got from Amazon. The RTC had to be programmed once before loading the logger sketch.

Arduino sketch reads the resistance of the photocell and the time and date on the clock, and stores it to the SD card. After sitting all day in the sun, covered by a piece of cardboard (except for the photocell), I bring the card in and add a description of the logged location to the last line of the file, using a tag "Title:".




The log file looks like this:

2020/06/23T20:10:14, 395.9
2020/06/23T20:11:14, 406.5
2020/06/23T20:12:14, 417.1
2020/06/23T20:13:14, 449.0
2020/06/23T20:14:14, 449.0
2020/06/23T20:15:14, 470.3
Title: Bed 2

To get plots of the solar intensity, I wrote a Python script that uses matplotlib. The brighter the sun, the lower the resistance. Full sun is about 25 ohms. As each location is plotted, the number of hours of full sun is calculated. Full sun is assumed to be when the resistance is less that 75 ohms. The number of full sun hours is often less than the stop time minus the start time. This is because the trees or other objects sometimes obscure the sun over the course of the day.



For each plot I mark the total hours of sun on a diagram of our garden.


This is the hardware:
  • Arduino Uno
  • HiLetGo data logger shield
  • CdS photocell
  • 10 Kohm Resistor

This is the software:



I have some soil moisture and temperature sensors that I'll integrate into the next phase of the project.