Infared Touchless Temperature Meter With OLED Display

by RandomProjects in Circuits > Arduino

222 Views, 0 Favorites, 0 Comments

Infared Touchless Temperature Meter With OLED Display

int.jpeg

Hi, In my last Project, I used an LCD screen for it but I got an OLED one now and I Made a small crude Infrared thermometer. It Has a pretty good accuracy and you can change the bitmap picture in starting if you want to!

so let's get right into it!

Supplies

supplies.jpeg

Arduino Nano/Uno/ESP8266 NodeMCU 1.0(ESP12-E)

Few Male to Male Jumper Wires

4 Male to Female jumper wires

SSD1306 128x64 OLED

Push button

BreadBoard

MLX90614 Infrared temp sensor module

(Optional) 18650 Li-ion battery and charge+protecetion Board

(Optional) Locking Push button as a Power button for battery-connected setup

Get the Materials Ready and Wiring

supplies.jpeg

Get your components ready and let's wire them up!

Most of the components are I2C so they are easy to wire

The VCC of the OLED and Sensor goes to 5V pin (or 3.3v in ESP)

The GND Pin of all goes to GND in Arduino or ESP

Push Button is connected Between Digital Pin 4 in ARDUINO(use different gpio in program if using ESP32/ESP8266) and GND Pin

Arduino I2C Wiring:

SDA of BOTH Display and Sensor goes to A4 Pin

SCL of BOTH goes to A5


ESP8266 I2C Wiring:

SDA of Both GOES to D3

SCL of Both GOES to D2


And the Wiring is done!



Programming

So, We come to the less fun part...Programming.

I have done the job for you by painstaking testing, bug fixing, etc.

Also this code is made Specifically for I2C OLED although with mods you can make it work with SPI OLEDs

DON'T MIRROR MY PROGRAM Send a link to this instructables instead.

https://drive.google.com/drive/folders/1mS14PPAmaK-eVc9acbwM6l6BKcEY5T--?usp=sharing\

(or)

