DHT 12 Sensor
tonizombie opened this issue · 6 comments
Would it be possible to use DHT 12 sensor with this module? (The board im using https://wiki.52pi.com/index.php?title=EP-0106)
Hi, I don't have a DHT12 to test with. Have you tried it? It may just work.
I tried but just says "Loading..." under the module header when i start the mirror. No errors in log either, i think the issue might be with the DHT script that reads the temps.
This is the script that came with the board and it works fine, so might be the script (https://wiki.52pi.com/index.php?title=EP-0106#Program_in_Language_C.28Raspberry_Pi.29)
ah ok, quickly looking over that script, it looks like it asks the board to get the data from the sensor, rather than querying it directly. My recommendation would be to modify that script to output the data in the JSON format the this module expects ({ "humidity": 18.9, "celcius": 20.6, "fahrenheit": 69.1, "kelvin": 293.8, "attempts": 1 }
) then set this module to use that script for the query.
As i know very little about C how would i go about with this? Would "printf(0x05, 0x06)" work? Those numbers being what the original script defines the temp and humidity as.
Check out the source of my DHT script to see the output format.
Line 297 in d17850d
I removed the farenheit, kelvin and attempts because they do not exist in the original code, also changed the original defines to temp_c and humidity.
With this code (https://pastebin.com/d4Baysug) i can get it to output the humidity and celcius, however they are both 0.0 because the print is missing their (int)aReceiveBuf[EITHER temp_c OR humidity respectively]
Would you have any idea how to incorporate that intareceivebuff to the print?
In the original code it adds it just after the value (temperature = %d Celsius\n", (int)aReceiveBuf[temp_c]), if doing like this in the fprintf(stdout it also prints the aReceiveBuff after the 0.0 value and dosent actually get the sensor data