Difference: SolutionsToTheDHT11TemperatureAndHumiditySensor (1 vs. 2)

Revision 22020-05-30 - UliRaich

Line: 1 to 1
 
META TOPICPARENT name="Solutions"

Solutions to exercise 4: The DHT11 Temperature and Humidity Sensor

Exercise 1:

Line: 10 to 10
 It takes a new measurement every 2 s and prints the result.

Exercise 2:

Changed:
<
<
The manual evaluation you must do yourself, the program for automatic data extraction is here:
>
>
When doing the manual evaluation you get:
                      Combined Decimal Value  
Humidity High 0 0 1 1   1 1 1 1   0x3f 63 Humidity = 63%
Humidity Low 0 0 0 0   0 0 0 0   0x00    
Temperature 0 0 0 1   0 1 1 1   0x17 23 Temperature = 23.4°C
Temperature Decimal 0 0 0 0   0 1 0 0   0x04 4  
Checksum 0 1 0 1   1 0 1 0   0x5a    

Adding the first 4 hex numbers should result in the same value as the checksum:

dht11Checksum.png

The program for automatic data extraction is here:

  https://iotworkshop.africa/pub/IoT_Course_English/SolutionsToTheDHT11TemperatureAndHumiditySensor/dht11Eval.py.txt

and here a screen dump when running it on the data taken:

Changed:
<
<
dht11Result.png
>
>
dht11Eval.png
 

Exercise 3:

The exercise sheet pretty much explains how to proceed. Therefore I just supply the solution for your study. There are 2 different ways on how to convert the binary values in the 32*32 bit array to strings such that you can write them to the file. In the solution I use the newer method while the old style is given in the comments.

Line: 47 to 58
 
<--/commentPlugin-->

META FILEATTACHMENT attachment="dht11.py.txt" attr="" comment="" date="1589460999" name="dht11.py.txt" path="dht11.py.txt" size="739" user="UliRaich" version="1"
Changed:
<
<
META FILEATTACHMENT attachment="dht11Eval.py.txt" attr="" comment="" date="1589464467" name="dht11Eval.py.txt" path="dht11Eval.py.txt" size="1986" user="UliRaich" version="2"
>
>
META FILEATTACHMENT attachment="dht11Eval.py.txt" attr="" comment="" date="1590848923" name="dht11Eval.py.txt" path="dht11Eval.py.txt" size="2009" user="UliRaich" version="3"
 
META FILEATTACHMENT attachment="dht11Result.png" attr="" comment="" date="1589462766" name="dht11Result.png" path="dht11Result.png" size="18985" user="UliRaich" version="1"
META FILEATTACHMENT attachment="dht11RawRead.py.txt" attr="" comment="" date="1589463741" name="dht11RawRead.py.txt" path="dht11RawRead.py.txt" size="814" user="UliRaich" version="1"
META FILEATTACHMENT attachment="dht11Unpack.py.txt" attr="" comment="" date="1589464428" name="dht11Unpack.py.txt" path="dht11Unpack.py.txt" size="1125" user="UliRaich" version="2"
META FILEATTACHMENT attachment="dht11Plot.py.txt" attr="" comment="" date="1589464296" name="dht11Plot.py.txt" path="dht11Plot.py.txt" size="1109" user="UliRaich" version="2"
Added:
>
>
META FILEATTACHMENT attachment="dht11Eval.png" attr="" comment="" date="1590848923" name="dht11Eval.png" path="dht11Eval.png" size="20099" user="UliRaich" version="1"
META FILEATTACHMENT attachment="dht11Checksum.png" attr="" comment="" date="1590849113" name="dht11Checksum.png" path="dht11Checksum.png" size="4735" user="UliRaich" version="1"

Revision 12020-05-14 - UliRaich

Line: 1 to 1
Added:
>
>
META TOPICPARENT name="Solutions"

Solutions to exercise 4: The DHT11 Temperature and Humidity Sensor

Exercise 1:

The solution to the exercise is quasi already given in the MicroPython manual. All you need to do is replacing the Pin (4 in the manual) by the pin used with our hardware: pin 16. Here is the solution:

https://iotworkshop.africa/pub/IoT_Course_English/SolutionsToTheDHT11TemperatureAndHumiditySensor/dht11.py.txt

It takes a new measurement every 2 s and prints the result.

Exercise 2:

The manual evaluation you must do yourself, the program for automatic data extraction is here:

https://iotworkshop.africa/pub/IoT_Course_English/SolutionsToTheDHT11TemperatureAndHumiditySensor/dht11Eval.py.txt

and here a screen dump when running it on the data taken:

dht11Result.png

Exercise 3:

The exercise sheet pretty much explains how to proceed. Therefore I just supply the solution for your study. There are 2 different ways on how to convert the binary values in the 32*32 bit array to strings such that you can write them to the file. In the solution I use the newer method while the old style is given in the comments.

Here is the solution that starts a measurement, reads out the raw data and write them to a file named "/data/dht11.txt". If the "/data" directory does not yet exist on the ESP32 it is created.

https://iotworkshop.africa/pub/IoT_Course_English/SolutionsToTheDHT11TemperatureAndHumiditySensor/dht11RawRead.py.txt

Exercise 4:

In the script

https://iotworkshop.africa/pub/IoT_Course_English/SolutionsToTheDHT11TemperatureAndHumiditySensor/dht11Unpack.py.txt

the file dth11.txt is opened and unpacked. The sequence if bits is written to the file "dht11Unpacked.txt". This file can be easily plotted with gnuplot:

gnuplot
plot [0:900][0:1.5] "dht11Unpacked.txt" with lines

The script

https://iotworkshop.africa/pub/IoT_Course_English/SolutionsToTheDHT11TemperatureAndHumiditySensor/dht11Plot.py.txt

does unpacking and plotting in a single script. It uses matplotlib to produce the plot.

-- Uli Raich - 2020-05-14

Comments

<--/commentPlugin-->

META FILEATTACHMENT attachment="dht11.py.txt" attr="" comment="" date="1589460999" name="dht11.py.txt" path="dht11.py.txt" size="739" user="UliRaich" version="1"
META FILEATTACHMENT attachment="dht11Eval.py.txt" attr="" comment="" date="1589464467" name="dht11Eval.py.txt" path="dht11Eval.py.txt" size="1986" user="UliRaich" version="2"
META FILEATTACHMENT attachment="dht11Result.png" attr="" comment="" date="1589462766" name="dht11Result.png" path="dht11Result.png" size="18985" user="UliRaich" version="1"
META FILEATTACHMENT attachment="dht11RawRead.py.txt" attr="" comment="" date="1589463741" name="dht11RawRead.py.txt" path="dht11RawRead.py.txt" size="814" user="UliRaich" version="1"
META FILEATTACHMENT attachment="dht11Unpack.py.txt" attr="" comment="" date="1589464428" name="dht11Unpack.py.txt" path="dht11Unpack.py.txt" size="1125" user="UliRaich" version="2"
META FILEATTACHMENT attachment="dht11Plot.py.txt" attr="" comment="" date="1589464296" name="dht11Plot.py.txt" path="dht11Plot.py.txt" size="1109" user="UliRaich" version="2"
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback