Monitoring Suhu Dan Kelembaban Menggunakan ESP32 + DHT22 Dengan Protokol MQTT

Idrus Project
9 Nov 202310:42

Summary

TLDRThis video tutorial guides viewers through creating an IoT project using an ESP32 microcontroller and a DHT22 sensor to monitor temperature and humidity. It covers the setup of hardware connections, installation of necessary libraries in Arduino IDE, programming steps, and configuration of MQTT for data publishing. The video also demonstrates how to use the MQTT Dash app on Android for real-time monitoring of the environmental data, concluding with a live test of the system.

Takeaways

  • πŸ“· The video demonstrates setting up an IoT project using an ESP32 and a DHT22 sensor to monitor temperature and humidity, displaying the data on an MQTT dashboard.
  • πŸ” The ESP32 microcontroller is chosen for its built-in Wi-Fi module, facilitating easy internet connectivity for the project.
  • 🌑️ The DHT22 sensor is selected over the DHT11 for its higher accuracy in measuring temperature and humidity.
  • πŸ”§ Two breadboards are used in the setup to accommodate the ESP32, which would otherwise occupy all available pins on a single breadboard.
  • πŸ”Œ The DHT22 is connected to the ESP32 using jumper cables, with the VCC pin to VIN, the OUT pin to a digital pin (D32), and the GND pin to the ESP32's ground.
  • πŸ“š The Arduino IDE is used for programming the ESP32, requiring the installation of the PubSubClient and DHT.h libraries for MQTT communication and sensor data reading.
  • πŸ“ The script includes setting up Wi-Fi credentials and MQTT broker details within the Arduino code, using a free MQTT broker like broker.hivemq.com.
  • πŸ”‘ The MQTT topic for publishing data is defined in the code, with a unique identifier to prevent data collision, especially when using a free broker.
  • πŸ”„ The 'void Loop' function in the Arduino code is responsible for obtaining data from the DHT22 and publishing it to the MQTT broker.
  • πŸ“² The video mentions using an Android app, such as MQTT Dash, to monitor and display the temperature and humidity data published by the ESP32.
  • πŸ› οΈ The video is sponsored by PCBY, a PCB manufacturing service offering low-cost prototyping, and also provides services like CNC, 3D printing, and laser cutting.

Q & A

  • What is the main purpose of the project described in the video?

    -The main purpose of the project is to create an Internet of Things (IoT) device that monitors temperature and humidity using an ESP32 microcontroller and a DHT22 sensor, and publishes the data to an MQTT broker.

  • Why is the ESP32 microcontroller a suitable choice for this project?

    -The ESP32 microcontroller is suitable because it includes built-in Wi-Fi connectivity, making it easier to connect the device to the internet for data transmission.

  • What are the alternatives to the DHT22 sensor mentioned in the script?

    -The script mentions the DHT11 as an alternative to the DHT22, but the DHT22 is chosen for its higher accuracy in measuring temperature and humidity.

  • Why are two breadboards used in the project setup?

    -Two breadboards are used because a single ESP32 module occupies all available pins on one breadboard, preventing the use of additional pins on the same side.

  • What is the function of the USB cable in the project setup?

    -The USB cable is used for programming the ESP32 microcontroller, connecting it to a computer or laptop for code upload and debugging.

  • Which libraries are required to be installed for the project's Arduino programming?

    -The required libraries for the project are 'PubSubClient' for MQTT communication and 'DHT.h' for reading data from the DHT22 sensor.

  • What is the significance of the MQTT broker in the project?

    -The MQTT broker is essential for the project as it acts as an intermediary for the ESP32 to publish temperature and humidity data to a topic, which can then be subscribed to and monitored.

  • How can one subscribe to the data published by the ESP32 in the script?

    -One can subscribe to the data by using an MQTT client, such as the MQTT Dash app on Android, and setting up a subscription to the specific topic that the ESP32 publishes to.

  • What is the recommended MQTT broker for a free service as mentioned in the script?

    -The script recommends using 'broker.hivemq.com' as a free MQTT broker service for the project.

  • How does the video guide the user to test the project setup on the hardware?

    -The video instructs the user to upload the program to the ESP32, set up the MQTT Dash app on an Android device to monitor the data, and then test the hardware by observing the temperature and humidity readings on the app.

  • What is the importance of having a unique topic for the MQTT messages?

    -Having a unique topic is important to avoid data conflicts, especially when using a free MQTT broker, as a common topic might be used by multiple users, leading to mixed data streams.

Outlines

00:00

🌑️ IoT Weather Monitoring Project Setup

