💬 Air Humidity Sensor - DHT
-
Hi all,
I recoded this sketch and I posted on GitHub (1 year ago, and I updated it today). It runs good from 1 year with no issues.
I don't know why it's still not merged in master branch. I forgot to do some action??
Can anyone help me? please.
Meanwhile you can download and use it; this is its link:
https://github.com/cnerone/MySensorsArduinoExamples/blob/master/examples/DhtTemperatureAndHumiditySensor/DhtTemperatureAndHumiditySensor.ino -
Hi all,
I recoded this sketch and I posted on GitHub (1 year ago, and I updated it today). It runs good from 1 year with no issues.
I don't know why it's still not merged in master branch. I forgot to do some action??
Can anyone help me? please.
Meanwhile you can download and use it; this is its link:
https://github.com/cnerone/MySensorsArduinoExamples/blob/master/examples/DhtTemperatureAndHumiditySensor/DhtTemperatureAndHumiditySensor.ino -
I used the code that cnerone has in his comment below with a nano and DHT22 and it worked great. For my nano I did have to use the 'old' bootloader for the program to download into the nano correctly with the arduino IDE. The code in the example here wouldn't compile for me, I think because someone changed the DHT library but for some reason kept the name the same so I ran into some kind of conflicts with variables. I wish when people modified libraries they would give them new/different names because the IDE does not have a good way of handling multiple libraries with the same name. BTW: That is not a MySensors issue, it's the IDE.
-
Also, I could not get a clean compile/download to a arduino mini 3.3v with 168 processor. From what I could find there is not enough memory to handle the newest mysensor libraries, at least that's what some people are saying in forums. I didn't spend much time on it and moved on to other arduinos.
-
For any one that needs it this is how I got the DHT22 to work.
This is my poor attempt at trying to get the DHT22 to work as the original code
https://github.com/cnerone/MySensorsArduinoExamples/blob/master/examples/DhtTemperatureAndHumiditySensor/DhtTemperatureAndHumiditySensor.ino
will not compile for me.// Enable debug prints #define MY_DEBUG // Enable and select radio type attached #define MY_RADIO_RF24 //#define MY_RADIO_RFM69 //#define MY_RS485 #define MY_RF24_CE_PIN 9 #define MY_RF24_CS_PIN 10 #include <SPI.h> #include <MySensors.h> #include <DHT.h> // Set this to the pin you connected the DHT's data pin to #define DHTPIN 2 // what digital pin we're connected to #define DHTTYPE DHT22 // DHT 22 (AM2302), AM2321 #define CHILD_ID_HUM 0 #define CHILD_ID_TEMP 1 MyMessage msgHum(CHILD_ID_HUM, V_HUM); MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP); DHT dht(DHTPIN, DHTTYPE); void presentation() { // Send the sketch version information to the gateway sendSketchInfo("TemperatureAndHumidity", "1.1"); // Register all sensors to gw (they will be created as child devices) present(CHILD_ID_HUM, S_HUM); present(CHILD_ID_TEMP, S_TEMP); } void setup() { dht.begin(); // set data pin of DHT sensor } void loop() { delay(2000); // Reading temperature or humidity takes about 250 milliseconds! // Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor) float h = dht.readHumidity(); // Read temperature as Celsius (the default) float t = dht.readTemperature(); // Read temperature as Fahrenheit (isFahrenheit = true) float f = dht.readTemperature(true); // Check if any reads failed and exit early (to try again). if (isnan(h) || isnan(t) || isnan(f)) { return; } // Compute heat index in Fahrenheit (the default) float hif = dht.computeHeatIndex(f, h); // Compute heat index in Celsius (isFahreheit = false) float hic = dht.computeHeatIndex(t, h, false); send(msgTemp.set(f, 1)); send(msgHum.set(h, 1)); } -
For any one that needs it this is how I got the DHT22 to work.
This is my poor attempt at trying to get the DHT22 to work as the original code
https://github.com/cnerone/MySensorsArduinoExamples/blob/master/examples/DhtTemperatureAndHumiditySensor/DhtTemperatureAndHumiditySensor.ino
will not compile for me.// Enable debug prints #define MY_DEBUG // Enable and select radio type attached #define MY_RADIO_RF24 //#define MY_RADIO_RFM69 //#define MY_RS485 #define MY_RF24_CE_PIN 9 #define MY_RF24_CS_PIN 10 #include <SPI.h> #include <MySensors.h> #include <DHT.h> // Set this to the pin you connected the DHT's data pin to #define DHTPIN 2 // what digital pin we're connected to #define DHTTYPE DHT22 // DHT 22 (AM2302), AM2321 #define CHILD_ID_HUM 0 #define CHILD_ID_TEMP 1 MyMessage msgHum(CHILD_ID_HUM, V_HUM); MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP); DHT dht(DHTPIN, DHTTYPE); void presentation() { // Send the sketch version information to the gateway sendSketchInfo("TemperatureAndHumidity", "1.1"); // Register all sensors to gw (they will be created as child devices) present(CHILD_ID_HUM, S_HUM); present(CHILD_ID_TEMP, S_TEMP); } void setup() { dht.begin(); // set data pin of DHT sensor } void loop() { delay(2000); // Reading temperature or humidity takes about 250 milliseconds! // Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor) float h = dht.readHumidity(); // Read temperature as Celsius (the default) float t = dht.readTemperature(); // Read temperature as Fahrenheit (isFahrenheit = true) float f = dht.readTemperature(true); // Check if any reads failed and exit early (to try again). if (isnan(h) || isnan(t) || isnan(f)) { return; } // Compute heat index in Fahrenheit (the default) float hif = dht.computeHeatIndex(f, h); // Compute heat index in Celsius (isFahreheit = false) float hic = dht.computeHeatIndex(t, h, false); send(msgTemp.set(f, 1)); send(msgHum.set(h, 1)); }@catchra This bit might be important.....
"This example uses a modified version of the external DHT library, which is included in the MySensors external examples. Please install it and restart the Arduino IDE before trying to compile."Did you do this already?
-
@catchra This bit might be important.....
"This example uses a modified version of the external DHT library, which is included in the MySensors external examples. Please install it and restart the Arduino IDE before trying to compile."Did you do this already?