As I showed in the companion post about my experiences during the 2024 total solar eclipse, I made an Arduino-based light and temperature sensor to record the changes during the eclipse. The goal was to record at a regular interval from the start to the end of the eclipse. The set-up involves four main components beyond the Arduino: a photoresistor, a digital temperature sensor, a way to write data to an SD card, and a clock to track the time of day. While the Arduino has some built-in timing capabilities, they always restart at 0 when the power is turned on. A real-time clock has a watch battery so it can keep the time even when turned off.
I have a data recording shield from Adafruit that includes the SD card system and the clock all on one board that fits on top of the Arduino board. That provided two of the components. Light and temperature sensors are pretty common. I settled on using a photoresistor that came with my starter kit and a digital temperature sensor that was part of a suite of sensors.
For the photoresistor, I needed to build a voltage divider so I could measure the change in resistance. Finding the right value for the fixed resistor in the divider can be a challenge and one I largely failed at in the end as you'll see. Measuring the light is one of the earliest lessons in the starter kit so I just copied that code over. Likewise, the temperature sensor has a simple tutorial program that I copied in. Below is the breadboard layout with the data logging shield hiding an Arduino.
Breadboard view of the sensors |
The clock needs to be set whenever a new battery is put in or if it has drifted over time. When I was doing testing of the recorder, I noticed that during some tests, I was getting default times instead of the real time. But other times, it worked fine. I was focused on getting the rest of the system working so I hadn't focused on the time but it was annoying. It was also messing up which file I wrote to as the filename was constructed from the date. Obviously something was wrong with the set-up or the code. It wasn't making sense that it sometimes worked and sometimes didn't. I finally thought to test the battery and the voltage was low so it was about dead. When I was testing and I noticed the wrong time, I would reprogram it but then leave everything plugged in to the computer while doing testing. Since the clock was still powered, it held the time fine. But if I took it off computer power for long, the battery would fail and the clock would reset. A new battery quickly fixed that.
I settled on recording data every five seconds. Each time through the loop, I read the light and temperature values, then I could write them out to the SD card along with the time. I didn't need precise timing for this so I used the built-in delay function instead of checking the time from the clock. I was a little concerned about generating too much data but that wasn't a valid concern. In the end, the file was only 141 KB. And that included some additional debugging fields for each write.
I took the working system outside one sunny day for an extended test. When I looked at the data after about an hour I noticed the temperature climbed pretty steadily getting up to near 100 degrees F on a day with weather only in the low 70's. I suspected the sensor was heating up in the direct sunlight and that was giving the high readings. I needed a way to shade the sensor while still letting air flow around it. A box would trap air and be slow to respond to temperature changes. I also needed to have light reach the photoresistor. I tried an open-weave basket over part of the breadboard but that was hard to cover over the temperature sensor. So I ran the photoresistor wires through the open weave so the light sensor was on top while the basket shaded the temperature sensor. But that turned out to be awkward to connect and disconnect the wires for transport. I settle on an index card folded over like a tent to shade the temperature sensor but leaving the rest of the set up exposed to the sun. That worked OK but might have contributed to the fluctuating temperatures recorded.
The day of the event I set the board out on a side table and put the tent cover on it and let it start recording. All went to plan except for the light calibration. I had played around with the fixed resistor in the voltage divider to try and make sure I covered a good range. Apparently a flashlight is much dimmer than in the sun so my middle point for calibration was much too dim and throughout most of the partial eclipse I was maxing out the sensor. Only right at totality could you see the light drop off. That's a bummer but OK considering this was about my fourth priority on the day.
Below is the full event's data. You can see the light is flat for all except the shortest amount of times as totality hits. The temperature rises as the afternoon progresses and then starts dropping off as more and more of the sun is covered.
In total, it was a fun project even if I ended up deciding to do it late so it was a bit rushed and not as well tested as needed.
No comments:
Post a Comment