Monitoring Suhu Ds18b20 Realtime Grafik dan Datalogger Webserver ESP32 Penampil DMD P10
Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana cara membuat sebuah alat yang dapat memonitor suhu secara realtime grafik dengan datalogger. alat ini juga bisa dipantu via web browser bisa menggunakan chrome atau mozilla. untuk lebih jelasnya berikut adalah koding dan skemanya.
1. Skema
2. Interface
3. Program ESP32
#include <WiFi.h>
#include <WebServer.h>
#include <OneWire.h>
#include <DallasTemperature.h>
#include <SPI.h>
#include <DMD32.h>
#include "fonts/SystemFont5x7.h"
// =====================================================
// WIFI ACCESS POINT
// =====================================================
const char* ssid = "ESP32-SUHU";
const char* password = "12345678";
WebServer server(80);
// =====================================================
// DS18B20
// =====================================================
#define DS18B20_PIN 13
OneWire oneWire(DS18B20_PIN);
DallasTemperature sensors(&oneWire);
float suhu = 0.0;
// =====================================================
// DMD P10
// =====================================================
#define DISPLAYS_ACROSS 1
#define DISPLAYS_DOWN 1
DMD dmd(
DISPLAYS_ACROSS,
DISPLAYS_DOWN
);
// =====================================================
// TIMER DMD
// =====================================================
hw_timer_t *timer = NULL;
void IRAM_ATTR triggerScan()
{
dmd.scanDisplayBySPI();
}
// =====================================================
// WEB PAGE
// =====================================================
const char webpage[] PROGMEM = R"rawliteral(
<!DOCTYPE html>
<html>
<head>
<meta name="viewport"
content="width=device-width, initial-scale=1">
<title>Monitoring Suhu ESP32</title>
<style>
body {
background:#111;
color:white;
font-family:Arial;
text-align:center;
margin:0;
}
.container {
max-width:900px;
margin:auto;
padding:15px;
}
.card {
background:#222;
padding:20px;
margin-bottom:20px;
border-radius:15px;
}
h1 {
margin-top:5px;
}
.suhu {
font-size:70px;
font-weight:bold;
margin:20px;
}
.status {
font-size:18px;
margin-bottom:10px;
}
.waktu {
font-size:18px;
color:#aaa;
}
canvas {
width:100%;
max-width:850px;
height:400px;
background:#181818;
border-radius:10px;
}
table {
width:100%;
border-collapse:collapse;
margin-top:15px;
}
th {
background:#333;
padding:10px;
}
td {
padding:8px;
border-bottom:1px solid #444;
}
.data {
max-height:300px;
overflow-y:auto;
}
</style>
</head>
<body>
<div class="container">
<!-- ================================================= -->
<!-- NILAI SUHU -->
<!-- ================================================= -->
<div class="card">
<h1>MONITORING SUHU</h1>
<div class="suhu">
<span id="suhu">
--.--
</span>
°C
</div>
<div class="status"
id="status">
Menghubungkan...
</div>
<div class="waktu">
Waktu sekarang:
<span id="waktu">
--
</span>
</div>
</div>
<!-- ================================================= -->
<!-- GRAFIK -->
<!-- ================================================= -->
<div class="card">
<h2>Grafik Suhu Realtime</h2>
<canvas
id="graph"
width="850"
height="400">
</canvas>
</div>
<!-- ================================================= -->
<!-- TABEL DATA -->
<!-- ================================================= -->
<div class="card">
<h2>Data Suhu</h2>
<div class="data">
<table>
<thead>
<tr>
<th>No</th>
<th>Waktu</th>
<th>Suhu</th>
</tr>
</thead>
<tbody id="tabel">
</tbody>
</table>
</div>
</div>
</div>
<script>
// =====================================================
// ARRAY DATA
// =====================================================
let dataSuhu = [];
let dataWaktu = [];
// maksimal 60 data
const maxData = 60;
// =====================================================
// CANVAS
// =====================================================
const canvas =
document.getElementById("graph");
const ctx =
canvas.getContext("2d");
// =====================================================
// AMBIL DATA DARI ESP32
// =====================================================
function updateSuhu()
{
fetch("/suhu")
.then(
response => response.json()
)
.then(
data =>
{
let nilai =
parseFloat(data.suhu);
// -----------------------------------------------------
// TAMPILKAN NILAI
// -----------------------------------------------------
document.getElementById(
"suhu"
).innerHTML =
nilai.toFixed(2);
document.getElementById(
"status"
).innerHTML =
"ESP32 terhubung";
// -----------------------------------------------------
// WAKTU
// -----------------------------------------------------
let sekarang =
new Date();
let jam =
String(
sekarang.getHours()
).padStart(2,'0');
let menit =
String(
sekarang.getMinutes()
).padStart(2,'0');
let detik =
String(
sekarang.getSeconds()
).padStart(2,'0');
let waktu =
jam +
":" +
menit +
":" +
detik;
document.getElementById(
"waktu"
).innerHTML =
waktu;
// -----------------------------------------------------
// SIMPAN DATA
// -----------------------------------------------------
dataSuhu.push(nilai);
dataWaktu.push(waktu);
if (
dataSuhu.length > maxData
)
{
dataSuhu.shift();
dataWaktu.shift();
}
// -----------------------------------------------------
// UPDATE GRAFIK
// -----------------------------------------------------
gambarGrafik();
// -----------------------------------------------------
// UPDATE TABEL
// -----------------------------------------------------
updateTabel();
})
.catch(
error =>
{
document.getElementById(
"status"
).innerHTML =
"ESP32 tidak terhubung";
});
}
// =====================================================
// GRAFIK
// =====================================================
function gambarGrafik()
{
ctx.clearRect(
0,
0,
canvas.width,
canvas.height
);
if (
dataSuhu.length < 1
)
return;
// -----------------------------------------------------
// CARI NILAI MIN/MAX
// -----------------------------------------------------
let min =
Math.min(...dataSuhu);
let max =
Math.max(...dataSuhu);
if (
max - min < 2
)
{
let tengah =
(min + max) / 2;
min =
tengah - 1;
max =
tengah + 1;
}
min -= 0.5;
max += 0.5;
// -----------------------------------------------------
// AREA GRAFIK
// -----------------------------------------------------
let kiri = 60;
let kanan = 20;
let atas = 30;
let bawah = 55;
let lebar =
canvas.width -
kiri -
kanan;
let tinggi =
canvas.height -
atas -
bawah;
// -----------------------------------------------------
// GRID
// -----------------------------------------------------
ctx.strokeStyle =
"#333";
ctx.lineWidth = 1;
for (
let i = 0;
i <= 5;
i++
)
{
let y =
atas +
i *
(tinggi / 5);
ctx.beginPath();
ctx.moveTo(
kiri,
y
);
ctx.lineTo(
canvas.width - kanan,
y
);
ctx.stroke();
}
// -----------------------------------------------------
// LABEL SUHU
// -----------------------------------------------------
ctx.fillStyle =
"#aaa";
ctx.font =
"14px Arial";
for (
let i = 0;
i <= 5;
i++
)
{
let nilai =
max -
i *
((max - min) / 5);
let y =
atas +
i *
(tinggi / 5);
ctx.fillText(
nilai.toFixed(1)
+
" °C",
5,
y + 5
);
}
// -----------------------------------------------------
// GARIS GRAFIK
// -----------------------------------------------------
ctx.strokeStyle =
"#00ff88";
ctx.lineWidth = 3;
ctx.beginPath();
dataSuhu.forEach(
(suhu,index) =>
{
let x;
if (
dataSuhu.length == 1
)
{
x = kiri;
}
else
{
x =
kiri +
index *
(
lebar /
(dataSuhu.length - 1)
);
}
let y =
atas +
(max - suhu) /
(max - min) *
tinggi;
if (
index == 0
)
{
ctx.moveTo(
x,
y
);
}
else
{
ctx.lineTo(
x,
y
);
}
});
ctx.stroke();
// -----------------------------------------------------
// TITIK
// -----------------------------------------------------
ctx.fillStyle =
"#ffffff";
dataSuhu.forEach(
(suhu,index) =>
{
let x;
if (
dataSuhu.length == 1
)
{
x = kiri;
}
else
{
x =
kiri +
index *
(
lebar /
(dataSuhu.length - 1)
);
}
let y =
atas +
(max - suhu) /
(max - min) *
tinggi;
ctx.beginPath();
ctx.arc(
x,
y,
4,
0,
Math.PI * 2
);
ctx.fill();
// ---------------------------------------------------
// NILAI DI TITIK
// ---------------------------------------------------
ctx.fillStyle =
"#fff";
ctx.font =
"12px Arial";
ctx.fillText(
suhu.toFixed(1)
+
"°C",
x - 15,
y - 10
);
});
// -----------------------------------------------------
// SUMBU WAKTU
// -----------------------------------------------------
ctx.fillStyle =
"#aaa";
ctx.font =
"12px Arial";
// tampilkan beberapa label waktu
let jumlahLabel = 6;
for (
let i = 0;
i < jumlahLabel;
i++
)
{
if (
dataWaktu.length == 0
)
break;
let index =
Math.floor(
i *
(dataWaktu.length - 1) /
(jumlahLabel - 1)
);
let x;
if (
dataWaktu.length == 1
)
{
x = kiri;
}
else
{
x =
kiri +
index *
(
lebar /
(dataWaktu.length - 1)
);
}
ctx.fillText(
dataWaktu[index],
x - 20,
canvas.height - 20
);
}
}
// =====================================================
// TABEL
// =====================================================
function updateTabel()
{
let tabel =
document.getElementById(
"tabel"
);
tabel.innerHTML = "";
// tampilkan data terbaru di atas
for (
let i =
dataSuhu.length - 1;
i >= 0;
i--
)
{
let row =
tabel.insertRow();
let no =
row.insertCell(0);
let waktu =
row.insertCell(1);
let suhu =
row.insertCell(2);
no.innerHTML =
dataSuhu.length - i;
waktu.innerHTML =
dataWaktu[i];
suhu.innerHTML =
dataSuhu[i].toFixed(2)
+
" °C";
}
}
// =====================================================
// MULAI
// =====================================================
updateSuhu();
setInterval(
updateSuhu,
1000
);
</script>
</body>
</html>
)rawliteral";
// =====================================================
// WEB ROOT
// =====================================================
void handleRoot()
{
server.send(
200,
"text/html",
webpage
);
}
// =====================================================
// DATA SUHU
// =====================================================
void handleSuhu()
{
String json =
"{\"suhu\":" +
String(suhu,2) +
"}";
server.send(
200,
"application/json",
json
);
}
// =====================================================
// BACA DS18B20
// =====================================================
void bacaSuhu()
{
sensors.requestTemperatures();
float t =
sensors.getTempCByIndex(0);
if (
t != DEVICE_DISCONNECTED_C
)
{
suhu = t;
}
}
// =====================================================
// TAMPILKAN P10
// =====================================================
void tampilP10()
{
char teks[20];
sprintf(
teks,
"%.1f ",
suhu
);
//dmd.clearScreen();
dmd.selectFont(
SystemFont5x7
);
dmd.drawString(
0,
0,
"SUHU",
4,
GRAPHICS_NORMAL
);
dmd.drawString(
0,
9,
teks,
strlen(teks),
GRAPHICS_NORMAL
);
}
// =====================================================
// SETUP
// =====================================================
void setup()
{
Serial.begin(
115200
);
delay(1000);
Serial.println();
Serial.println(
"START ESP32"
);
// =====================================================
// WIFI
// =====================================================
WiFi.mode(
WIFI_AP
);
delay(500);
bool ap =
WiFi.softAP(
ssid,
password
);
if(ap)
{
Serial.println(
"ACCESS POINT BERHASIL"
);
Serial.print(
"SSID : "
);
Serial.println(
ssid
);
Serial.print(
"IP : "
);
Serial.println(
WiFi.softAPIP()
);
}
else
{
Serial.println(
"ACCESS POINT GAGAL"
);
}
// =====================================================
// WEB SERVER
// =====================================================
server.on(
"/",
handleRoot
);
server.on(
"/suhu",
handleSuhu
);
server.begin();
Serial.println(
"WEB SERVER AKTIF"
);
// =====================================================
// DS18B20
// =====================================================
sensors.begin();
Serial.println(
"DS18B20 OK"
);
// =====================================================
// DMD
// =====================================================
//dmd.clearScreen();
dmd.selectFont(
SystemFont5x7
);
// =====================================================
// TIMER DMD
// =====================================================
timer =
timerBegin(
0,
80,
true
);
timerAttachInterrupt(
timer,
&triggerScan,
true
);
timerAlarmWrite(
timer,
300,
true
);
timerAlarmEnable(
timer
);
Serial.println(
"DMD P10 OK"
);
Serial.println();
Serial.println(
"=========================="
);
Serial.println(
"SSID : ESP32-SUHU"
);
Serial.println(
"PASS : 12345678"
);
Serial.println(
"IP : 192.168.4.1"
);
Serial.println(
"=========================="
);
}
// =====================================================
// LOOP
// =====================================================
unsigned long waktuSensor = 0;
void loop()
{
server.handleClient();
if (
millis() - waktuSensor >= 1000
)
{
waktuSensor =
millis();
bacaSuhu();
tampilP10();
Serial.print(
"Suhu: "
);
Serial.print(
suhu,
2
);
Serial.println(
" C"
);
}
}
#include <WebServer.h>
#include <OneWire.h>
#include <DallasTemperature.h>
#include <SPI.h>
#include <DMD32.h>
#include "fonts/SystemFont5x7.h"
// =====================================================
// WIFI ACCESS POINT
// =====================================================
const char* ssid = "ESP32-SUHU";
const char* password = "12345678";
WebServer server(80);
// =====================================================
// DS18B20
// =====================================================
#define DS18B20_PIN 13
OneWire oneWire(DS18B20_PIN);
DallasTemperature sensors(&oneWire);
float suhu = 0.0;
// =====================================================
// DMD P10
// =====================================================
#define DISPLAYS_ACROSS 1
#define DISPLAYS_DOWN 1
DMD dmd(
DISPLAYS_ACROSS,
DISPLAYS_DOWN
);
// =====================================================
// TIMER DMD
// =====================================================
hw_timer_t *timer = NULL;
void IRAM_ATTR triggerScan()
{
dmd.scanDisplayBySPI();
}
// =====================================================
// WEB PAGE
// =====================================================
const char webpage[] PROGMEM = R"rawliteral(
<!DOCTYPE html>
<html>
<head>
<meta name="viewport"
content="width=device-width, initial-scale=1">
<title>Monitoring Suhu ESP32</title>
<style>
body {
background:#111;
color:white;
font-family:Arial;
text-align:center;
margin:0;
}
.container {
max-width:900px;
margin:auto;
padding:15px;
}
.card {
background:#222;
padding:20px;
margin-bottom:20px;
border-radius:15px;
}
h1 {
margin-top:5px;
}
.suhu {
font-size:70px;
font-weight:bold;
margin:20px;
}
.status {
font-size:18px;
margin-bottom:10px;
}
.waktu {
font-size:18px;
color:#aaa;
}
canvas {
width:100%;
max-width:850px;
height:400px;
background:#181818;
border-radius:10px;
}
table {
width:100%;
border-collapse:collapse;
margin-top:15px;
}
th {
background:#333;
padding:10px;
}
td {
padding:8px;
border-bottom:1px solid #444;
}
.data {
max-height:300px;
overflow-y:auto;
}
</style>
</head>
<body>
<div class="container">
<!-- ================================================= -->
<!-- NILAI SUHU -->
<!-- ================================================= -->
<div class="card">
<h1>MONITORING SUHU</h1>
<div class="suhu">
<span id="suhu">
--.--
</span>
°C
</div>
<div class="status"
id="status">
Menghubungkan...
</div>
<div class="waktu">
Waktu sekarang:
<span id="waktu">
--
</span>
</div>
</div>
<!-- ================================================= -->
<!-- GRAFIK -->
<!-- ================================================= -->
<div class="card">
<h2>Grafik Suhu Realtime</h2>
<canvas
id="graph"
width="850"
height="400">
</canvas>
</div>
<!-- ================================================= -->
<!-- TABEL DATA -->
<!-- ================================================= -->
<div class="card">
<h2>Data Suhu</h2>
<div class="data">
<table>
<thead>
<tr>
<th>No</th>
<th>Waktu</th>
<th>Suhu</th>
</tr>
</thead>
<tbody id="tabel">
</tbody>
</table>
</div>
</div>
</div>
<script>
// =====================================================
// ARRAY DATA
// =====================================================
let dataSuhu = [];
let dataWaktu = [];
// maksimal 60 data
const maxData = 60;
// =====================================================
// CANVAS
// =====================================================
const canvas =
document.getElementById("graph");
const ctx =
canvas.getContext("2d");
// =====================================================
// AMBIL DATA DARI ESP32
// =====================================================
function updateSuhu()
{
fetch("/suhu")
.then(
response => response.json()
)
.then(
data =>
{
let nilai =
parseFloat(data.suhu);
// -----------------------------------------------------
// TAMPILKAN NILAI
// -----------------------------------------------------
document.getElementById(
"suhu"
).innerHTML =
nilai.toFixed(2);
document.getElementById(
"status"
).innerHTML =
"ESP32 terhubung";
// -----------------------------------------------------
// WAKTU
// -----------------------------------------------------
let sekarang =
new Date();
let jam =
String(
sekarang.getHours()
).padStart(2,'0');
let menit =
String(
sekarang.getMinutes()
).padStart(2,'0');
let detik =
String(
sekarang.getSeconds()
).padStart(2,'0');
let waktu =
jam +
":" +
menit +
":" +
detik;
document.getElementById(
"waktu"
).innerHTML =
waktu;
// -----------------------------------------------------
// SIMPAN DATA
// -----------------------------------------------------
dataSuhu.push(nilai);
dataWaktu.push(waktu);
if (
dataSuhu.length > maxData
)
{
dataSuhu.shift();
dataWaktu.shift();
}
// -----------------------------------------------------
// UPDATE GRAFIK
// -----------------------------------------------------
gambarGrafik();
// -----------------------------------------------------
// UPDATE TABEL
// -----------------------------------------------------
updateTabel();
})
.catch(
error =>
{
document.getElementById(
"status"
).innerHTML =
"ESP32 tidak terhubung";
});
}
// =====================================================
// GRAFIK
// =====================================================
function gambarGrafik()
{
ctx.clearRect(
0,
0,
canvas.width,
canvas.height
);
if (
dataSuhu.length < 1
)
return;
// -----------------------------------------------------
// CARI NILAI MIN/MAX
// -----------------------------------------------------
let min =
Math.min(...dataSuhu);
let max =
Math.max(...dataSuhu);
if (
max - min < 2
)
{
let tengah =
(min + max) / 2;
min =
tengah - 1;
max =
tengah + 1;
}
min -= 0.5;
max += 0.5;
// -----------------------------------------------------
// AREA GRAFIK
// -----------------------------------------------------
let kiri = 60;
let kanan = 20;
let atas = 30;
let bawah = 55;
let lebar =
canvas.width -
kiri -
kanan;
let tinggi =
canvas.height -
atas -
bawah;
// -----------------------------------------------------
// GRID
// -----------------------------------------------------
ctx.strokeStyle =
"#333";
ctx.lineWidth = 1;
for (
let i = 0;
i <= 5;
i++
)
{
let y =
atas +
i *
(tinggi / 5);
ctx.beginPath();
ctx.moveTo(
kiri,
y
);
ctx.lineTo(
canvas.width - kanan,
y
);
ctx.stroke();
}
// -----------------------------------------------------
// LABEL SUHU
// -----------------------------------------------------
ctx.fillStyle =
"#aaa";
ctx.font =
"14px Arial";
for (
let i = 0;
i <= 5;
i++
)
{
let nilai =
max -
i *
((max - min) / 5);
let y =
atas +
i *
(tinggi / 5);
ctx.fillText(
nilai.toFixed(1)
+
" °C",
5,
y + 5
);
}
// -----------------------------------------------------
// GARIS GRAFIK
// -----------------------------------------------------
ctx.strokeStyle =
"#00ff88";
ctx.lineWidth = 3;
ctx.beginPath();
dataSuhu.forEach(
(suhu,index) =>
{
let x;
if (
dataSuhu.length == 1
)
{
x = kiri;
}
else
{
x =
kiri +
index *
(
lebar /
(dataSuhu.length - 1)
);
}
let y =
atas +
(max - suhu) /
(max - min) *
tinggi;
if (
index == 0
)
{
ctx.moveTo(
x,
y
);
}
else
{
ctx.lineTo(
x,
y
);
}
});
ctx.stroke();
// -----------------------------------------------------
// TITIK
// -----------------------------------------------------
ctx.fillStyle =
"#ffffff";
dataSuhu.forEach(
(suhu,index) =>
{
let x;
if (
dataSuhu.length == 1
)
{
x = kiri;
}
else
{
x =
kiri +
index *
(
lebar /
(dataSuhu.length - 1)
);
}
let y =
atas +
(max - suhu) /
(max - min) *
tinggi;
ctx.beginPath();
ctx.arc(
x,
y,
4,
0,
Math.PI * 2
);
ctx.fill();
// ---------------------------------------------------
// NILAI DI TITIK
// ---------------------------------------------------
ctx.fillStyle =
"#fff";
ctx.font =
"12px Arial";
ctx.fillText(
suhu.toFixed(1)
+
"°C",
x - 15,
y - 10
);
});
// -----------------------------------------------------
// SUMBU WAKTU
// -----------------------------------------------------
ctx.fillStyle =
"#aaa";
ctx.font =
"12px Arial";
// tampilkan beberapa label waktu
let jumlahLabel = 6;
for (
let i = 0;
i < jumlahLabel;
i++
)
{
if (
dataWaktu.length == 0
)
break;
let index =
Math.floor(
i *
(dataWaktu.length - 1) /
(jumlahLabel - 1)
);
let x;
if (
dataWaktu.length == 1
)
{
x = kiri;
}
else
{
x =
kiri +
index *
(
lebar /
(dataWaktu.length - 1)
);
}
ctx.fillText(
dataWaktu[index],
x - 20,
canvas.height - 20
);
}
}
// =====================================================
// TABEL
// =====================================================
function updateTabel()
{
let tabel =
document.getElementById(
"tabel"
);
tabel.innerHTML = "";
// tampilkan data terbaru di atas
for (
let i =
dataSuhu.length - 1;
i >= 0;
i--
)
{
let row =
tabel.insertRow();
let no =
row.insertCell(0);
let waktu =
row.insertCell(1);
let suhu =
row.insertCell(2);
no.innerHTML =
dataSuhu.length - i;
waktu.innerHTML =
dataWaktu[i];
suhu.innerHTML =
dataSuhu[i].toFixed(2)
+
" °C";
}
}
// =====================================================
// MULAI
// =====================================================
updateSuhu();
setInterval(
updateSuhu,
1000
);
</script>
</body>
</html>
)rawliteral";
// =====================================================
// WEB ROOT
// =====================================================
void handleRoot()
{
server.send(
200,
"text/html",
webpage
);
}
// =====================================================
// DATA SUHU
// =====================================================
void handleSuhu()
{
String json =
"{\"suhu\":" +
String(suhu,2) +
"}";
server.send(
200,
"application/json",
json
);
}
// =====================================================
// BACA DS18B20
// =====================================================
void bacaSuhu()
{
sensors.requestTemperatures();
float t =
sensors.getTempCByIndex(0);
if (
t != DEVICE_DISCONNECTED_C
)
{
suhu = t;
}
}
// =====================================================
// TAMPILKAN P10
// =====================================================
void tampilP10()
{
char teks[20];
sprintf(
teks,
"%.1f ",
suhu
);
//dmd.clearScreen();
dmd.selectFont(
SystemFont5x7
);
dmd.drawString(
0,
0,
"SUHU",
4,
GRAPHICS_NORMAL
);
dmd.drawString(
0,
9,
teks,
strlen(teks),
GRAPHICS_NORMAL
);
}
// =====================================================
// SETUP
// =====================================================
void setup()
{
Serial.begin(
115200
);
delay(1000);
Serial.println();
Serial.println(
"START ESP32"
);
// =====================================================
// WIFI
// =====================================================
WiFi.mode(
WIFI_AP
);
delay(500);
bool ap =
WiFi.softAP(
ssid,
password
);
if(ap)
{
Serial.println(
"ACCESS POINT BERHASIL"
);
Serial.print(
"SSID : "
);
Serial.println(
ssid
);
Serial.print(
"IP : "
);
Serial.println(
WiFi.softAPIP()
);
}
else
{
Serial.println(
"ACCESS POINT GAGAL"
);
}
// =====================================================
// WEB SERVER
// =====================================================
server.on(
"/",
handleRoot
);
server.on(
"/suhu",
handleSuhu
);
server.begin();
Serial.println(
"WEB SERVER AKTIF"
);
// =====================================================
// DS18B20
// =====================================================
sensors.begin();
Serial.println(
"DS18B20 OK"
);
// =====================================================
// DMD
// =====================================================
//dmd.clearScreen();
dmd.selectFont(
SystemFont5x7
);
// =====================================================
// TIMER DMD
// =====================================================
timer =
timerBegin(
0,
80,
true
);
timerAttachInterrupt(
timer,
&triggerScan,
true
);
timerAlarmWrite(
timer,
300,
true
);
timerAlarmEnable(
timer
);
Serial.println(
"DMD P10 OK"
);
Serial.println();
Serial.println(
"=========================="
);
Serial.println(
"SSID : ESP32-SUHU"
);
Serial.println(
"PASS : 12345678"
);
Serial.println(
"IP : 192.168.4.1"
);
Serial.println(
"=========================="
);
}
// =====================================================
// LOOP
// =====================================================
unsigned long waktuSensor = 0;
void loop()
{
server.handleClient();
if (
millis() - waktuSensor >= 1000
)
{
waktuSensor =
millis();
bacaSuhu();
tampilP10();
Serial.print(
"Suhu: "
);
Serial.print(
suhu,
2
);
Serial.println(
" C"
);
}
}
4. VIDEO HASILNYA











.jpeg)
