0Pricing
Arduino & IoT Academy · บทเรียน

ต่อสาย DHT11/DHT22

เชื่อมต่อสายข้อมูล ไฟเลี้ยง และตัวต้านทานพูลอัป

ต่อสาย DHT11/DHT22 เป็นบทเรียน Arduino & IoT Academy ฟรีบน CoddyKit นี่คือบทเรียนที่ 1 จากทั้งหมด 4 บทเรียน คุณสามารถอ่านบทเรียนทั้งหมดด้านล่างฟรี — จากนั้นลองปฏิบัติด้วยตัวคุณเองในเบราว์เซอร์พร้อมตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7 บทเรียนนี้เป็นส่วนหนึ่งของเส้นทางการเรียน Arduino & IoT Academy และความก้าวหน้าของคุณจะซิงค์ข้ามเว็บและแอป CoddyKit คอร์ส Arduino & IoT Academy มีบทเรียนทั้งหมด 4 บทเรียน

บางส่วนของบทเรียนนี้ยังไม่ได้รับการแปล และแสดงเป็นภาษาอังกฤษ

Meet the DHT Sensor

A DHT sensor measures both temperature and humidity in one tiny package. It is the friendliest way to give your project a sense of climate. 🌡️

DHT11 vs DHT22

The DHT11 is cheap and good enough for hobby projects. The DHT22 costs a bit more but reads a wider range with better accuracy.

Just One Data Pin

What makes DHT lovely is its single data pin. One wire carries both readings to your board, so wiring stays simple.

Three Pins to Know

A bare DHT has three useful pins: VCC for power, GND for ground, and DATA for the signal. A fourth pin is usually unused.

Power It Correctly

Connect VCC to the 5V pin on your Arduino and GND to a ground pin. Get this right first, or the sensor stays silent.

The Data Line

Run the DATA pin to any digital pin you like, such as pin 2. You will name this exact pin later in your code.

#define DHTPIN 2

Add a Pull-Up Resistor

The data line needs a pull-up resistor, about 10k ohms, between DATA and VCC. It keeps the idle signal clean and steady.

Why the Pull-Up Helps

Without that resistor, the data line can float and report scrambled values. The pull-up gives the line a reliable resting voltage.

Modules Make It Easy

Many DHT modules come on a small board with the resistor already soldered on. Then you only wire three pins and skip the resistor.

Mind the Orientation

Always check the pin labels printed on your sensor. Swapping VCC and GND can overheat the part, so look before you power up.

Double-Check Before Power

Trace each wire one more time: power, ground, and data to the right digital pin. A calm check now saves confusing readings later.

Quick Check

You are wiring a bare DHT11. What component does its data line need to stay reliable?

Recap

You met the DHT family, wired VCC, GND, and a data pin, and added a 10k pull-up so the signal stays clean and trustworthy. 🎉

คำถามที่พบบ่อย

บทเรียน “ต่อสาย DHT11/DHT22” ฟรีหรือไม่

ใช่ — ข้อความเต็มของ “ต่อสาย DHT11/DHT22” ฟรีให้อ่านที่นี่บนเว็บ เพื่อปฏิบัติแบบโต้ตอบ (ตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7) และปลดล็อคส่วนที่เหลือของคอร์ส Arduino & IoT Academy ให้อัปเกรดเป็น CoddyKit PRO คอร์ส Arduino & IoT Academy มีบทเรียนทั้งหมด 4 บทเรียน

คุณจะเรียนรู้อะไรในบทเรียน “ต่อสาย DHT11/DHT22”

เชื่อมต่อสายข้อมูล ไฟเลี้ยง และตัวต้านทานพูลอัป คุณปฏิบัติ Arduino & IoT Academy ด้วยโค้ดที่ใช้งานได้จริงที่คุณเรียกใช้โดยตรงในเบราว์เซอร์ และติวเตอร์ AI ตลอด 24/7 ตอบคำถามของคุณขณะที่คุณไปผ่านบทเรียน

คุณต้องมีประสบการณ์ก่อนที่จะเริ่มเรียน Arduino & IoT Academy หรือไม่

ไม่จำเป็นต้องมีประสบการณ์มาก่อน Arduino & IoT Academy บน CoddyKit ออกแบบมาสำหรับผู้เริ่มต้นไปจนถึงผู้เรียนขั้นสูง คุณสามารถเริ่มต้นที่นี่หรือเริ่มจากตัวแรกและเรียนด้วยความเร็วของคุณเอง นี่คือบทเรียนที่ 1 จากทั้งหมด 4 บทเรียน

บทเรียน “ต่อสาย DHT11/DHT22” ใช้เวลานานแค่ไหน

บทเรียน CoddyKit ส่วนใหญ่ใช้เวลาประมาณ 5–10 นาที แต่ละบทเรียนจึงสั้นและเป็นแบบโต้ตอบ คุณสามารถก้าวหน้าอย่างต่อเนื่องและกลับมาเรียนต่อจากตรงที่เพิ่งหยุดบนเว็บและแอปได้เลย

ฉันเขียนและรันโค้ดในบทเรียน Arduino & IoT Academy นี้ได้ไหม

ได้ บทเรียน Arduino & IoT Academy ทุกบทมีตัวแก้ไขโค้ดในตัว คุณจึงเขียนและรันโค้ดจริงได้เลยในเบราว์เซอร์ และได้รับข้อเสนอแนะจาก AI ในทันที — ไม่ต้องติดตั้งในเครื่องของคุณ

บทเรียนทั้งหมดในหลักสูตรนี้

  1. ต่อสาย DHT11/DHT22
  2. ติดตั้งไลบรารี DHT
  3. อ่านอุณหภูมิและความชื้น
  4. จัดการการอ่านค่าที่ล้มเหลว
← กลับไปที่ Arduino & IoT Academy