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

Arduino UNO-Based Environmental Monitoring System with SD Card Logging and LED Alerts

View and Edit Project In Cirkit DesignerImage of Arduino UNO-Based Environmental Monitoring System with SD Card Logging and LED Alerts

Circuit Documentation

Summary

This circuit is designed to monitor environmental conditions using various sensors and display the data on an LCD screen. It also logs the data to an SD card and provides visual alerts using LEDs. The main components include an Arduino UNO, a temperature sensor (LM35), a current sensor (ACS712), an accelerometer (ADXL345), an SD card module, an LCD display, and three LEDs (green, red, and yellow).

Component List

  1. Arduino UNO

    • Description: Microcontroller board based on the ATmega328P.
    • Pins: UNUSED, IOREF, Reset, 3.3V, 5V, GND, Vin, A0, A1, A2, A3, A4, A5, SCL, SDA, AREF, D13, D12, D11, D10, D9, D8, D7, D6, D5, D4, D3, D2, D1, D0
  2. Temperature Sensor (LM35)

    • Description: Analog temperature sensor.
    • Pins: +Vs, Vout, GND
  3. SD Card Module

    • Description: Module for interfacing with an SD card.
    • Pins: GND, +3.3V, +5V, CS, MOSI, SCK, MISO
  4. 5V Battery

    • Description: Power supply for the circuit.
    • Pins: +, -
  5. ACS712 Current Sensor

    • Description: Current sensor with 5A, 20A, and 30A options.
    • Pins: 1, 2, GND, OUT, VCC
  6. ADXL345

    • Description: 3-axis accelerometer.
    • Pins: GND, VCC, CS, INT1, INT2, SDO, SDA, SCL
  7. LCD 16x2 (Wokwi Compatible)

    • Description: 16x2 character LCD display.
    • Pins: VSS, VDD, V0, RS, RW, E, D0, D1, D2, D3, D4, D5, D6, D7, A, K
  8. LED: Two Pin (green)

    • Description: Green LED.
    • Pins: cathode, anode
  9. LED: Two Pin (red)

    • Description: Red LED.
    • Pins: cathode, anode
  10. LED: Two Pin (yellow)

    • Description: Yellow LED.
    • Pins: cathode, anode
  11. Resistor (220 Ohms)

    • Description: Resistor with 220 Ohms resistance.
    • Pins: pin1, pin2

Wiring Details

Arduino UNO

Temperature Sensor (LM35)

SD Card Module

5V Battery

ACS712 Current Sensor

ADXL345

LCD 16x2 (Wokwi Compatible)

LED: Two Pin (green)

LED: Two Pin (red)

LED: Two Pin (yellow)

Resistor (220 Ohms)

Code Documentation

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

// Pin Definitions
#define LED_RED 3
#define LED_YELLOW 4
#define LED_GREEN 5
#define SD_CS 10
#define CURRENT_SENSOR A0
#define TEMP_SENSOR A1

// Initialize LCD (RS, EN, D4, D5, D6, D7)
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);

// Variables for sensors
float current = 0.0;
float temperature = 0.0;
int16_t accX, accY, accZ;

// SD card setup
File logFile;

// ADXL345 I2C Address
#define ADXL345_ADDR 0x53

void setup() {
  // Begin serial communication
  Serial.begin(9600);

  // Initialize LCD
  lcd.begin(16, 2);
  lcd.print("Initializing...");
  
  // Setup LEDs
  pinMode(LED_RED, OUTPUT);
  pinMode(LED_YELLOW, OUTPUT);
  pinMode(LED_GREEN, OUTPUT);

  // Setup SD Card
  if (!SD.begin(SD_CS)) {
    lcd.clear();
    lcd.print("SD Init Failed");
    while (1);
  }
  lcd.clear();
  lcd.print("SD Init Success");

  // Initialize ADXL345
  Wire.begin();
  setupADXL345();

  delay(1000);
}

void loop() {
  // Read current from ACS712
  current = readCurrent();

  // Read temperature from LM35
  temperature = readTemperature();

  // Read vibration data from ADXL345
  readVibration();

  // Display data on LCD
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("I: ");
  lcd.print(current, 2);
  lcd.print("A T:");
  lcd.print(temperature, 1);
  lcd.print("C");
  
  lcd.setCursor(0, 1);
  lcd.print("X:");