Devices & Components
Arduino Uno Rev3
2S LiPo Battery (7.4V) or External Power Supply
Jumper-Wires
HC-SR04 ultrasonic sensor
5V Passive Buzzer
16 X 2 LCD display
MLX90614 infrared temperature sensor
Breadboard-
Software & Tools
Webotricks
Project description
Code
Arduino code to read temperature data from the MLX90614 sensor
1#include <Wire.h> 2#include <Adafruit_MLX90614.h> 3#include <NewPing.h> 4 5Adafruit_MLX90614 mlx = Adafruit_MLX90614(); 6#define TRIG_PIN 9 7#define ECHO_PIN 10 8#define BUZZER_PIN 6 9#define MAX_DISTANCE 100 10NewPing sonar(TRIG_PIN, ECHO_PIN, MAX_DISTANCE); 11 12void setup() { 13 Serial.begin(9600); 14 mlx.begin(); 15 pinMode(BUZZER_PIN, OUTPUT); 16} 17 18void loop() { 19 delay(500); 20 int distance = sonar.ping_cm(); 21 22 if (distance > 0 && distance <= 10) { 23 delay(2000); // Allow time for stable reading 24 float temp = mlx.readObjectTempC(); 25 Serial.print("Temperature: "); 26 Serial.print(temp); 27 Serial.println(" °C"); 28 29 if (temp > 30.0) { 30 tone(BUZZER_PIN, 1000, 500); // High temperature alert 31 } else { 32 tone(BUZZER_PIN, 500, 500); // Low temperature alert 33 } 34 } 35}
Comments
Only logged in users can leave comments