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

Arduino UNO and ESP32 Based Temperature Monitoring and Access Control System

View and Edit Project In Cirkit DesignerImage of Arduino UNO and ESP32 Based Temperature Monitoring and Access Control System

Circuit Documentation

Summary of the Circuit

This circuit integrates an Arduino UNO and an ESP32 microcontroller with various peripherals including an MLX90614 infrared temperature sensor, an OLED display, a buzzer, a relay module, and two LEDs with resistors. The Arduino UNO is responsible for controlling the relay, buzzer, and LEDs based on data received from the ESP32, which reads temperature data from the MLX90614 sensor and displays it on the OLED screen. The ESP32 also communicates temperature readings to the Arduino UNO for further processing and action.

Component List

Arduino UNO

ESP32

MLX90614

5V Battery

OLED Display 2.42"

Buzzer

Relay Module

LED: Two Pin (Red)

LED: Two Pin (Green)

Resistor (200 Ohms)

Wiring Details

Arduino UNO

ESP32

MLX90614

5V Battery

OLED Display 2.42"

Buzzer

Relay Module

LED: Two Pin (Red)

LED: Two Pin (Green)

Resistor (200 Ohms)

Documented Code

Arduino UNO Code

// Arduino UNO Code

#include <Wire.h>
#include <Adafruit_MLX90614.h>
#include <Adafruit_SSD1306.h>

#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
#define OLED_RESET    -1
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);

Adafruit_MLX90614 mlx = Adafruit_MLX90614();

const int buzzerPin = 3;
const int relayPin = 4;
const int redLEDPin = 7;
const int greenLEDPin = 8;

void setup() {
  Serial.begin(115200); // Start serial communication at 115200 baud rate
  pinMode(buzzerPin, OUTPUT);
  pinMode(relayPin, OUTPUT);
  pinMode(redLEDPin, OUTPUT);
  pinMode(greenLEDPin, OUTPUT);

  if(!display.begin(SSD1306_I2C_ADDRESS, OLED_RESET)) {
    Serial.println(F("SSD1306 allocation failed"));
    for(;;);
  }
  display.display();
  delay(2000);
  display.clearDisplay();

  mlx.begin();
}

void loop() {
  // Check if there is incoming data from the ESP32
  if (Serial.available()) {
    String data = Serial.readStringUntil('\n'); // Read the incoming string until a newline character

    // Check if the received data contains "Face Recognized"
    if (data.indexOf("Face Recognized") >= 0) {
      digitalWrite(redLEDPin, HIGH); // Turn on the red LED if a face is recognized
      digitalWrite(greenLEDPin, LOW); // Turn off the green LED
      digitalWrite(relayPin, HIGH); // Activate the relay
      tone(buzzerPin, 1000); // Turn on the buzzer
    } else {
      digitalWrite(redLEDPin, LOW); // Turn off the red LED
      digitalWrite(greenLEDPin, HIGH); // Turn on the green LED
      digitalWrite(relayPin, LOW); // Deactivate the relay
      noTone(buzzerPin); // Turn off the buzzer
    }
  }

  // Read temperature from the mlx90614 sensor
  double ambientTemp = mlx.readAmbientTempC();
  double objectTemp = mlx.readObjectTempC();

  // Display temperature on the OLED display
  display.clearDisplay();
  display.setTextSize(1);
  display.setTextColor(SSD1306_WHITE);
  display.setCursor(0, 0);
  display.print("Ambient Temp: ");
  display.print(ambientTemp);
  display.println(" C");
  display.print("Object Temp: ");
  display.print(objectTemp);
  display.println(" C");
  display.display();

  delay(1000); // Update every second
}

ESP32 Code

// ESP32 Code

#include <Wire.h>
#include <Adafruit_MLX90614.h>
#include <Adafruit_SSD1306.h>

#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
#define OLED_RESET    -1
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);

Adafruit_MLX90614 mlx = Adafruit_MLX90614();

void setup() {
  Serial.begin(115200); // Start serial communication at 115200 baud rate
  Wire.begin();

  if(!display.begin(SSD1306_I2C_ADDRESS, OLED_RESET)) {
    Serial.println(F("SSD1306 allocation failed"));
    for(;;);
  }
  display.display();
  delay(2000);
  display.clearDisplay();

  mlx.begin();
}

void loop() {
  // Read temperature from the mlx90614 sensor
  double ambientTemp = mlx.readAmbientTempC();
  double objectTemp = mlx.readObjectTempC();

  // Send temperature data to Arduino UNO
  Serial.print("Ambient Temp: ");
  Serial.print(ambientTemp);
  Serial.print(" C, Object Temp: ");
  Serial.print(objectTemp);
  Serial.println(" C");

  // Display temperature on the OLED display
  display.clearDisplay();
  display.setTextSize(1);
  display.setTextColor(SSD1306_WHITE);
  display.setCursor(0, 0);
  display.print("Ambient Temp: ");
  display.print(ambientTemp);
  display.println(" C");
  display.print("Object Temp: ");
  display.print(objectTemp);
  display.println(" C");
  display.display();

  delay(1000); // Update every second
}

This concludes the documentation for the circuit, including a summary, component descriptions, wiring details, and documented code for the microcontrollers.