For our fourth week in the Make It Last Build Series, we’re looking at how to turn our electronic thermometer into a data logger by adding storage capability. You’ll probably want to check out the most recent newsletter for background data, before continuing with this post.
Also, before we forget, we’re getting to the end of our first build. Hopefully, you’ve been following along, and have most of the pieces in place to finish your project. The entry deadline is 11:59pm PDT on November 12, 2010, so make sure to submit your project by then! As a reminder, you don’t need to purchase anything or build our sample project to be eligible- you just need to build any device that runs on batteries and can collect some form of environmental data. See the official rules for specifics on all this and what prizes you can win.
Finally, If you have any questions about this project, or ideas for it you’d like to share, head on over to the MAKE Forums topic and sound off. Now, to build our data logger!
Data logger schematic
Here is the schematic for the data logger. To make it a bit easier to understand, I’ve broken it up into five sections — the microcontroller (components that are required to get the microcontroller running), programmer (the port used to connect a PIC programmer), sensor (for our example, a thermometer), serial port (header to connect an FTDI cable), and data storage (the EEPROM memory chip and related parts). Circuit schematics can be confusing to look at, so a good strategy is to try and break them into smaller pieces. This can also be helpful when looking at the actual circuits — can you identify which components on your breadboard correspond to each of the above sections? Your circuit should already have the first four sections, or everything except the data storage portion.
Step 0: Collect supplies
- Completed ‘thermometer’ project
- Microchip 24AA1025 EEPROM memory
- 2x10k resistor (100k is fine)
- Breadboard jumper wires
- 2xAA battery holder and batteries
Step 1: Place the EEPROM on the board
Place the EEPROM chip in the breadboard, to the right of the microcontroller. After it is seated, connect the power and ground wires as shown above. Pin 8 should be connected to power, and Pin 5 to Ground.
Step 2: Configure the EEPROM using jumper wires
Next, we need to add some wires to tell the EEPROM how to behave. First off, we need to configure the serial address that the chip will respond to. When the microcontroller wants to read or write from the memory, it first has to send the address of the chip over the i2c serial line. By adding an external way of configuring the address that the device responds to, the designers made it possible to hook up and use multiple EEPROM chips at the same time, without them conflicting with each other. We only have one chip, so let’s configure it to respond to Address 7 by connecting wires from EEPROM Pins 1, 2, and 3 to power.
Next, we need to tell the chip to allow both reads and writes to the chip. To do this, run a wire from the WP pin (Pin 7 on the EEPROM) to Ground.
Step 3: Wire up the i2c bus between the processor and memory
The EEPROM chip communicates with the microcontroller over an i2c serial bus. The bus uses two wires (clock and data) to pass messages back and forth between the two devices. Hook up the clock line by connecting microcontroller Pin 14 with EEPROM Pin 6, and the data line by connecting microcontroller Pin 15 with EEPROM Pin 5. The other thing we’ll need to do is add pull-up resistors from both of these lines to power. These are necessary because devices on the i2c bus use open collector outputs, which help prevent issues if both the EEPROM and microcontroller were to send data out over the serial line at the same time.
Note: Some microcontrollers have pull-up resistors built-in, so that you don’t need to supply external ones. You need them for the 18lf25k22, though!
Step 4: Hook up the serial port
Now, we need to add a wire to allow the computer to send serial data to the PIC. Connect Pin 18 on the microcontroller to Pin 4 on the serial header.
Note: In the thermometer project build, I showed an optional resistor between the FTDI serial cable and the PIC, because I was using a 5V serial converter. I found out how to convert my adapter into a 3.3V version, so I removed the resistor for this build.
Step 5: Connect the batteries
Finally, connect up the battery pack! Wire the positive lead (red) of the pack to the Power rail, and the negative lead (black) to Ground. A battery pack with an on/off switch will work best, since you will want to be sure it is disconnected while using your programming cable.
Step 6: Test out the data logger
Thats all for the hardware modifications. The final portion is to modify the software to use the EEPROM memory for logging purposes. Grab the
, then use MPLAB to program it onto your board. For the example project, we have implemented a simple serial protocol to control the data logger. The commands are:
- m: Measure the temperature, and return the value immediately
- b: Begin logging
- e: End logging
- d: Dump logged data
- r: Reset the logger).
To test that everything is working, fire up your serial program (as in the last example), and type the letter “m.” You should get back a response like this:
The current temperature is: 68
If that worked, you are all set to go. Unplug the PIC programmer, turn on the battery, and type ‘b’ to begin logging. At this point, you can disconnect the data logger from your FTDI cable, and set it somewhere for a while to gather temperature data. By default, it grabs the temperature every 10 seconds, but you can change this by modifying the value of the variable ‘logInterval’ in the source code.
Let it collect data for a while (a few minutes, or a few hours), then plug it back into the serial cable, type ‘e’ in your terminal window to stop data collection, then type ‘d’ to get the data. You should get a long list of temperature samples, which you can cut and paste into a spreadsheet program to make a graph. Here is one I took, where I placed my data logger in the fridge, then next to a kettle of water, then back in the freezer before leaving it on my desk while I made tea:
That’s all for now. Next week, we’ll make the project energy-efficient by configuring the processor to shut down between measurements, work on making the measurements a bit more precise, and make a simple GUI to display the collected data using Processing.