The DHT22 is, as you described, made to work over GPIO pins. That means that any device with GPIO can use it.
About the libraries. There are two major libraries for communicating via GPIO written, one for C++ and one for Python. That means that any device that has GPIO and can run Python or C++ can use your DHT22.
What about no C++, Python, Java... based libraries? Well, there is no Linux standard library for communicating over GPIO. Of course, if you are eager to learn and explore, you can write a library in Assembly or Bash, which would be as close to LSL as you can get. By doing that you can natively communicate over GPIO from Linux shell without any other programming language. If you are interested in Bash, take a look at this.
How does Linux know the temperature and humidity when it can only read 0s and 1s? Consider two things:
- How does computer store number 32? The computer only knows 0's and 1's so he needs to convert 32 to binary. What is 32 = 2^6 in decimal, is 100000 in binary.
How does computer read temperature and humidity? When you execute a function like
get_temperature()
which requests temperature from DHT22, what actually happens is that your computer sends signal to DHT22 (it "writes" to DHT22 over GPIO through IN on DHT22, which is the same as OUT on computer). Then the DHT22 senses the temperature and "sends" data back. How does it send it? It creates a sequence of electric charges through GPIO (GPIO IN on computer and GPIO OUT on DHT22). In our case, if temperature is 32, then it sends the next sequence: 1-0-0-0-0-0. The computer reads the sequence and when you try to print it to screen it converts it into decimal.
Hope I got myself clear and this is what you wanted.
In this link you find a C code for reading DHT22 temperature and humidity if that is what you want. Please let me know what you want to do in general (read temp. and hum. via library, write new library for communicating over GPIO, write new library in another language for DHT22...).
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…