I have a little problem for school and I have to read the temperature with Arduino from a DTH11 sensor and print it in serial, only in C language. Can someone help me with an example or something.
-
The DTH11 has a digital single-wire serial interface - the ADC is of no use to you with this sensor. Really all you are asking here if for someone to Google it for you: https://www.instructables.com/id/How-to-interface-Humidity-and-Temperature-DTH11-Se/ – Clifford Apr 23 '19 at 21:07
1 Answers
You can find the DHT11 data sheet on the Internet, for example
https://akizukidenshi.com/download/ds/aosong/DHT11.pdf or
https://www.mouser.com/ds/2/758/DHT11-Technical-Data-Sheet-Translated-Version-1143054.pdf
there are sections which explain how the sensor module communicates via 1 wire with the MCU (Arduino).
Then, once you have an idea how the communication happens, you can read more articles like
and there are many others, most use an already written library.
If your assignment won't let you use a library, you'll have to read for example the code at https://playground.arduino.cc/Main/DHTLib/ in files dht.h
and dht.cpp
and implement your own, maybe minimal version based on your understanding of the information provided on DHT's data sheet.
I would recommend to get things working by using a library first, then change it to work without.

- 11,312
- 4
- 30
- 44