//Made By ESPNower
//Don't Reuse Without Asking ME!
//Programming started in Feb 3,2023
//Programming ended in Feb 4,2023
//I2C Display only!
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <Adafruit_MLX90614.h>
#define CAMEO16_GLCD_HEIGHT 64
#define CAMEO16_GLCD_WIDTH 128
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
#define OLED_RESET     -1 // Reset pin # (or -1 if sharing Arduino reset pin)
#define OLED_ADDR 0x3C ///< See datasheet for Address; 0x3D for 128x64, 0x3C for 128x32
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
Adafruit_MLX90614 mlx = Adafruit_MLX90614();
#define BUTTON_PIN 4
#define ON_PIN 6
double temp_amb;
double temp_obj;
long shutdownTimer = 0;
//INTRO Image BitMap Data
static const unsigned char PROGMEM cameo16_glcd_bmp[] =
{  
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x90, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x68, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3d, 0x63, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x94, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6c, 0x6b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x93, 0x94, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6c, 0x69, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x93, 0x16, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x48, 0xe1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0xb7, 0x1e, 0x68, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x48, 0xc1, 0x90, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x95, 0x3e, 0x6c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x6a, 0xc0, 0x90, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x23, 0x15, 0x2f, 0x4f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, 0xe8, 0xd0, 0xb0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x63, 0x17, 0x0e, 0x4b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x98, 0xc8, 0xf1, 0xb4, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 
    0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x47, 0x35, 0x0a, 0x4a, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 
    0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xb8, 0xca, 0xb5, 0x95, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 
    0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x46, 0x25, 0x4a, 0x68, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 
    0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x29, 0xda, 0xa5, 0x97, 0xc8, 0x00, 0x00, 0x00, 0x00, 0x00, 
    0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0xd6, 0x24, 0x18, 0x48, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 
    0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x29, 0x90, 0x07, 0xb5, 0xee, 0x00, 0x00, 0x00, 0x00, 0x00, 
    0x00, 0x00, 0x00, 0x00, 0x00, 0x19, 0x94, 0x68, 0x00, 0x4a, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 
    0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x6b, 0x80, 0x01, 0xa5, 0x6b, 0x00, 0x00, 0x00, 0x00, 0x00, 
    0x00, 0x00, 0x00, 0x00, 0x00, 0x5b, 0x94, 0x40, 0x00, 0x5a, 0x94, 0x80, 0x00, 0x00, 0x00, 0x00, 
    0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x62, 0x80, 0x00, 0x25, 0x4a, 0x40, 0x00, 0x00, 0x00, 0x00, 
    0x00, 0x00, 0x00, 0x00, 0x00, 0xd3, 0x1c, 0x00, 0x00, 0x18, 0xb5, 0x80, 0x00, 0x00, 0x00, 0x00, 
    0x00, 0x00, 0x00, 0x00, 0x01, 0x2c, 0xe0, 0x00, 0x00, 0x07, 0x4a, 0x40, 0x00, 0x00, 0x00, 0x00, 
    0x00, 0x00, 0x00, 0x00, 0x02, 0x92, 0x10, 0x00, 0x00, 0x00, 0x94, 0xb0, 0x00, 0x00, 0x00, 0x00, 
    0x00, 0x00, 0x00, 0x00, 0x01, 0x6d, 0xe0, 0x00, 0x00, 0x03, 0x53, 0x48, 0x00, 0x00, 0x00, 0x00, 
    0x00, 0x00, 0x00, 0x00, 0x06, 0x92, 0x00, 0x00, 0x00, 0x00, 0x6c, 0xa0, 0x00, 0x00, 0x00, 0x00, 
    0x00, 0x00, 0x00, 0x00, 0x09, 0x49, 0x00, 0x00, 0x00, 0x00, 0x12, 0x58, 0x00, 0x00, 0x00, 0x00, 
    0x00, 0x00, 0x00, 0x00, 0x14, 0xb6, 0x00, 0x00, 0x00, 0x40, 0x0d, 0xa6, 0x00, 0x00, 0x00, 0x00, 
    0x00, 0x00, 0x00, 0x00, 0x0b, 0x48, 0x00, 0x01, 0x00, 0x2d, 0xf0, 0x48, 0x00, 0x00, 0x00, 0x00, 
    0x00, 0x00, 0x00, 0x00, 0x34, 0x90, 0x00, 0x00, 0xbf, 0x92, 0x0f, 0xb7, 0x00, 0x00, 0x00, 0x00, 
    0x00, 0x00, 0x00, 0x00, 0x49, 0x60, 0x00, 0x3f, 0x40, 0x69, 0xb0, 0x48, 0x80, 0x00, 0x00, 0x00, 
    0x00, 0x00, 0x00, 0x00, 0xa6, 0x80, 0x03, 0xc0, 0xb7, 0x16, 0x4b, 0x95, 0x00, 0x00, 0x00, 0x00, 
    0x00, 0x00, 0x00, 0x00, 0x59, 0x00, 0x0c, 0x37, 0x08, 0xe9, 0x34, 0x6a, 0xc0, 0x00, 0x00, 0x00, 
    0x00, 0x00, 0x00, 0x01, 0xa4, 0x00, 0x72, 0xc8, 0xf6, 0x16, 0xca, 0x95, 0x20, 0x00, 0x00, 0x00, 
    0x00, 0x00, 0x00, 0x02, 0x58, 0x01, 0x8d, 0x22, 0x09, 0xd1, 0x35, 0x4a, 0xc0, 0x00, 0x00, 0x00, 
    0x00, 0x00, 0x00, 0x05, 0x80, 0x04, 0x20, 0x00, 0x00, 0x0c, 0x8a, 0xb4, 0x38, 0x00, 0x00, 0x00, 
    0x00, 0x00, 0x00, 0x02, 0x60, 0x08, 0x00, 0x00, 0x00, 0x00, 0xe9, 0x4b, 0xc0, 0x00, 0x00, 0x00, 
    0x00, 0x00, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x94, 0x1c, 0x00, 0x00, 0x00, 
    0x00, 0x00, 0x00, 0x12, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x69, 0xe2, 0x00, 0x00, 0x00, 
    0x00, 0x00, 0x00, 0x2d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x16, 0x19, 0x00, 0x00, 0x00, 
    0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xa6, 0x00, 0x00, 0x00, 
    0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x51, 0x00, 0x00, 0x00, 
    0x00, 0x00, 0x00, 0x90, 0x00, 0x18, 0x10, 0x85, 0x00, 0xc0, 0x60, 0x00, 0x2e, 0xc0, 0x00, 0x00, 
    0x00, 0x00, 0x00, 0x40, 0x00, 0x1c, 0x18, 0xc7, 0xe1, 0xf0, 0x60, 0x00, 0x02, 0x20, 0x00, 0x00, 
    0x00, 0x00, 0x01, 0x80, 0x00, 0x34, 0x18, 0xc6, 0x31, 0x80, 0xd0, 0x00, 0x01, 0xc0, 0x00, 0x00, 
    0x00, 0x00, 0x02, 0x00, 0x00, 0x36, 0x18, 0xc6, 0x30, 0xe1, 0x98, 0x00, 0x00, 0x30, 0x00, 0x00, 
    0x00, 0x00, 0x04, 0x00, 0x00, 0x7e, 0x18, 0xc6, 0x30, 0x31, 0xf8, 0x00, 0x00, 0x48, 0x00, 0x00, 
    0x00, 0x00, 0x08, 0x00, 0x00, 0x63, 0x1d, 0x87, 0xe1, 0xb3, 0x0c, 0x00, 0x00, 0x04, 0x00, 0x00, 
    0x00, 0x00, 0x00, 0x00, 0x00, 0xc3, 0x07, 0x07, 0x80, 0xe3, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};


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


