Arduino Sunlight Logger Project and Chart from First Test

We are renting a beautiful home in Portland in a nice neighborhood with magnificent pine trees all around. During the summer it looks and smells like we live in a camp ground. The needles and pine cones are a pain to deal with but we enjoy watching the squirrels and birds that frequently visit.

One of the things my wife and I have really missed after relocating from beautiful Southern Oregon was our home grown tomatoes. This year I found plans for a pretty cool planter very similar to this one:

It seemed to work well but our tomato grew very tall and spindly. I’m convinced it was due inadequate sunlight in the area we chose to place the planter. We tried to keep an eye on the amount of sunlight in different areas of our yard but found it difficult to quantify. One area had good sun in the morning but shade in the afternoon and vice-versa in other areas.

I decided I wanted to build an Arduino Sunlight Logger using a light sensor to record the amount of sunlight throughout the day. I planned to place the Logger in the various locations that we would consider placing the plant and recording just how much sunlight that spot gets throughout the day.

I’ve uploaded the sketch for my project. You can change the constants to control how the data is collected but as it sets now it records the amount of light once every minute, averaging 5 samples taken at 0.1 second intervals, for about 8 hours before the log fills up. You can increase the size of the log but I did encounter a strange problem where the Arduino would freeze if I made the log too large. It blinks an LED once each time it samples and continuously when the log is full. I left the debug code in that outputs to the serial port. I think you’ll find it useful for testing your circuit. I used a button press to output the log data through the serial port. I then cut and paste it into a Google spreadsheet. The attached image is from my very first test. You’ll want to be careful to not use the IDE serial monitor as it will reset the Arduino causing you to lose any data that was collected. A friendly forum member suggested:

which proved very useful for me. This “serial monitor” has a lot of handy features besides not resetting the Arduino when it connects to the serial port.

I put the Arduino in a box to protect it from the weather and cut an aperture (hole in the box) for the photo-resistor to poke out of. I think this saturated the sensor since it was already in the shade when I set it outside and I still got pretty high readings (1023 is the theoretical max). For my next test I plan to recess the photo-resistor a little but not too much since I don’t want the angle of the sun to greatly impact the readings as it would if the photo-resistor was too far below the aperture.

If you found this fun or interesting please make a small donation to my PayPal account at I have many more Arduino projects in mind and appreciate your support.

LightMeterLogger.ino (2.94 KB)

chart_1 (1).png