This paragraph introduces an IoT project that involves monitoring temperature and humidity using an ESP32 microcontroller and a DHT22 sensor. The project is about setting up an MQTT-based system to display the readings on an MQTT dashboard. The video explains the components required, including an ESP32 for Wi-Fi connectivity and the DHT22 for higher accuracy compared to the DHT11. It also covers the physical setup with breadboards and jumper cables, and mentions the need for a USB cable for programming. The paragraph concludes with a brief introduction to the software setup, including the installation of necessary libraries in the Arduino IDE.

05:01

πŸ› οΈ Programming and Configuring the IoT Device

The second paragraph delves into the programming aspect of the project. It describes the process of writing code for the ESP32 using the Arduino IDE, including the setup of Wi-Fi and MQTT connections. The video script outlines the creation of an ESP client object for connecting to Wi-Fi and the use of functions to publish temperature and humidity data to a unique MQTT topic to avoid data conflicts. It also covers the setup of the MQTT dashboard on an Android device using the MQTT Dash app, explaining how to create a new project, add widgets for temperature and humidity, and configure the subscription to the correct MQTT topics. The paragraph ends with a test of the hardware setup, showing the MQTT dashboard displaying the sensor readings.

10:03

πŸ“ˆ Testing and Final Thoughts on the IoT Project

The final paragraph discusses the testing phase of the IoT project. It mentions observing the sensor readings on the MQTT dashboard and suggests warming up the sensor to see the temperature rise in real-time. The paragraph also includes a call to action for viewers to support the channel by liking, sharing, commenting, and subscribing. The video concludes with a sign-off, thanking viewers for watching and expressing anticipation for the next video.

Mindmap

Keywords

πŸ’‘ESP32

ESP32 is a microcontroller with integrated Wi-Fi capabilities, which simplifies internet connectivity for projects. In the video, it is used as the central processing unit for the IoT project to monitor temperature and humidity. The script mentions 'microcontroller kita menggunakan esp32' and 'kita bisa pasangkan esp32-nya di bagian tengah', indicating its role in the project setup.

πŸ’‘DHT22

DHT22 is a type of sensor used for measuring temperature and humidity. The video emphasizes its higher accuracy compared to alternatives like DHT11. The script refers to it as 'sensornya sendiri kita menggunakan dht22' and 'dht 22-nya di sini', showing its importance in gathering environmental data.

πŸ’‘MQTT

MQTT, or Message Queuing Telemetry Transport, is a lightweight messaging protocol for small sensors and mobile devices, facilitating the communication between the ESP32 and the broker. The script discusses 'menggunakan protokol, mqtit' and 'ESP client supaya nanti bisa, dihubungkan ke, wifi', highlighting its use for data transmission in the project.

πŸ’‘Breadboard

A breadboard is a device used for building and testing electronic circuits without soldering. The video mentions using two breadboards, 'perakitan kita bisa menggunakan, braidbard seperti ini', to accommodate the ESP32 and DHT22, allowing for easy connections and adjustments.

πŸ’‘Jumper Cable

Jumper cables are used to connect components within a circuit. The script includes 'gunakan kabel jumper ke dht 2-2-nya', indicating their use to link the DHT22 sensor to the ESP32 for data collection.

πŸ’‘Arduino IDE

Arduino IDE is the integrated development environment used for writing and uploading code to the ESP32. The video script includes instructions on 'masuk ke pemrograman Arduino ide-nya', showing it as the tool for programming the microcontroller.

πŸ’‘Library

In the context of the video, a library refers to pre-written code modules that are included in the project for specific functionalities, such as 'pub sub client' and 'dht.h' for MQTT communication and reading sensor data. The script mentions 'menginstal beberapa library' and provides steps for including them in the project.

πŸ’‘WiFi

WiFi is a wireless networking technology used to connect devices to the internet. The video discusses setting up WiFi connectivity for the ESP32 with 'Network untuk menghubungkan device kita ke jaringan wi-fi', which is essential for the IoT project's remote monitoring capabilities.

πŸ’‘MQTT Broker

An MQTT Broker is a server that handles MQTT messages between clients. The video mentions 'broker mqtt-nya' and 'broker.hmq.com', indicating its role in the middleman for message passing between the ESP32 and other devices or services.

πŸ’‘MQTT Dashboard (MQTT Dash)

MQTT Dash is an application used to monitor and visualize data from MQTT topics. The video script includes instructions for setting up MQTT Dash on Android to 'memonitoring data suhu dan kelembaban', demonstrating its use for real-time data observation.

πŸ’‘Prototype

