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:29] – [All about noForth] mka | en:pfw:dht22 [2025-04-26 16:16] (current) – [Numerical representation of the measured values] mka | ||
---|---|---|---|
Line 37: | Line 37: | ||
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," | ||
{{ : | {{ : | ||
Line 76: | Line 78: | ||
</ | </ | ||
- | ==== Source Code ==== | + | ==== Numerical representation of the measured values ==== |
+ | |||
+ | === Humidity === | ||
+ | |||
+ | The first 16 bits coming from the DHT22 are the relative humidity in tenths of a percent. They can be processed directly with the 16-bit noForth and correspond to a positive integer. Rounded to whole digits for display purposes. | ||
+ | Here is an excerpt from the noforth source code: | ||
+ | |||
+ | < | ||
+ | : .hum ( hum -- ) 10 / . ." %rel" space ; | ||
+ | </ | ||
+ | |||
+ | === Temperature === | ||
+ | |||
+ | The next 16 bits are the temperature in tenths of a degree Celsius. Temperatures from zero degrees and higher can be processed directly using the 16-bit noForth; they correspond to a positive integer. | ||
+ | |||
+ | Temperatures below zero degrees are represented by the DHT22 as follows: The MSB of the 16-bits is set, but otherwise the temperature is specified as a positive integer. This number format //does not correspond// | ||
+ | < | ||
+ | : .tmp ( tmp -- ) | ||
+ | dup hx 8000 and hx 8000 = \ check MSB | ||
+ | if [char] - | ||
+ | else [char] + | ||
+ | then emit | ||
+ | hx 7fff and ( tmp -- +tmp ) \ reset MSB | ||
+ | 10 /mod 3 .r [char] . emit . \ --> TTT.T | ||
+ | [char] f decemit | ||
+ | space | ||
+ | ; | ||
+ | </ | ||
+ | |||
+ | * This is already included in the following source code.\\ | ||
+ | * And here you can see how this was discovered: [[en: | ||
+ | |||
+ | |||
+ | ==== Source Code - and what it was used for.==== | ||
[[en: | [[en: | ||
+ | This program was used to test DHT22 modules before installation. The DHT22 modules were tested for functionality at room temperature, | ||
==== More information on the MSP430G2553 ==== | ==== More information on the MSP430G2553 ==== | ||
Line 100: | Line 136: | ||
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 === | === Logic Analyser === |
en/pfw/dht22.1745537379.txt.gz · Last modified: 2025-04-25 01:29 by mka