The Adafruit Adalogger FeatherWing is a versatile add-on board designed for the Adafruit Feather series of microcontroller boards. It features an SD card slot for data logging, a real-time clock (RTC) for precise timekeeping, and compatibility with various sensors for environmental monitoring. This compact and efficient board is ideal for projects requiring data storage, timestamping, and sensor integration.
The Adalogger FeatherWing connects to the Feather board via its headers. Below is the pin configuration:
Pin | Name | Description |
---|---|---|
1 | 3V | 3.3V power input/output |
2 | GND | Ground connection |
3 | SCL | I2C clock line for RTC communication |
4 | SDA | I2C data line for RTC communication |
5 | MOSI | SPI Master Out Slave In (used for SD card communication) |
6 | MISO | SPI Master In Slave Out (used for SD card communication) |
7 | SCK | SPI clock line (used for SD card communication) |
8 | CS | Chip Select for SD card |
9 | BAT | Connection for CR1220 coin cell battery (RTC backup) |
0x68
. Ensure no other devices on the I2C bus conflict with this address.Below is an example of how to use the Adalogger FeatherWing with an Arduino-compatible Feather board to log data to an SD card and read the RTC.
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <RTClib.h>
#include <SPI.h>
#include <SD.h>
// Initialize RTC and SD card
RTC_DS3231 rtc;
const int chipSelect = 10; // CS pin for SD card
void setup() {
Serial.begin(9600);
while (!Serial); // Wait for Serial Monitor to open
// Initialize RTC
if (!rtc.begin()) {
Serial.println("Couldn't find RTC");
while (1);
}
// Check if RTC lost power and set the time if needed
if (rtc.lostPower()) {
Serial.println("RTC lost power, setting the time!");
rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
}
// Initialize SD card
if (!SD.begin(chipSelect)) {
Serial.println("SD card initialization failed!");
while (1);
}
Serial.println("SD card initialized.");
}
void loop() {
// Get current time from RTC
DateTime now = rtc.now();
// Open a file on the SD card
File dataFile = SD.open("datalog.txt", FILE_WRITE);
// If the file is available, write data to it
if (dataFile) {
dataFile.print("Time: ");
dataFile.print(now.year(), DEC);
dataFile.print('/');
dataFile.print(now.month(), DEC);
dataFile.print('/');
dataFile.print(now.day(), DEC);
dataFile.print(" ");
dataFile.print(now.hour(), DEC);
dataFile.print(':');
dataFile.print(now.minute(), DEC);
dataFile.print(':');
dataFile.println(now.second(), DEC);
dataFile.close(); // Close the file
Serial.println("Data written to SD card.");
} else {
// If the file isn't available, print an error
Serial.println("Error opening datalog.txt");
}
delay(1000); // Wait 1 second before logging again
}
SD Card Not Detected
RTC Not Responding
Data Not Logging
FILE_WRITE
).Incorrect Time
rtc.adjust()
.