now: the Status register; the Bit Rate register; the Control
register; and the Data register. We’ll look at these in more
detail once we get coding.
Laying Components
on the Breadboard
Figures 5 and 6 show the schematic and partial build
for our project — far more complex than our first five
projects! I’ve excluded the components needed to get the
microcontroller working on a breadboard (as in the past
articles) in order to allow us to focus more easily on these
specific components. Grab your datasheets and let’s
quickly run through how they’re connected!
U2: 24LC128
This is the EEPROM chip: Microchip’s 24LC128 (refer
to Resources for a link to the datasheet). It has 128 kilobits
of storage, and operates between 2.5V and 5.5V. It’s
available in various packages including a DIP (so is
breadboard friendly).
Taking a look at the connections, you’ll immediately
notice that the SDA and SCL lines have 10K pull-up
resistors — we mentioned these pull-ups earlier. These pins
are connected to pins 27 and 28 on the ATmega328P —
the microcontroller’s own SDA and SCL lines.
Pin 7, WP, is tied to GND — this is the write-protect
pin, and is disabled when connected to GND. I once
spent hours troubleshooting a project, only to find that I’d
misread the datasheet and connected the write-protect pin
to VCC instead of VSS (GND).
Finally, there are three pins labelled A0 to A2. This is a
nice touch, and enables you to set the I2C address for the
chip. Remember that the I2C protocol requires you to
specify which component you’re talking to by using its
address. These pins allow you to connect more than one
24LC128 chip by giving each their own address. The base
address for the 24LC128 is
“1010xyz” where x is the value on
pin A2, y is A1, and z is A0 (refer
to the datasheet for more details;
“Section 5.0: Device Addressing”).
In our project, I’ve connected all
three pins to VCC, so the address
is 1010111. Remember, it’s only
seven bits in length, as the eighth
bit is the read(1)/write(0) bit.
U3: MCP79400
This is the RTC chip:
Microchip’s MCP79400 (see
Resources). Apart from the basic
timekeeping (date and time), it
also has a backup battery and two
alarms. I haven’t included the
backup battery on the schematic
— opting for a basic configuration
— but once you’ve mastered this
project, it’ll be easy for you to
include it. The one feature I really
like about the MCP79400 is the
wide voltage range it can operate
over: from 1.8V up to 5.5V. It
56 September 2015
Figure 4: The I2C registers used in our project.
Figure 5:
Temperature
logger schematic.