A prototype in the context of the video refers to the initial model of the IoT project being demonstrated. The script mentions 'pesan 10 keping PCB Prototype', suggesting that viewers can create their own initial models of the project using PCBs from the mentioned service.

Highlights

The project demonstrates how to monitor temperature and humidity using MQTT with an ESP32 and DHT22.

ESP32 is chosen for its built-in Wi-Fi module, simplifying internet connectivity.

DHT22 is selected over DHT11 for its higher accuracy in sensing temperature and humidity.

The tutorial explains the use of two breadboards to accommodate the ESP32 and DHT22 sensors.

The video covers the physical assembly of the ESP32 and DHT22 using jumper cables.

A USB cable is used for programming the ESP32 microcontroller.

The video is sponsored by PCByy, offering affordable PCB prototyping services.

Arduino IDE is used for programming the ESP32 with necessary libraries such as PubSubClient and DHT.h.

Instructions on how to install the required libraries for the project are provided.

The tutorial includes setting up Wi-Fi credentials and MQTT broker details in the code.

The code defines the pins used for connecting the DHT22 sensor to the ESP32.

The video explains the use of dual-core functionality of the ESP32 for efficient programming.

The MQTT topic for publishing temperature and humidity data is configured to be unique to avoid data conflicts.

The tutorial guides through the process of uploading the program to the ESP32.

The video shows how to set up MQTT Dash on Android for monitoring the temperature and humidity data.

MQTT Dash is used to create a new project and add widgets for displaying temperature and humidity readings.

The video concludes with a live demonstration of the setup, showing real-time temperature and humidity monitoring.

The importance of a tight sensor connection for accurate readings is emphasized.

The video encourages viewers to like, share, comment, and subscribe for more similar content.

Transcripts

play00:00

Nah sekarang kita bisa lihat suhu dan

play00:02

kelembaban sudah tampil di mqtt das-nya

play00:05

dan ini untuk hardware-nya ada sp32 dan

play00:09

dht22 seperti

play00:12

ini halo semuanya balik lagi di channel

play00:15

YouTube Project di video kali ini kita

play00:17

akan membuat Project Internet ofting

play00:19

menggunakan sp32 dan dht22 seperti ini

play00:23

Project kali ini kita akan pantau suhu

play00:25

dan kelembaban menggunakan protokol

play00:27

mqtit nanti kita bisa coba mengunakan M2

play00:31

dust seperti yang ada di video awal tadi

play00:33

dan bagaimana caranya kita langsung aja

play00:35

lanjut ke tutorial

play00:38

[Musik]

play00:44

Oke berikut adalah bahan-bahan yang

play00:45

dipakainya yang pertama untuk

play00:47

microcontroller kita menggunakan esp32

play00:50

esp32 ini merupakan microcontroller yang

play00:52

sudah include untuk modul wi-fi jadi

play00:55

untuk konektivitas internet akan jadi

play00:57

lebih mudah kemudian untuk sensornya

play01:00

sendiri kita menggunakan dht22

play01:03

alternatif lain teman-teman bisa

play01:05

menggunakan dht 11 yang warnanya biru di

play01:07

sini saya menggunakan dht22 Karena untuk

play01:10

tingkat akurasinya yang lebih tinggi

play01:12

dibanding dht 11 Kemudian untuk

play01:15

perakitan kita bisa menggunakan

play01:17

braidbard seperti ini dan ada kabel

play01:19

jampper juga maelt to mil di sini Kenapa

play01:22

saya menggunakan dua buah breadbard

play01:25

Karena untuk asp32 sendiri jika kita

play01:27

pasang di satu breadbot saja dia memakan

play01:30

semua PIN yang tersedia jadi kita enggak

play01:33

bisa pakai lagi pin-pin yang ada di

play01:34

sebelahnya seperti

play01:36

ini maka dari itu kita harus gabungkan

play01:39

dua bidboard seperti ini caranya tinggal

play01:41

pasang aja seperti

play01:43

ini dan kita bisa pasang esp32-nya di

play01:47

bagian tengah seperti ini nanti untuk

play01:50

PIN sebelahnya atas dan bawah bisa kita

play01:53

gunakan untuk keperluan jumper

play01:56

menggunakan kabel jumper ke dht 2-2-nya

play02:00

selanjutnya ada kabel USB seperti ini

play02:03

fungsi kabel USB ini nanti kita pakai

play02:05

untuk

play02:06

[Musik]

play02:08

pemrograman berikut untuk perakitannya

play02:11

kita bisa pasangkan esp32-nya di bagian

play02:13

tengah seperti

play02:14

[Musik]

play02:17

ini selanjutnya kita bisa pasang dht

