SurtrTech
Published © GPL3+

Contactless Temperature Sensor MLX90614

+ LCD/OLED can be used to measure body temperature or to detect movement... in Celsius and Fahrenheit!

BeginnerProtip1 hour120,241
Contactless Temperature Sensor MLX90614

Things used in this project

Story

Read more

Schematics

With Serial monitor only

With LCD i²c

With OLED

Code

MLX90614_LCD_Celsius.ino

Arduino
This code uses LCD and in Celsius
/* This code works with MLX90614 (GY906) and LCD ic screen
 * It measures both ambient and object temperature in Celsius and display it on the screen
 * Please visit www.surtrtech.com for more details
 */

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

#define I2C_ADDR 0x27 //I2C adress, you should use the code to scan the adress first (0x27) here
#define BACKLIGHT_PIN 3 // Declaring LCD Pins
#define En_pin 2
#define Rw_pin 1
#define Rs_pin 0
#define D4_pin 4
#define D5_pin 5
#define D6_pin 6
#define D7_pin 7

LiquidCrystal_I2C lcd(I2C_ADDR,En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin);
Adafruit_MLX90614 mlx = Adafruit_MLX90614();

void setup() {
  
  mlx.begin();
  lcd.begin (16,2);
  lcd.setBacklightPin(BACKLIGHT_PIN,POSITIVE);
  lcd.setBacklight(HIGH); //Lighting backlight
  lcd.home ();

}

void loop() {
 lcd.setCursor(0,0);
 lcd.print("Ambient ");
 lcd.print(mlx.readAmbientTempC());
 lcd.print(" C");
 
 lcd.setCursor(0,1);
 lcd.print("Target  ");
 lcd.print(mlx.readObjectTempC());
 lcd.print(" C");

 delay(1000);

}

MLX90614_OLED_Fahrenheit.ino

Arduino
This one with OLED and displays in Fahrneheit, you can combine both
/* This code works with MLX90614 (GY906) and OLED screen
 * It measures both ambient and object temperature in Fahrenheit and display it on the screen
 * Please visit www.surtrtech.com for more details
 */

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

#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 32 // OLED display height, in pixels
#define OLED_RESET    -1 // Reset pin # (or -1 if sharing Arduino reset pin)

Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET); //Declaring the display name (display)
Adafruit_MLX90614 mlx = Adafruit_MLX90614();

void setup() {  
  mlx.begin(); 
  display.begin(SSD1306_SWITCHCAPVCC, 0x3C); //Start the OLED display
  display.clearDisplay();
  display.display();

}

void loop() {
  display.clearDisplay();
  
  display.setTextSize(1);                    
  display.setTextColor(WHITE);             
  display.setCursor(0,4);                
  display.println("Ambient"); 
  
  display.setTextSize(2);
  display.setCursor(50,0);
  display.println(mlx.readAmbientTempF(),1);
 
  display.setCursor(110,0);
  display.println("F");
  
  display.setTextSize(1);                    
  display.setTextColor(WHITE);             
  display.setCursor(0,20);                
  display.println("Target"); 
  
  display.setTextSize(2);
  display.setCursor(50,17);
  display.println(mlx.readObjectTempF(),1);
  
  display.setCursor(110,17);
  display.println("F");
  
  display.display();
  
  delay(1000);

}

ML90614 library

Adafruit SSD1306 library

Adafruit GFX library

NewLiquidCrystal Library

Credits

SurtrTech

SurtrTech

9 projects • 207 followers
YT Channel bit.ly/35Ai76l, run by Automation and Electrical Engineer, Electronics amateur, no IT background so you may see wreckage in codes

Comments