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

Arduino Uno R3 Controlled Environmental Monitoring System with LCD Interface and Touch Sensor Interaction

View and Edit Project In Cirkit DesignerImage of Arduino Uno R3 Controlled Environmental Monitoring System with LCD Interface and Touch Sensor Interaction

Circuit Documentation

Summary

This circuit is designed to interface with various sensors and actuators, including touch sensors, a DHT11 humidity and temperature sensor, LEDs, a buzzer, a relay, and an LCD display. It is controlled by an Arduino Uno R3 microcontroller, which manages input from the sensors and controls the output to the actuators based on the sensor readings and user input. The circuit includes components for user interaction, environmental monitoring, and feedback through visual and auditory means.

Component List

Microcontroller

Sensors

Actuators

Integrated Circuits

Discrete Components

Wiring Details

Arduino Uno R3

Connected to various sensors, actuators, and the 74HC595 shift register for controlling the circuit.

LCD Display (16 pin)

DHT11

Photocell (LDR)

Forms a voltage divider with a 1k Ohm resistor, connected to an analog input for light measurement.

NTC

Forms a voltage divider with a 10k Ohm resistor, connected to an analog input for temperature measurement.

Touch Sensor TTP233

LEDs

Each LED is connected in series with a 220 Ohm resistor to limit current, with the cathode connected to GND and the anode controlled by the Arduino or the 74HC595 shift register.

Buzzer

Connected to a digital pin for sound generation.

12V Relay

74HC595 Shift Register

NPN Transistors (EBC)

Used to switch higher current loads, such as the relay and LEDs, controlled by the Arduino through base resistors.

Power mb V2

Provides regulated power to the circuit components.

Documented Code

Arduino Uno R3 Code

//www.elegoo.com
//2016.12.9
#include <dht_nonblocking.h>
#include <ShiftedLCD.h>
#include <SPI.h>
#include <TimerOne.h>

// Sensors
int tempPin = 0;
int lightPin = 1;

// Display
LiquidCrystal lcd(10); 
int backlightPin = 8;

// Humidity
#define DHT_SENSOR_TYPE DHT_TYPE_11
static const int DHT_SENSOR_PIN = 2;
DHT_nonblocking dht_sensor( DHT_SENSOR_PIN, DHT_SENSOR_TYPE );

// Controller
int latchPin = 0;
int clockPin = 1;
int dataPin = 4;
byte controls = 0;
bool loops = true;
bool justSwitched = true;

// Motors
int motor1Pin = 5;
int motor2Pin = 6;
int motorIncrease = 1;
int currentMotorSpeed = 0;

// BypassDamper
bool bypassActive = 0;
int damperPowerPin = 3;
int damperSwitchPin = 7;

// Buttons: analog port and debounce time
const int fanSpeed1Button = A2;
const int fanSpeed2Button = A3;
const int fanSpeed3Button = A4;
const int bypassButton = A5;
const int debounceDelay = 50; // milliseconds
bool buttonState = false;     // Current state of the button
bool lastButtonState = false; // Previous state of the button

// Light
bool lightState = false;
bool lastLightState = false;

/*
 * Poll for a measurement, keeping the state machine alive.  Returns
 * true if a measurement is available.
 */
static bool measure_environment( float *temperature, float *humidity )
{
  static unsigned long measurement_timestamp = millis( );

  /* Measure once every four seconds. */
  if( millis( ) - measurement_timestamp > 3000ul )
  {
    if( dht_sensor.measure( temperature, humidity ) == true )
    {
      measurement_timestamp = millis( );
      return( true );
    }
  }

  return( false );
}

void setup()
{
  pinMode(backlightPin, OUTPUT);
  digitalWrite(backlightPin, HIGH);

  lcd.begin(16, 2);

  pinMode(DHT_SENSOR_PIN, INPUT);
  pinMode(latchPin, OUTPUT);
  pinMode(dataPin, OUTPUT);
  pinMode(clockPin, OUTPUT);
  pinMode(motor1Pin, OUTPUT);
  pinMode(motor2Pin, OUTPUT);
  pinMode(fanSpeed1Button, INPUT);
  pinMode(fanSpeed2Button, INPUT);
  pinMode(fanSpeed3Button, INPUT);
  pinMode(bypassButton, INPUT);
  pinMode(damperSwitchPin, OUTPUT);

  pinMode(damperPowerPin, OUTPUT);

  Timer1.initialize(3 * 1000000);  // Set a timer interval of 1 second (1,000,000 microseconds)
  Timer1.attachInterrupt(toggleLoop);

  controls = 0;
  updateShiftRegister();
}
void loop()
{

  // Read data
  // Light
  int lightReading = analogRead(lightPin);
  

  // Buttons
  bool readingFS1B = analogRead(fanSpeed1Button) > 200; // Threshold for detecting press (adjust if necessary)
  bool readingFS2B = analogRead(fanSpeed2Button) > 200; // Threshold for detecting press (adjust if necessary)
  bool readingFS3B = analogRead(fanSpeed3Button) > 200; // Threshold for detecting press (adjust if necessary)
  bool readingBPB = analogRead(bypassButton) > 200; // Threshold for detecting press (adjust if necessary)

  bool readingFS = readingFS1B || readingFS2B || readingFS3B || readingBPB;

  // Debounce logic
  if (readingFS != lastButtonState) {
    delay(debounceDelay);
    if (readingFS != buttonState) {
      
      buttonState = readingFS;

      // If fan speed has changed, set new speed
      if (readingFS1B) {
        setMotorSpeed(1);
      } else if (readingFS2B) {
        setMotorSpeed(2);
      } else if (readingFS3B) {
        setMotorSpeed(3);
      }

      if (readingBPB) {
        bypassActive = !bypassActive;
      }

      // Toggle value on button release
      if (!buttonState) { 

        // Fans Speed LEDs
        bitClear(controls,1);
        bitClear(controls,2);
        bitClear(controls,3);

        if (currentMotorSpeed != 0) {
          bitSet(controls,currentMotorSpeed);
        }
        // Bypass Damper
        bitClear(controls,5);

        if (bypassActive) {
          bitSet