Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

Arduino-Based Piezo Sensor Data Logger with SD Card Storage

View and Edit Project In Cirkit DesignerImage of Arduino-Based Piezo Sensor Data Logger with SD Card Storage

Circuit Documentation

Summary

This circuit is designed to capture voltage readings from piezo sensors and store the data on an SD card using Arduino microcontrollers. The circuit includes two Arduino UNOs and one Arduino Nano, each interfaced with a Micro SD Card Module for data logging. Piezo sensors are connected to the Arduinos to detect vibrations and convert them into electrical signals. The circuit also features bridge rectifiers to convert AC signals from the piezo sensors to DC, electrolytic capacitors for voltage smoothing, and resistors for current limiting. The system is powered by 3.7V batteries.

Component List

Microcontrollers

Sensors

Storage Modules

Power Components

Passive Components

Sensor Modules

Wiring Details

Arduino UNO

Piezo Sensor

Micro SD Card Module

Resistor

Bridge Rectifier

Electrolytic Capacitor

3.7V Battery

Arduino Nano

BMP280

Documented Code

Arduino UNO Code (First Instance)

#include <SPI.h>
#include <SD.h>

const int sensorPin = A0; // Analog pin connected to piezo sensor
File myFile;

void setup() {
    Serial.begin(9600);
    // Initialize SD card
    if (!SD.begin(10)) {
        Serial.println("SD card initialization failed!");
        return;
    }
    Serial.println("SD card is ready.");
    
    // Create/Open file
    myFile = SD.open("data.txt", FILE_WRITE);
    if (myFile) {
        myFile.println("Time (s), Voltage (V)"); // Header for data
        myFile.close(); // Close file after writing header
    } else {
        Serial.println("Error opening data.txt");
    }
}

void loop() {
    unsigned long currentTime = millis() / 1000; // Time in seconds
    int sensorValue = analogRead(sensorPin); // Read analog value from sensor
    float voltage = sensorValue * (5.0 / 1023.0); // Convert ADC value to voltage

    // Open file for writing
    myFile = SD.open("data.txt", FILE_WRITE);
    if (myFile) {
        myFile.print(currentTime); // Print time in seconds
        myFile.print(", ");
        myFile.println(voltage); // Print voltage in volts
        myFile.close(); // Close file after writing data
    } else {
        Serial.println("Error opening data.txt");
    }

    delay(100); // Delay for 100 ms (10 readings per second)
}

Arduino UNO Code (Second Instance)

void setup() {
  // put your setup code here, to run once:

}

void loop() {
  // put your main code here, to run repeatedly:

}

Arduino Nano Code

/*
 * This Arduino Sketch reads voltage data from a piezo sensor and stores it
 * on an SD card at a rate of 10 readings per second. The piezoelectricity
 * generated is stored in a connected battery.
 */

#include <SPI.h>
#include <SD.h>

const int sensorPin = A0; // Analog pin connected to piezo sensor
File myFile;

void setup() {
    Serial.begin(9600);
    // Initialize SD card
    if (!SD.begin(10)) {
        Serial.println("SD card initialization failed!");
        return;
    }
    Serial.println("SD card is ready.");
    
    // Create/Open file
    myFile = SD.open("data.txt", FILE_WRITE);
    if (myFile) {
        myFile.println("Time (s), Voltage (V)"); // Header for data
        myFile.close(); // Close file after writing header
    } else {
        Serial.println("Error opening data.txt");
    }
}

void loop() {
    unsigned long currentTime = millis() / 1000; // Time in seconds
    int sensorValue = analogRead(sensorPin); // Read analog value from sensor
    float voltage = sensorValue * (5.0 / 1023.0); // Convert ADC value to voltage

    // Open file for writing
    myFile = SD.open("data.txt", FILE_WRITE);
    if (myFile) {
        myFile.print(currentTime); // Print time in seconds
        myFile.print(", ");
        myFile.println(voltage); // Print voltage in volts
        myFile.close(); // Close file after writing data
    } else {
        Serial.println("Error opening data.txt");
    }

    delay(100); // Delay for 100 ms (10 readings per second)
}

This concludes the documentation for the provided circuit design and embedded code.