Arduino Based Data Logger | RF Circuits

Saturday, June 25, 2011

Arduino Based Data Logger

Well I thought it was about time I actually finished a project I started (enough to boast about online anyway). I recently bought myself an Arduino and just about every attachment under the sun, and have really been stumped for interesting projects to do with it.

I decided to build myself a makeshift data logger to sample the temperature and brightness of my bedroom during the night. Temperature was the main variable I was looking for, but I thought brightness would let me compare this to when the sun came up, etc.

Hardware used:
  • 1x Arduino Duemilanove
  • 1x Prototyping breadboard
  • 1x Light Dependent Resistor (LDR)
  • 1x Thermistor (RTD)
  • 2x Resistors
  • 2x 1024Kbit EEPROM chips (Microchip 24aa1025)
  • Some jumper wires
  • An LED
Description of Parts:
Arduino
(www.arduino.cc)
"An Arduino is an open source electronics prototyping platform," according to their website. It consists of a circuit board with a processor and memory, some digital and analog inputs and outputs and usually a USB port. You can also get attachments that give them screens, ethernet ports, bluetooth, etc. People have done some pretty awesome things with them, from cat flaps that Twitter whenever their cats come home, to flight controllers for UAVs.

Breadboard
Pretty standard piece of electronic prototyping kit. A breadboard is a plastic board with holes in it that let you plug wires and other discrete electronic components together. I got mine from Maplin Electronics (in the UK), though you can get them at pretty any electrical retailler

Light Dependent Resistor (LDR) and Thermistor (RTD)
In case you're wondering, RTD stands for "Resistance Temperature Detector," and basically means a resistor that changes it's value based on how h ot it is. An LDR works on the same principal (except with light instead of heat). I got these off eBay, though again you can get them from anywhere

EEPROM Chips
EEPROM (Electronically Erasable Programmable Read Only Memory) chips are used to store the data once I've acquired and processed it. The chips I'm using are made by Microchip (the guys who make PIC processors), and communicate over I2C, which only uses two wires from the Arduino (saves on IO). I got mine for free 'cos im a student from Microchip Direct


Building the Circuit:
There's not a lot of point in me including a circuit diagram. If you're familiar at all with the Arduino you'll know it has a bunch of analog voltage inputs. I wired the RTD and LDR up in voltage divider style setups and plugged Vout from each into the an analog input (AN0 and AN1 in my case).


The EEPROM chips were wired up according to their datasheet. Basically this involves plugging each of the 8 pins into either 5V or 0V, except the two used for communications. No other discrete components were used.


Programming:
Now, the really fun part! The ATmega chip on the Arduino is programmed using the AVR C compiler. You can download this, and the programming environment from www.arduino.cc. Programming took me about 6-8 hours to write the program for the processor, and about 1 hour for the program running on my PC to graph the values.

Processor
Besides actually capturing the data every 15s and storing it to the EEPROMs, I had a couple of other requirements for the processor.
  1. I had to be able to calibrate my sensors - i.e. I had to be able to stick the RTD in the fridge with a thermometer, and tell the processor what temperature it was actually at. Similarly while holding it in my hands to keep it warm. The processor then had to translate the raw analog values into actual temperature readings.
  2. I needed to get the data out of the EEPROMs somehow, which meant getting the processor to read the data off the chips and dump it over serial to the PC.
The source code (PDE) file from the Arduino IDE is here.

Graphing Software
I needed a way to show these results. I used Java, and an open source graphing package called JFreeChart. The Java program sends a serial command to the Arduino telling it to send its data, and the Arduino sends a comma separated list of values to the PC, which the Java program then interprets and displays on the graph.

The source code can be found here, though you'll need a whole bunch of JAR files, and some of the Arduino config files. The entire Eclipse workspace folder can be found here.

Results:
The graph above shows the results from leaving my data logger running overnight in my bedroom. You can see the temperature barely drops to about 23'C during the night, even with my windows open. Considering this is Scotland, it's hard to believe. No wonder I'm having trouble sleeping!

No comments:

Post a Comment