Cirkit Designer Logo
Cirkit Designer
Your all-in-one circuit design IDE
Home / 
Project Documentation

Arduino-Based Piezo Sensor Data Logger with SD Card Storage

Image of Arduino-Based Piezo Sensor Data Logger with SD Card Storage

Circuit Documentation

Summary

The circuit in question is designed to interface an Arduino UNO and an Arduino Nano with various sensors and modules, including piezo sensors, a micro SD card module, a BMP280 sensor, and a GPS NEO 6M module. The circuit is powered by 3.7V batteries and includes bridge rectifiers and electrolytic capacitors for power management. The primary function of the circuit is to collect data from the piezo sensors and the BMP280 sensor, log this data to an SD card, and communicate with a GPS module. The Arduino UNO and Nano serve as the central processing units, controlling data acquisition, storage, and communication.

Component List

  • Arduino UNO: A microcontroller board based on the ATmega328P, featuring digital and analog I/O pins.
  • Piezo Sensor: A device that generates an electrical charge in response to mechanical stress.
  • Micro SD Card Module: A module that allows an Arduino board to read and write data to a micro SD card.
  • Resistor (1M Ohm): A passive component used to limit current or divide voltages.
  • Bridge Rectifier: A circuit that converts alternating current (AC) to direct current (DC).
  • Electrolytic Capacitor (1uF and 1F): A capacitor used for filtering and power smoothing in the circuit.
  • 3.7V Battery: A power source for the circuit.
  • Arduino Nano: A small, complete, and breadboard-friendly board based on the ATmega328P.
  • BMP280: A precision sensor that measures barometric pressure and temperature.
  • GPS NEO 6M: A GPS module for location tracking.
  • 1N4007 Rectifier Diode: A diode used for rectification, allowing current to flow in only one direction.

Wiring Details

Arduino UNO

  • 5V: Connected to the VCC pin of the Micro SD Card Module.
  • GND: Common ground with the Resistor, Micro SD Card Module, and Bridge Rectifier.
  • A0: Connected to the "+" pin of a Piezo Sensor for analog signal input.
  • D13: Connected to the SCK pin of the Micro SD Card Module for SPI communication.
  • D12: Connected to the MISO pin of the Micro SD Card Module for SPI communication.
  • D11: Connected to the MOSI pin of the Micro SD Card Module for SPI communication.
  • D10: Connected to the CS pin of the Micro SD Card Module for SPI chip select.

Piezo Sensor

  • +: Connected to the A0 pin of the Arduino UNO and AC input + of the Bridge Rectifier.
  • -: Connected to the Resistor and AC input - of the Bridge Rectifier.

Micro SD Card Module

  • VCC: Powered by the 5V pin of the Arduino UNO.
  • GND: Common ground with the Arduino UNO.
  • CS: Chip select controlled by the D10 pin of the Arduino UNO.
  • SCK: Serial clock connected to the D13 pin of the Arduino UNO.
  • MOSI: Master Out Slave In connected to the D11 pin of the Arduino UNO.
  • MISO: Master In Slave Out connected to the D12 pin of the Arduino UNO.

Resistor (1M Ohm)

  • Pin1: Connected to the GND of the Arduino UNO.
  • Pin2: Connected to the "-" pin of a Piezo Sensor.

Bridge Rectifier

  • AC input +: Connected to the "+" pin of a Piezo Sensor.
  • AC input -: Connected to the "-" pin of a Piezo Sensor.
  • +: Connected to the "+" pin of the Electrolytic Capacitor and the 3.7V Battery.
  • -: Common ground with the Arduino UNO and the 3.7V Battery.

Electrolytic Capacitor

  • +: Connected to the "+" pin of the 3.7V Battery and the "+" output of the Bridge Rectifier.
  • -: Common ground with the Arduino UNO, the 3.7V Battery, and the Micro SD Card Module.

3.7V Battery

  • +: Connected to the "+" pin of the Electrolytic Capacitor and the "+" output of the Bridge Rectifier.
  • -: Common ground with the Arduino UNO, the Electrolytic Capacitor, and the Micro SD Card Module.

Arduino Nano

  • D1/TX: Connected to the RX pin of the GPS NEO 6M module.
  • D0/RX: Connected to the TX pin of the GPS NEO 6M module.
  • GND: Common ground with the GPS NEO 6M module, Micro SD Card Module, BMP280 sensor, and the Bridge Rectifier.
  • 5V: Powers the GPS NEO 6M module, BMP280 sensor, and the Micro SD Card Module.
  • A5: Connected to the SCL pin of the BMP280 sensor.
  • A4: Connected to the SDA pin of the BMP280 sensor.
  • D10: Connected to the CS pin of the Micro SD Card Module.
  • D12/MISO: Connected to the MISO pin of the Micro SD Card Module.
  • D13/SCK: Connected to the SCK pin of the Micro SD Card Module.
  • D11/MOSI: Connected to the MOSI pin of the Micro SD Card Module.

BMP280

  • VCC: Powered by the 5V pin of the Arduino Nano.
  • GND: Common ground with the Arduino Nano.
  • SCL: Connected to the A5 pin of the Arduino Nano for I2C communication.
  • SDA: Connected to the A4 pin of the Arduino Nano for I2C communication.

GPS NEO 6M

  • VCC: Powered by the 5V pin of the Arduino Nano.
  • RX: Connected to the D1/TX pin of the Arduino Nano.
  • TX: Connected to the D0/RX pin of the Arduino Nano.
  • GND: Common ground with the Arduino Nano.

Documented Code

Arduino UNO Code (Instance 1)

#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 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