play02:20

22-nya di sini bisa kita perhatikan ada

play02:23

PIN Plus out dan

play02:28

Min

play02:30

[Musik]

play02:32

untuk PIN plus-nya kita bisa hubungkan

play02:34

ke Vin yang ada di sp32 seperti

play02:38

ini Kemudian untuk out-nya kita bisa

play02:41

hubungkan di PIN digital 32 atau d32

play02:45

seperti

play02:46

ini dan yang terakhir untuk PIN min-nya

play02:50

kita bisa hubungkan di PIN gnd yang ada

play02:52

di

play02:55

esp32 selanjutnya kita bisa hubungkan

play02:58

esp32-nya ke kabel

play03:01

USB dan ujung satunya kita bisa

play03:03

hubungkan ke komputer atau

play03:07

laptop kita lanjut ke langkah

play03:10

selanjutnya sebelum kita lanjut video

play03:13

kali ini disponsori oleh pcbyy pcby

play03:16

merupakan pabrik percetakan PCB di China

play03:18

dengan hanya 5 dolar saja kalian sudah

play03:20

bisa pesan 10 keping PCB Prototype

play03:23

dengan spesifikasi yang sangat

play03:25

berkualitas selain PCB pcby y juga

play03:28

menyediakan jasa CNC 3D printing dan

play03:31

laser cutting Jadi tunggu apa lagi

play03:33

buruan cetak PCB kamu di pcbyy

play03:36

selanjutnya kita bisa langsung masuk ke

play03:38

pemrograman Arduino ide-nya di sini

play03:41

untuk programnya sendiri Kita harus

play03:42

menginstal beberapa library yang pertama

play03:45

ada pub sub client pub sub client ini

play03:48

berfungsi untuk menghubungkan esp32 kita

play03:51

ke broker

play03:52

mqtt-nya dan dht.h dht.h ini seperti

play03:56

namanya berfungsi untuk membaca data

play03:58

dari sensor

play04:00

dht-nya untuk menginstalnya teman-teman

play04:03

bisa masuk ke bagian sketch kemudian

play04:05

include library dan pilih manage library

play04:08

di sini teman-teman bisa ketikkan aja

play04:10

pubsub client seperti itu nanti tinggal

play04:13

didownload kemudian di bagian sini kita

play04:16

bisa Masukkan nama Wifi yang akan kita

play04:19

pakai dan password

play04:27

wifi-nya selanjutnya di bagian mqtt

play04:30

broker kita bisa isikan dengan address

play04:33

atau Broker mqtt yang kita pakai untuk

play04:36

broker mqtt gratisan biasanya saya

play04:39

menggunakan

play04:43

broker.hmq.com karena ini broker

play04:45

gratisan jadi untuk username dan

play04:47

password-nya bisa kita kosokkan seperti

play04:49

ini kemudian portnya kita pakai

play04:54

1883 di sini ada definisi Pin dan jenis

play04:57

dht yang kita pakai dan ada variabel

play05:01

yang berfungsi untuk menampung data suhu

play05:03

dan data

play05:05

kelembabannya kemudian kita buat objek

play05:08

untuk ESP client supaya nanti bisa

play05:11

dihubungkan ke

play05:13

wifi selanjutnya kita buat juga untuk

play05:17

function supaya bisa menggunakan e

play05:20

fungsi dual core dari

play05:24

esp32-nya serial begin 115200 di sini

play05:28

fungsinya untuk thebaging program dengan

play05:30

kecepatan baudrad

play05:32

115200 kemudian ada setup Wii setup Wii

play05:36

sendiri di sini kita bisa lihat di

play05:38

bagian Network untuk menghubungkan

play05:40

device kita ke jaringan wi-fi yang

play05:43

sebelumnya kita tulis di variabel SSID

play05:45

dan

play05:49

password kemudian tentukan di Core 1 di

play05:53

Core 0 maaf untuk menjalankan fungsi

play05:56

mqtt untuk mqtt ini sendiri di sini kita

play06:00

hanya gunakan untuk publish karena

play06:02

keperluan Project kali ini hanya untuk

play06:04

publish data publish data temperatur dan

play06:07

publish data kelembaban di topik

play06:11

esp32/ temperatur Idrus 24 ya ini bisa

play06:15

diatur Yang penting unik aja ya

play06:17

teman-teman karena kita menggunakan SP

play06:21

karena kita menggunakan broker gratisan

play06:23

Jadi kalau topik yang kita pakai namanya

play06:26

itu umum bisa jadi nanti datanya bentrok

play06:29

kemudian kita juga lakukan hal yang sama

