Lab 3 Smart Environmental and Activity Logger
The Smart Environmental and Activity Logger is a portable embedded system designed to monitor and record audio, temperature, motion (IMU), and battery level. It uses an RTC (Real-Time Clock) to timestamp all logged data and stores it on an SD card for future analysis. The system’s status (ON/OFF) is controlled via Bluetooth, and the OLED display shows the real-time battery voltage and system status. To protect the battery, logging automatically stops when the battery voltage drops below a predefined threshold.
Voltage Divider
We have used three resitors for the voltage divider circuit, they were 680Ω, 2.2kΩ, and 10kΩ. 2.2kΩ and 680Ω were connected paralle.680Ω and 10kΩ were in series connection.


The image below shows how we implemented our circuit connection on a bread board.

Data Logging
Reading from pin A0 were used to calculate the battery voltage from the analog-to-digital converter (ADC) and prints the system status on the OLED.
The code snippet given below is the function to calculate battery voltage from the ADC. Our final arduino code can be downloaded from
here.
void getData() {
if (logging) {
// Read the input on analog pin A0:
int sensorValue = analogRead(A0);
// Convert the ADC value to voltage:
float measuredVoltage = sensorValue * (referenceVoltage / 1023.0);
// Account for the voltage divider to get the actual battery voltage:
float batteryVoltage = measuredVoltage * ((R1 + R2) / R2);
if (batteryVoltage > referenceVoltage) {
digitalWrite(ledPin, HIGH); // Turn ON if above threshold
Serial.println("ON");
u8x8.setCursor(0, 2); // (columns, row)
u8x8.print("STATUS ON ");
u8x8.clearLine(3);
u8x8.clearLine(4);
} else {
digitalWrite(ledPin, LOW); // Turn OFF if below threshold
Serial.println("OFF");
u8x8.setCursor(0, 2); // (columns, row)
u8x8.print("STATUS OFF ");
u8x8.setCursor(0, 3); // (columns, row)
u8x8.print("Low Battery:");
u8x8.setCursor(0, 4); // (columns, row)
u8x8.print("Logging Stopped");
return;
}
Bluetooth Connection Setup




Voltage measurement and sensor output
On running our code, connection status and data collection were printed on to the serial monitor. The data collected and stored to the sd card was in Datalog.txt file and it can be dowloded from here.




Demo
Video of the functional prototype