pinMode(BUTTON_PIN, INPUT_PULLUP);


 
  display.ssd1306_command(SSD1306_DISPLAYON);
mlx.begin();
display.begin(SSD1306_SWITCHCAPVCC, OLED_ADDR);
display.display(); 
Serial.println("initiliazed");
  // init done
 


 
  // Show initial display buffer contents on the screen --
  // the library initializes this with an Adafruit splash screen.
 
  delay(0.1);
display.clearDisplay();
 display.clearDisplay();


  display.drawBitmap(0, 0, cameo16_glcd_bmp, 128, 64, 1);
  display.display();
  delay(3000);
  display.clearDisplay();
  // Clear the buffer.
  display.clearDisplay();
  display.setTextSize(2);
  display.setTextColor(SSD1306_WHITE);
  display.setCursor(35,10);
  display.println("Press \n Button to  Measure");
  display.display();
 
 
}
void loop() {
  
  byte buttonState = digitalRead(BUTTON_PIN);
  if(buttonState == LOW) {
    Serial.println("Button Pressed, Temp Read start!");
  display.clearDisplay();
display.clearDisplay();
 display.setCursor(15,14);
 display.setTextColor(SSD1306_WHITE);
 display.print("Reading.  \nDon't move ");
  display.display();
  display.clearDisplay();
 delay(100);
 display.setCursor(15,14);
 display.print("Reading.. \nDon't move ");
  display.display();
  display.clearDisplay();
 delay(100);
 display.setCursor(15,14);
 display.print("Reading... \nDon't move");
 delay(100);


 display.display();
 delay(50);
  display.clearDisplay();
  // First two numbers in each drawBitmap() call are the top-left pixel
  // coordinate, next three are the logo name, width, height and rotation.
  temp_amb = mlx.readAmbientTempC();
  temp_obj = mlx.readObjectTempC();


 display.clearDisplay();
  //Serial Monitor
  Serial.print("Room Temp = ");
  Serial.println(temp_amb);
  Serial.print("Object temp = ");
  Serial.println(temp_obj);
 
  display.clearDisplay();
  display.setCursor(25,10);  
  display.setTextSize(1);
  display.setTextColor(WHITE);
  display.println(" Temperature");
  display.setCursor(25,30);
  display.setTextSize(2);
  display.print(temp_obj);
  display.print((char)247);
  display.print("C");
  display.display();
 delay(2000);
 
  }
else { display.clearDisplay();
  display.setTextSize(2);
  display.setTextColor(SSD1306_WHITE);
  display.setCursor(35,10);
  display.println("Press \n Button to  Measure");
  display.display();
  display.clearDisplay();
 }
}

How to Use

int.jpeg

After Uploading the Program, Turn it on, Point the Infrared sensor at something, and Push the button, and it will show its temperature of it quickly!

Working Principle

Every hot object emits infrared rays, by counting the number of rays emitted by an object, we can find it's temperature.

Customization

Well, After you are bored of using it with my Secret Space Agency Logo, You can Get a Bitmap image, Size it to 128x64, and laterally flip the image, then use this Program Called LCD Image Converter, Adafruit has a seperate tutorial on how to use it and make a cool necklace that shows images!

https://learn.adafruit.com/steampunk-cameo-necklace/bitmaps-and-code

Then, If you are an American and want it in Fahrenheit, Change these lines in the code

Celsius: Fahrenheit:

  temp_amb = mlx.readAmbientTempC();


temp_amb = mlx.readAmbientTempF();

temp_obj = mlx.readObjectTempC();

display.print("C");  temp_obj = mlx.readObjectTempF();

 display.print("F");

After changing these lines to F in some places instead of C, Upload the Program and that's it!

Also, you can add a LI Ion Battery with a Charge, Protect, Boost board and hook it up to the Arduino, I used a Latching Push Button you can see in the intro pics and supplies pic.

Furthermore, you can add an aligning laser, Put this stuff in a box, sell it, and make some cash!

Also, this thing works to even measure sub-ambient temps!


 

Conclusion

This Project was a fun one, for me and YOU! Also if you want to look forward to the Space Agency, Just leave a comment ill ask my staff and maybe you can be a part of the Aeronautical UNIVERSE Delving Space Agency (AUDSA) :-)

Anyways Spoiler alert, I am Gonna Make a Revised version of the Music Player but Smaller and cuter.

Bye, see you later!