Datalogger 1 – Arduino I2C

TOC:

  1. Chapter 0 – Introduction
  2. Chapter 1 – Arduino I2C
  3. Chapter 2 – Continuous EEPROM Addressing (digression)
  4. Chapter 3 – Update and Sleep Design
  5. Chapter 4 – Clock Design and Sleep Investigation
  6. Chapter 5 – Gallery
  7. Chapter 6 – Results
  8. Chapter 7 – Final Report
  9. Chapter 8 – Followup 1

Status Update

So I got the initial Boarduino + TC74 + 24AA1025 circuit set up (I still need to make a breakout for the SOIC-16W DS3231M) on a breadboard, and I have the software working.  I’ll describe it, but first a few lessons I learned.

First, I learned I have to be more careful and have good lighting, because an early version of the circuit on the breadboard had some kind of short around the EEPROM, which cooked my 24AA1025 chip (I think, it got really hot, and wouldn’t respond on the I2C bus any longer) and melted part of my breadboard <insert photo here>.  I have 3 chips left, though, so unless I destroy another one I should be able to complete the project.

The second thing I learned was the importance of reading the datasheet and not always trusting libraries that provide a high-level abstraction of the underlying behavior.  I discovered (along with many others, as it turns out, according to this posted issue: https://code.google.com/p/arduino/issues/detail?id=28 ) some deficiencies in the default Arduino I2C library.  Many I2C devices, including my EEPROM and Temp sensor (and probably my RTC), require specific sequences for random reads, e.g., send the device ID with a WRITE command, send the address or command (could be multiple bytes, as is the case with the EEPROM, or a single byte, like for the TC74), and then send the device ID again with a READ command, to initiate the read, without sending a STOP command between the write and the read.  I could find no mechanism in the default “Wire.h” I2C library provided by the Arduino environment.

After a lot of search, and several abortive attempts to modify the library myself to do what I needed, I found this in the Adafruit forums: http://forums.adafruit.com/viewtopic.php?f=25&t=13722 , which describes (and provides) a lighter-weight, lower level I2C interface for Arduino, which worked like a charm.  This library is provided with the GPL license.  I added a few helper functions, so I’ll be releasing my own updates at the end of this project.

With this new TwiMaster I2C library, I was able to match the bus behavior expected by both my EEPROM and my TC74, and successfully read the temperature and stored data in the EEPROM.  I’ll post the code later, if I think of it.

The next step is to set up a serial interface for clearing the EEPROM and downloading the data, once I’ve done that (and added the DS3231M RTC), then I will try and get it going on a more bare-bones ATmega328 configuration, running at the lower voltage, powered by batteries.  Then, on to the PIC!

This entry was posted in Datalogger, Make It Last, Projects. Bookmark the permalink.