Introduction: ESP32 and Infrared Temperature Sensor MLX90614
During pandemic situation, very useful is infrared thermometer, which detect temperature without touching object - non contact thermometer. Also for electronics is suitable sensor.
Step 1: BOM
For testing you will need:
1. ESP32, I use devkit v1.
2. MLX90614 sensor
3. breadboard
4. 4x dupont cables
Step 2: Wiring
As sensor use I2C communication, wiring is simple:
MLX90614 - ESP32
VIN - 3.3V (never connect to 5V, because ESP32 use 3.3V logic!)
GND - GND
SCL - GPIO 22 (marked as D22 on board)
SDA - GPIO 21 (marked as D21 on board)
Step 3: Code
You will need adafruit library, which you can simple find in library manager in Arduino IDE.
Then you can open example (mlxtest). You can get temperature of object and also ambient temperature. Both temperature values can be set in Celsius or Farenheit.
#include <wire.h><Wire.h><br>#include <adafruit_mlx90614.h></adafruit_mlx90614.h></wire.h><Adafruit_MLX90614.h> Adafruit_MLX90614 mlx = Adafruit_MLX90614(); void setup() { Serial.begin(9600); Serial.println("Adafruit MLX90614 test"); mlx.begin(); } void loop() { Serial.print("Ambient = "); Serial.print(mlx.readAmbientTempC()); Serial.print("*C\tObject = "); Serial.print(mlx.readObjectTempC()); Serial.println("*C"); Serial.print("Ambient = "); Serial.print(mlx.readAmbientTempF()); Serial.print("*F\tObject = "); Serial.print(mlx.readObjectTempF()); Serial.println("*F"); Serial.println(); delay(500); }
Step 4: Testing
Sensor is good for measure electronics as resistors or chips. Testing temperature of human body is questionable, as temperature depend on distance sensor from object.