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

ESP32-Based Infrared Thermometer with I2C LCD Display

View and Edit Project In Cirkit DesignerImage of ESP32-Based Infrared Thermometer with I2C LCD Display

Circuit Documentation

Summary

This circuit is designed around the ESP32 microcontroller and includes a variety of components to demonstrate a simple infrared thermometer with an LCD display. The ESP32 reads temperature data from an MLX90614 infrared temperature sensor and displays the temperature on a 16x2 I2C LCD. A tactile switch is used to trigger the temperature measurement, and an LED indicates when the measurement is taking place. The circuit is powered by an 18650 Li-Ion battery, and resistors are used for LED current limiting and pull-up for the tactile switch.

Component List

ESP32

MLX90614 Infrared Temperature Sensor

18650 Li-Ion Battery

Resistor (10k Ohms)

Tactile Switch Buttons - 12mm Square

LED: Two Pin (Red)

Resistor (220 Ohms)

16x2 I2C LCD

Wiring Details

ESP32

MLX90614 Infrared Temperature Sensor

18650 Li-Ion Battery

Resistor (10k Ohms)

Tactile Switch Buttons - 12mm Square

LED: Two Pin (Red)

Resistor (220 Ohms)

16x2 I2C LCD

Documented Code

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

// Pin Definitions
#define BUTTON_PIN 13    // Pin where the button is connected
#define LED_PIN 14       // Pin where the LED is connected

// Create an instance of the MLX90614 sensor
Adafruit_MLX90614 mlx = Adafruit_MLX90614();

// Create an instance of the LCD with new SDA and SCL pins
LiquidCrystal_I2C lcd(0x27, 16, 2);  // LCD address 0x27, 16x2 display

void setup() {
  Serial.begin(115200);

  // Initialize button pin
  pinMode(BUTTON_PIN, INPUT_PULLUP);  // Button connected to GND
  
  // Initialize LED pin
  pinMode(LED_PIN, OUTPUT);
  
  // Initialize the MLX90614 sensor
  if (!mlx.begin()) {
    Serial.println("Error: MLX90614 not found.");
    while (1);  // Halt the program if sensor is not found
  }
  
  // Initialize the LCD with custom SDA and SCL pins
  Wire.begin(4, 5);  // SDA on GPIO 4, SCL on GPIO 5
  lcd.begin();
  lcd.backlight();  // Turn on the backlight of the LCD
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("Infrared Thermometer");
  delay(2000);  // Show the message for 2 seconds
}

void loop() {
  // Check if the button is pressed
  if (digitalRead(BUTTON_PIN) == LOW) {
    // Turn on the LED to indicate measurement is happening
    digitalWrite(LED_PIN, HIGH);
    
    // Read the temperature from the MLX90614 sensor
    double temp = mlx.readObjectTempC(); // Get object temperature in Celsius
    
    // Print the temperature to Serial Monitor
    Serial.print("Temperature: ");
    Serial.print(temp);
    Serial.println(" °C");
    
    // Display temperature on the LCD
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("Temp: ");
    lcd.print(temp);
    lcd.print(" C");
    
    delay(1000);  // Wait 1 second between measurements
    
    // Turn off the LED once the measurement is done
    digitalWrite(LED_PIN, LOW);
  }
}

This code is designed to run on the ESP32 microcontroller. It initializes the MLX90614 sensor and the 16x2 I2C LCD, reads the temperature when the button is pressed, and displays it both on the Serial Monitor and the LCD. The LED is turned on during the measurement to indicate activity.