If you need to log environmental data for an IoT project, indoor climate monitor, or weather station, your first instinct might be to reach for a microSD card module. While SD cards offer gigabytes of storage, they come with significant drawbacks for embedded microcontrollers: they consume substantial power, require heavy file-system libraries that consume memory, and demand complex SPI wiring.
For many projects, logging gigabytes is unnecessary. If your goal is to record temperature and humidity readings every few minutes over days or weeks, a dedicated I2C memory chip is a much cleaner, more reliable, and power-efficient solution.
In this guide, we will build a lightweight environmental data logger using two plug-and-play modules from the PTSolns ecosystem: the I2Connect: AHT20 temperature and humidity sensor and the I2Connect: 2Mbit EEPROM.
Why Choose I2C EEPROM Over an SD Card?
-
Minimal Power Consumption: EEPROMs draw fractions of the current required to initialize and write to flash memory cards.
-
Zero File-System Overhead: No FAT32 or SD card libraries eating up your microcontroller's program memory.
-
Shared 2-Wire Bus: Both the sensor and the memory live on the same I2C lines (SDA and SCL), leaving your other microcontroller GPIO pins completely open.
-
High Reliability: Avoids SD card corruption caused by sudden power cuts during a write cycle.
Hardware Setup: True Plug & Play
The I2Connect Series is designed to eliminate breadboard clutter and the need to solder during prototyping.
1. Daisy-Chaining with Qwiic Cables
Both the AHT20 and the 2Mbit EEPROM feature dual Qwiic-compatible (4-pin, 1.0 mm JST SH) connectors. Because I2C operates on a shared bus architecture, you can simply daisy-chain the modules:
- Connect your microcontroller’s I2C port to the first port on the I2Connect: AHT20.
- Connect a second Qwiic cable from the AHT20's daisy-chain port directly into the I2Connect: EEPROM.

2. Solderless Breadboard Friendly
If you prefer prototyping on a breadboard, each module includes a pre-installed right-angle male header. The right-angle design allows the boards to stand upright when plugged in, ensuring your I2C connections remain accessible without blocking surrounding breadboard tie-points.
3. Voltage Compatibility
Both modules feature built in level-shifting circuitry and are 3.3V and 5V rated. You can safely connect them directly to 5V boards (like the PTSolns Uno R3+) or 3.3V boards (like the Nano Flip or microWatt) without external logic shifters.
Understanding the I2C Addressing
Because both devices share the Serial Data (SDA) and Serial Clock (SCL) lines, the microcontroller talks to each module via its 7-bit I2C address:
| Module | Default I2C Address | Notes |
|---|---|---|
| I2Connect: AHT20 | 0x38 | Factory-calibrated fixed address |
| I2Connect: EEPROM | 0x50 (or configured via solder pads) | 2Mbit (256 KB) non-volatile storage |
When your code requests climate readings, it polls address 0x38. When it is ready to save those measurements, it addresses the EEPROM, ensuring zero communication conflict on the shared bus.
Writing the Software
To make the software side as effortless as the hardware side, you can install both the I2Connect_AHT20 and the I2Connect_EEPROM libraries directly via the Library Manager in the PTSolns IDE or by downloading them from the official PTSolns GitHub repository. Having dedicated libraries means you do not have to write complex, low level I2C transmission code or manual byte-shifting logic.
Step 1: Polling the AHT20
Reading data takes just a few lines of setup:
#include <Wire.h>
#include <PTSolns_I2Connect_AHT20.h>
PTSolns_I2Connect_AHT20 aht20;
void setup() {
Serial.begin(115200);
Wire.begin();
if (!aht20.begin()) {
Serial.println("Error: AHT20 not detected. Check I2C wiring.");
while (1);
}
}
void loop() {
// Trigger a measurement before grabbing the values
if (aht20.readData()) {
float temperature = aht20.getTemperature(); // °C
float humidity = aht20.getHumidity(); // %RH
// Ready to write to EEPROM...
}
delay(60000); // Sample every 60 seconds
}
Step 2: Storing Readings in 2Mbit EEPROM
A 2Mbit EEPROM provides 256 Kilobytes of storage. Each single-precision float (temperature or humidity) occupies 4 bytes.
Saving a combined entry (8 bytes total: 4 bytes for temperature, 4 bytes for humidity) gives you: 256 KB × 1024 bytes/KB ÷ 8 bytes per sample = 32,768 data points.
Storage Capacity: Logging data once every 5 minutes allows you to record continuous environmental data for over 113 days without overwriting memory.
Because we have the official PTSolns library, saving our floating-point data to memory is incredibly straightforward. The library handles the memory alignment and I2C page writes for you:
#include <Wire.h>
#include <PTSolns_I2Connect_EEPROM.h>
PTSolns_I2Connect_EEPROM eeprom;
uint32_t currentAddress = 0; // Using uint32_t to support the full 256KB memory space
void setup() {
Wire.begin();
eeprom.begin(); // Initialize the EEPROM
}
void logData(float temp, float hum) {
// Store the temperature float
eeprom.put(currentAddress, temp);
currentAddress += sizeof(float); // Move address forward by 4 bytes
// Store the humidity float
eeprom.put(currentAddress, hum);
currentAddress += sizeof(float); // Move address forward again
}
Retrieving and Exporting Your Data
Because EEPROM is non-volatile, your data remains safely stored even if the system loses power. To retrieve the recorded logs, you can run an extraction sketch utilizing the library's read functions to easily pull the data back into human-readable floats:
#include <Wire.h>
#include <PTSolns_I2Connect_EEPROM.h>
PTSolns_I2Connect_EEPROM.h;
void setup() {
Serial.begin(115200);
Wire.begin();
eeprom.begin();
uint32_t readAddress = 0;
float storedTemp = 0.0;
float storedHum = 0.0;
// Example: Read the first stored entry
eeprom.get(readAddress, storedTemp);
readAddress += sizeof(float);
eeprom.get(readAddress, storedHum);
Serial.print("Retrieved Data - Temp: ");
Serial.print(storedTemp);
Serial.print("C, Humidity: ");
Serial.print(storedHum);
Serial.println("%");
}
void loop() {
// Empty
}
By using a loop to iterate through your memory addresses and printing the values separated by commas, you can easily copy and paste the Serial Monitor output directly into Microsoft Excel or Google Sheets for analysis and charting.
Summary
Ditching the bulky SD card module in favor of an I2C EEPROM makes environmental data logging significantly more compact, efficient, and robust. With the plug and play I2Connect series and the dedicated PTSolns software libraries, you can build a full logging setup in minutes using only two modules and a shared 4-wire bus.
- Check out the I2Connect: AHT20 Product Page
- Check out the I2Connect: EEPROM Product Page
- View the I2Connect_EEPROM Library on GitHub
- View the I2Connect_AHT20 Library on GitHub
- Download datasheets, 3D STEP models, and code libraries from the PTSolns Documentation Repository