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

Arduino UNO-Based Environmental Monitoring System with LCD Display and Stepper Motor

View and Edit Project In Cirkit DesignerImage of Arduino UNO-Based Environmental Monitoring System with LCD Display and Stepper Motor

Circuit Documentation

Summary

This circuit integrates an Arduino UNO microcontroller with various sensors and actuators, including a DFRobot Oxygen Sensor, a Bar02 Pressure/Depth Sensor, an LCD Display, a stepper motor, and a potentiometer. The Arduino UNO reads data from the sensors, controls the stepper motor, and displays information on the LCD. The circuit is powered by a 9V battery.

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. DFRobot Oxygen Sensor

    • Description: Sensor for measuring oxygen levels.
    • Pins: Pin 1, Pin 2, Pin 3, Pin 4
  3. LCD Display (16 pin)

    • Description: 16x2 character LCD display.
    • Pins: VSS, VDD, VO, RS, R_W, E, DB0, DB1, DB2, DB3, DB4, DB5, DB6, DB7, A, K
  4. Stepper Motor

    • Description: Stepper motor for precise control of rotation.
    • Pins: IN1, IN2, IN3, IN4, +, -
  5. 9V Battery

    • Description: Power source for the circuit.
    • Pins: -, +
  6. Potentiometer

    • Description: Variable resistor for adjusting voltage.
    • Pins: GND, Output, VCC
  7. Bar02 Pressure/Depth Sensor

    • Description: Sensor for measuring pressure and depth.
    • Pins: GND, SDA, SCL, VCC

Wiring Details

Arduino UNO

DFRobot Oxygen Sensor

LCD Display (16 pin)

Stepper Motor

9V Battery

Potentiometer

Bar02 Pressure/Depth Sensor

Code Documentation

#include <Wire.h>
#include <LiquidCrystal.h>
#include <Stepper.h>

// Constants for the stepper motor
const int stepsPerRevolution = 200; // Change this value based on your stepper motor's specifications
const int rpm = 16;

// Initialize the stepper library on pins 4 through 7
Stepper myStepper(stepsPerRevolution, 4, 5, 6, 7);

// Initialize the LCD library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 9, 10, 3, 2);

// Pin definitions for sensors
const int oxygenSensorPin = A0;
const int pressureSensorSDA = A4;
const int pressureSensorSCL = A5;

void setup() {
  // Set the speed of the stepper motor
  myStepper.setSpeed(rpm);

  // Initialize the LCD
  lcd.begin(16, 2);
  lcd.print("Initializing...");

  // Initialize I2C communication for the pressure sensor
  Wire.begin();

  // Initialize serial communication for debugging
  Serial.begin(9600);
}

void loop() {
  // Stepper motor control
  myStepper.step(stepsPerRevolution); // Rotate one full revolution
  delay(3750); // Delay to achieve 16 RPM (60 seconds / 16 RPM = 3.75 seconds per revolution)

  // Read oxygen sensor value
  int oxygenValue = analogRead(oxygenSensorPin);

  // Read pressure sensor value
  float pressureValue = readPressureSensor();

  // Display values on the LCD
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("Oxygen: ");
  lcd.print(oxygenValue);
  lcd.setCursor(0, 1);
  lcd.print("Pressure: ");
  lcd.print(pressureValue);

  // Print values to the serial monitor for debugging
  Serial.print("Oxygen: ");
  Serial.print(oxygenValue);
  Serial.print(" Pressure: ");
  Serial.println(pressureValue);

  delay(1000); // Delay before the next loop iteration
}

float readPressureSensor() {
  // Placeholder function to read pressure sensor value
  // Replace this with actual code to read from the Bar02 Pressure/Depth Sensor
  Wire.beginTransmission(pressureSensorSDA);
  Wire.write(0x00); // Replace with actual register address
  Wire.endTransmission();
  Wire.requestFrom(pressureSensorSDA, 2);
  if (Wire.available() == 2) {
    int highByte = Wire.read();
    int lowByte = Wire.read();
    int pressure = (highByte << 8) | lowByte;
    return pressure / 100.0; // Convert to appropriate units
  }
  return 0.0;
}

This code initializes the stepper motor, LCD, and sensors. It reads data from the oxygen and pressure sensors, controls the stepper motor, and displays the sensor values on the LCD and serial monitor. The readPressureSensor function is a placeholder and should be replaced with the actual code to read from the Bar02 Pressure/Depth Sensor.