I'm using the following to build a temperature logger and, ultimately, controller.
- Adruino UNO and software 1.0.4
- Ethernet Shield with integrated SD card
- Tiny RTC breakout board
- OneWire DS18B20 temperature ICs
- SanDisk 2GB micro SD card
To get everything running, I'm importing the following libraries.
The Arduino reads the sensors and if the temperature has changed, it logs the time and temperature reading to the 2GB micro SD card.
The good news is that when I monitor everything via the USB serial port "Serial Monitor" everything works as expected. I can see the updates via the serial monitor, the code is successfully logging the information to the SD card, and I can poll the device over the Ethernet and retrieve the current temperatures as JSON.
Sample from data stored on the SD card when everything is working and the Arduino is tethered to my computer via a USB cable
Now, the problem I'm having is that when I disconnect the USB cable from the Arduino, all hell breaks loose
. To start with the RTC seems to start returning a spurious result, basically, I get a unix timestamp value of '2212184785' constantly, which isn't even a legal value.
It seems like the Ethernet library, the OneWire/Dallas Tempurature libraries are working, and the SD card library is working, but for some reason the values reported by the RTC are junk.
Here's what on the SD card if I boot the code without being tethered. The Unix Timestamp (first value) and the Date/Time (second value) are completely wrong and do not change from moment to moment.
The JSON from the Ethernet connection also reports this incorrect time, but does export the correct temperature values. And more importantly, shows that the Ethernet Lib continues to work:
I've tried compiling a version of the code with ALL calls to any Serial or Serial related functions commented out. This yields the same result, basically, the RTC doesn't seem to work. (It works if the USB cable is plugged in even though there's no serial connection. It doesn't work once the USB cable is untethered.)
I've got the RTC break out board plugged into the Analog Pins. A5 = SCL, A4 = SDA, A3 = HIGH = 5v power, A2 = LOW = Ground, A1 = BAT = Unused. See attached image.
Any ideas on why untethering from the USB would cause the TinyRTC breakout board and library to start returning crap values?
My suspicion is that it has something to do with the Wire Library and perhaps some interaction with the Ethernet Shield w/integrated SD card. ???
Attached is my code with all the calls to Serial stripped out.
When running the version ~with~ the Serial calls left in, I have free RAM of 563 bytes. (This is when Arduino is attached via USB to computer and all code is working correctly.)