Monitor Suhu Non Contact MLX90614 LCD TFT Graphic ILI9341 ESP32
Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana cara membuat sebuah alat yang dapat mendeteksi suhu kemudian data suhu tersebut ditampilkan ke lcd TFT ILI9341 dengan grafiknya. jadi alat ini hanya monitor suhu saja secara non contact atau tidak menyentuh, sehingga sangat bagus untuk kebutuhan industri yang ingin memonitor suhu tanpa harus menyentuh objectnya. untuk koding dan skemanya seperti berikut ini.
a. Skema Rangkaian Alat
R1 - R6 = 2k2 ohm
R7 - R12 = 3k3 ohm
b. Program Arduino IDE
#include <Wire.h>
#include "SPI.h"
#include "Adafruit_GFX.h"
#include "Adafruit_ILI9341.h"
#include <Adafruit_MLX90614.h>
#include <WiFi.h>
Adafruit_MLX90614 mlx = Adafruit_MLX90614();
#define SCREEN_WIDTH 320
#define SCREEN_HEIGHT 350
#define MINOR_GRID tft.color565(100, 100, 255)
#define MAJOR_GRID tft.color565(0, 0, 255)
#define GRID_EDGE tft.color565(255, 0, 0)
#define V_CENTER tft.color565(255, 0, 0)
#define H_CENTER tft.color565(255, 0, 0)
#define TFT_CS 13
#define TFT_DC 14
//#define TFT_LED 5v
#define TFT_RST 12
#define TFT_MOSI 27
#define TFT_CLK 26
#define TFT_MISO 25
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_MOSI, TFT_CLK, TFT_RST, TFT_MISO);
int x=0;
int lastx=0;
int lasty=150;
int x1=0;
int lastx1=0;
int lasty1=0;
int x2=0;
int lastx2=0;
int lasty2=0;
int LastTime=0;
bool BPMTiming=false;
bool BeatComplete=false;
int BPM=0;
#define UpperThreshold 550
#define LowerThreshold 500
int lebar;
int tinggi;
int geser = 0;
float suhubenda;
void setup() {
mlx.begin();
tft.begin();
tft.fillScreen(ILI9341_BLACK);
tft.setTextSize(2);
tft.setRotation(3);
drawGrid();
Serial.begin(9600);
}
void loop()
{
suhubenda = mlx.readObjectTempC();
lebar = tft.width();
tinggi = tft.height();
tft.drawLine(0,115,lebar,115,ILI9341_RED);
if(x > lebar)
{
tft.fillScreen(ILI9341_BLACK);
//tft.fillRect(0,100,320,75,ILI9341_BLACK);
x=0;
lastx=x;
drawGrid();
}
tft.setTextColor(ILI9341_YELLOW,ILI9341_BLACK);
int y = 150 - ( suhubenda / 1 );
tft.drawLine(lastx,lasty,x,y,ILI9341_WHITE);
lasty = y;
lastx = x;
tft.setCursor(5, 10);
tft.setTextColor(ILI9341_YELLOW,ILI9341_BLACK);
tft.print("Suhu: ");
tft.print(suhubenda);
tft.print(" ");
x = x + 3;
x1++;
x2++;
}
void drawGrid()
{
for (int v = 5; v < SCREEN_WIDTH; v += 10)
{
// minor: 5,15,25 etc /
tft.drawFastVLine(v, 0, SCREEN_HEIGHT, MINOR_GRID);
}
for (int h = 5; h < SCREEN_HEIGHT; h += 10)
{
// minor: 5,15,25 etc
tft.drawFastHLine(0, h, SCREEN_HEIGHT, MINOR_GRID);
}
// next major lines, overlapping the minor lines at cross-sections
for (int v = 10; v < SCREEN_WIDTH; v += 10)
{
// main: 0,10,20 etc
tft.drawFastVLine(v, 0, SCREEN_HEIGHT, MAJOR_GRID);
}
for (int h = 10; h < SCREEN_HEIGHT; h += 10)
{
// main: 0,10,20 etc
tft.drawFastHLine(0, h, SCREEN_HEIGHT, MAJOR_GRID);
}
// edge lines
tft.drawFastVLine(0, 0, SCREEN_HEIGHT - 1, GRID_EDGE);
tft.drawFastVLine(SCREEN_WIDTH - 1, 0, SCREEN_HEIGHT - 1, GRID_EDGE);
tft.drawFastHLine(0, 0, SCREEN_WIDTH - 1, GRID_EDGE);
tft.drawFastHLine(0, SCREEN_HEIGHT - 1, SCREEN_HEIGHT - 1, GRID_EDGE);
// center lines
tft.drawFastVLine(SCREEN_WIDTH / 2, 0, SCREEN_HEIGHT, V_CENTER);
//tft.drawFastHLine(0, SCREEN_HEIGHT / 2 - 1, SCREEN_HEIGHT - 1, V_CENTER);
}
c. VIDEO HASILNYA
No comments:
Post a Comment