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.

Circuit diagram
Circuit diagram of voltage divider
Calculation
Calculation for voltage divider

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

CIRCUIT CONNECTION
Circuit connection on 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

CONNECTING
Connecting to our microcontroller using Bluetooth
Successful connection
Successful connection
Successful connection
Sending a message to start logging data
stop message
Sending a message to stop logging data

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.

Serial Monitor Reading
Serial Monitor Reading
datalog txt
Data written to SD card
status ON
Displaying battery voltage and data logging status on the OLED
threshold
Displaying a message when battery voltage is below 3.3V threshold

Demo

Video of the functional prototype

Categories:

Updated: