en:pfw:dht22
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| en:pfw:dht22 [2025-04-25 01:13] – [Source Code] mka | en:pfw:dht22 [2025-06-27 12:05] (current) – [Implementation for RP2040 using a PIO block] mka | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| {{pfw: | {{pfw: | ||
| - | ====== DHT22 Protocol | + | ====== DHT22 ====== |
| - | ===== Introduction ===== | + | |
| The DHT22 module is a low-cost digital temperature and humidity sensor. It utilizes a capacitive humidity sensor and a thermistor to measure the surrounding air and outputs a digital signal via a single data pin. It's known for its wider measurement range and higher accuracy compared to its predecessor, | The DHT22 module is a low-cost digital temperature and humidity sensor. It utilizes a capacitive humidity sensor and a thermistor to measure the surrounding air and outputs a digital signal via a single data pin. It's known for its wider measurement range and higher accuracy compared to its predecessor, | ||
| Line 16: | Line 14: | ||
| * Suitable for indoor environmental monitoring, weather stations, and HVAC systems. | * Suitable for indoor environmental monitoring, weather stations, and HVAC systems. | ||
| - | ===== SDA ===== | + | ===== SDA Protocol |
| The DHT22 communicates using a **proprietary single-wire serial protocol**. Here's a breakdown of the process: | The DHT22 communicates using a **proprietary single-wire serial protocol**. Here's a breakdown of the process: | ||
| Line 37: | Line 35: | ||
| The microcontroller needs to carefully time these pulses to correctly interpret the data sent by the DHT22. Libraries for popular platforms like Arduino and Raspberry Pi handle these timing-critical operations. | The microcontroller needs to carefully time these pulses to correctly interpret the data sent by the DHT22. Libraries for popular platforms like Arduino and Raspberry Pi handle these timing-critical operations. | ||
| - | [[https:// | + | [[https:// |
| + | |||
| + | On page 2, under 4, "The definition of single-bus interface," | ||
| {{ : | {{ : | ||
| - | ===== Implementation ===== | + | |
| - | ==== Testing with a Logic Analyser (PulsView) ==== | + | ===== Testing with a Logic Analyser (PulsView) |
| Pin P1.0 is bidirectional. It sends the start pulse and then receives the 40 data bits from the sensor module. | Pin P1.0 is bidirectional. It sends the start pulse and then receives the 40 data bits from the sensor module. | ||
| Line 56: | Line 56: | ||
| {{ : | {{ : | ||
| - | ==== Pseudocode | + | ====== Implementation for TI's Launchpad ====== |
| - | < | + | This program was used to test DHT22 modules before installation. The DHT22 modules were tested for functionality at room temperature, |
| - | Function: Pio ( -- ) \ set port I/O function. SDA --> P1.0 | + | |
| - | Function: wakeup ( -- ) \ notify sensor to prepare the data | + | |
| - | Function: @data ( -- sun moon hum tmp chk chksum ) \ get sensor data | + | |
| - | get response time of sensor, store in register ' | + | |
| - | get startpulse duration, store in register ' | + | |
| - | 40 loop | + | |
| - | read bit using ' | + | |
| - | | + | |
| - | 08 loop | + | |
| - | | + | |
| - | calculate chksum | + | |
| - | Function: (dht22) | + | |
| - | Function: | + | |
| - | Function: | + | |
| - | n loop dht22 | + | |
| - | </ | + | |
| - | ==== Source Code ==== | + | [[en: |
| - | [[en: | ||
| + | ====== Implementation for RP2040 ====== | ||
| - | ==== More information on the MSP430G2553 ==== | + | [[en: |
| + | PIO stands for // | ||
| + | ====== Background Information ====== | ||
| + | |||
| + | * How this was discovered: [[en: | ||
| * [[https:// | * [[https:// | ||
| * [[https:// | * [[https:// | ||
| + | * [[https:// | ||
| + | * [[en: | ||
| - | --- | + | ====== Aids ====== |
| - | + | ||
| - | === Source code editor | + | |
| + | MK:\\ | ||
| I like //Notepad Next// for Linux, a cross-platform, | I like //Notepad Next// for Linux, a cross-platform, | ||
| - | https:// | + | https:// |
| - | + | ||
| - | === Terminal === | + | |
| To work with the embedded noForth system I use //e4thcom// by Manfred Mahlow. | To work with the embedded noForth system I use //e4thcom// by Manfred Mahlow. | ||
| - | https:// | + | https:// |
| - | + | Sometimes I also use Windows and Teraterm, for example, to log longer MCU outputs to a file. I also prefer it for testing parts of the source code using copy and paste.\\ | |
| - | === Logic Analyser === | + | In this project I used a Logic Analyzer |
| - | + | ||
| - | AZDelivery | + | |
| // | // | ||
| - | |||
| - | --- | ||
en/pfw/dht22.1745536412.txt.gz · Last modified: 2025-04-25 01:13 by mka