Reading a DHT11/22 on a raspberry and send the results by MQTT

raspberry
mqtt
dht
Tags: #<Tag:0x00007f0155c53cf0> #<Tag:0x00007f0155c53b10> #<Tag:0x00007f0155c53750>

(Kees Van Gelder) #21

tnx Ikke, I am always in favor of simple and efficient


(Kees Van Gelder) #22

thanks Ikke,
As a matter of fact that is also how the DS18B20 is read on the raspberry, but as it requires file writes for every reading, I try to stay away from that. Nevertheless, it is an interesting addition.

As for accuracy of the DHT11… I have a couple of “old” ones and compared to some new ones I had bought, they have about a 5 degrees difference (Celsius).

I will all phase them out


(Rich Koshak) #23

/proc isn’t on the SD card so reading and writing to it won’t impact the longevity of the SD card. Everything in Linux is a file and everything in /proc is where the “files” that represent the running processes on your system go.

So unless I’m missing something, you can read and write to the device using the file in proc all day and it won’t be problem.


(SiHui) #24

Nope:

https://www.tldp.org/LDP/Linux-Filesystem-Hierarchy/html/proc.html


(Kees Van Gelder) #25

good to know. Tnx.that helped a lot!!!
I thought the values were stored in ‘sys’

@sihui
thanks for that link.

learn something new every day


(Rich Koshak) #26

For completeness, /dev is the same as /proc only that file system represents the hardware in your machine.


(Kees Van Gelder) #27

Thank you Rich
Most examples I saw for reading the DS18B20 though are writing in the ‘/sys’
hence that I thought they were ‘genuine’ file writes. As in ’ writing to SD’
But that one indeed seems pretty ’ virtual’ as well.
Still lots to learn I guess


(stuart harvey) #28

Absolutely brilliant works like a charm thank you so much for this tutorial just kept it as a DHT22


(Kees Van Gelder) #29

my pleasure