play06:31

di bagian publish

play06:33

untuk

play06:35

kelembabannya nah di void Loop sendiri

play06:38

kita pakai untuk mendapatkan data dari

play06:42

dht di sini data dari dht-nya kita

play06:46

masukkan di variabel temperatur dan

play06:49

variabel

play06:50

humidity selanjutnya kita bisa langsung

play06:52

upload aja pilih ke bagian tools

play06:55

kemudianardnya

play06:57

pilih322 jika tem-teman belum ada bisa

play07:00

download di bagian board Manager yang

play07:02

ada di sini atau bisa ikutin video kita

play07:05

sebelumnya yang membahas tentang

play07:07

sp32 kemudian di bagian portnya kita

play07:10

bisa pilih di port yang e sesuai ya di

play07:13

sini untuk as32 saya portnya masuk di

play07:16

port com 5 selanjutnya kita bisa

play07:19

langsung klik upload aja di

play07:24

sini oke sekarang proses upload-nya

play07:27

sudah selesai kita bisa lanjut untuk

play07:29

setting mqtt-nya di mqtt das yang ada di

play07:35

Android selanjutnya kita bisa download m

play07:38

Das untuk memonitoring data suhu dan

play07:41

kelembabannya di Play Store kita bisa

play07:43

Klik aja MQ d dan kita pilih yang ini ya

play07:48

di sini berhubung saya sudah m-download

play07:50

jadi saya tinggal klik Open aja atau

play07:52

buka kemudian buat proek baru dengan

play07:55

cara Klik tombol plus yang ada di pojok

play07:58

kanan atas ini

play08:01

masukin namanya contoh

play08:04

esp32 monitoring

play08:07

dht22 Kemudian untuk addressnya sendiri

play08:10

Kita bisa sesuaikan dengan Broker yang

play08:12

tadi kita tentukan di Arduino id-nya di

play08:15

sini kita menggunakan

play08:20

broker.vmq.com kemudian portnya

play08:23

1883 username dan passwordnya kita bisa

play08:26

kosongkan aja karena ini broker

play08:30

klik

play08:31

save selanjutnya kita buka Project Yang

play08:34

tadi kita

play08:36

buat tambahin widget dengan cara Klik

play08:39

tombol plus yang ada di atas

play08:41

ini pilih

play08:43

teks kemudian masukkan namanya contoh di

play08:46

sini suhu kemudian TOPIK untuk

play08:48

subscribe-nya kita bisa sesuaikan dengan

play08:51

topik publish Yang tadi kita tentukan di

play08:54

ardinonya contoh di sini

play08:58

sp32

play09:01

Idrus

play09:03

24 kemudian buat

play09:06

lagi teks masukin namanya

play09:10

kem Baban kemudian TOPIK untuk

play09:14

subscribe-nya

play09:18

esp32/ Yung Idrus 24 kemudian klik save

play09:24

sekarang sudah selesai untuk mqtt

play09:27

das-nya oke sekarang udah keesetting

play09:29

semua kita bisa testing langsung di

play09:31

hardware-nya seperti ini ini ada sp32

play09:34

sama sensor suhu dan kelembabannya di

play09:36

sini Kemudian untuk di handphone-nya

play09:39

kita bisa buka MV das yang tadi kita

play09:41

setting ada di monitoring SPT kedua dan

play09:45

dht

play09:46

22 seperti ini sekarang untuk suhu dan

play09:49

kelembabannya sudah

play09:53

[Musik]

play09:56

tampil kita bisa coba Panaskan unau

play09:59

sensornya menggunakan korek ya

play10:02

[Musik]

play10:06

oke di sini ada nan nan sedikit kalau

play10:09

nan itu artinya biasanya untuk sensornya

play10:11

e longgar ya untuk

play10:14

konektivitasnya Nah bisa kita lihat naik

play10:17

seperti

play10:18

itu

play10:21

37 ya sampai 38 dan

play10:25

39 Oke mungkin itu aja video kita pada

play10:28

kesempatan kali ini buat teman-teman

play10:30

yang suka dengan konten seperti ini

play10:31

bantu channel ini dengan cara di-like

play10:34

di-share dikomen dan di-subscribe terima

play10:36

kasih yang sudah menonton sampai jumpa

play10:38

lagi di video selanjutnya

play10:41

bye

Rate This
β˜…
β˜…
β˜…
β˜…
β˜…

5.0 / 5 (0 votes)

Related Tags
IoT ProjectESP32DHT22MQTT ProtocolArduino IDESensor ReadingDIY TutorialTemperature MonitoringHumidity SensorMicrocontroller