Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5

Temperature Sensor Options
#11

This is becoming quite the mystery.

I have attempted again today to get the DHT22 sensors to work including downloading from this forum the software again and ensuring my libraries match.

I have tried 3 different configuration files over two different TX boards which gives me the same results. These are titled:
  • Main TX board - my main transmitter unit with wind, rain, UV attached.
  • Ground TX board - secondary transmitter with ground and temperature.
  • Test configuration  - This was a fresh copy of the code downloaded once I started having issues in case any other configuration settings were conflicting.
.zip Config Files.zip Size: 6,02 KB  Downloads: 113


Main TX:
 
Code:
// --------------------------------------------------------------------------------------
//    WeatherDuino Pro2 Universal TX AT328 - Version: 7.0_b002
//           Start of user configurable options
// --------------------------------------------------------------------------------------


// --------------------------------------------------------------------------------------
//   Define ID and TX unit number
// --------------------------------------------------------------------------------------
#define Station_ID  0xA1    // Must be equal to your RX Unit (Value from 0x00 to 0xFF)  
#define Unit_ID        0    // If you use only one TX unit define it as Unit_ID = 0
                            // For a second TX unit, define it as Unit_ID = 1

// --------------------------------------------------------------------------------------
//   Define type of Temperature / Humidity sensor used as Sensor 0 and / or Sensor 1
// --------------------------------------------------------------------------------------
#define TH_SENSOR0  9      // [SENSOR 0] - 0 for SHT2x sensor, 1 for SHT31 sensor, 2 for HTU21 sensor, 9 for Not Used
#define TH_SENSOR1  1      // [SENSOR 1] - 0 for SHT1x sensor, 1 for DHT22 sensor, 9 for Not Used


// --------------------------------------------------------------------------------------
//   Define which Temp / Hum sensor controls the fan, and threshold values
// --------------------------------------------------------------------------------------
#define FANCONTROL_SENSOR  1      // 0 for Sensor 0, 1 for Sensor 1 (which sensor is used to control the RS Fan)
const int fanOn_HiTemp  = 25;     // RS Fan turn on when outside temperature is >= than this value (ºC)
const int fanOn_LowTemp =  2;     // RS Fan turn on when outside temperature is <= than this value (ºC)
const int fanOn_LowWind =  1;     // RS Fan turn on when Wind Average is <= than this value (m/s)


// --------------------------------------------------------------------------------------
//   Define type of Wind Speed sensor. See below for allowed types
// --------------------------------------------------------------------------------------
/*
--- Fine Offset Anemometers ---
Use 1O for standard FO anemometers
Use 11 for FO anemometer modified with 1 hall effect sensor

--- Inspeed Anemometers ---
Use 20 for Inspeed Vortex, digital 8 pulse revolution anemometer
Use 21 for Inspeed Vortex, hall efect sensor
Use 22 for Inspeed Vortex, read switch sensor

--- Davis Anemometers ---
Use 30 for Davis 6410, 7911 anemometer

--- Novalynx Anemometers ---
Use 40 for Novalynx, model 200-WS-02F

--- Environmental Measurements Limited ---
Use 50 for EML, model WSD1

--- Didcot Instrument Company ---
Use 60 for DIDCOT, model DWR205

--- Vector Instruments ---
Use 70 for Vector Instruments model A100LK
Use 71 for Vector Instruments model A100L2
Use 72 for Vector Instruments model A100R
*/
#define WINDSPEED_SENSORTYPE 10             // SEE INFO ABOVE!!!


// --------------------------------------------------------------------------------------
//   Define type of Wind Direction sensor
// --------------------------------------------------------------------------------------
/*
--- Fine Offset Wind Vane ---
Use 1O for standard FO wind vane

--- Analogue Wind Vanes ---
Use 20 for any 5V analogue wind vane. See bellow for a list of tested models

- Inspeed E-Vane 2
- Davis 6410
- Novalynx, model 200-WS-02F
- Environmental Measurements Limited, model model WSD1
- DIDCOT, model DWD205
- Almost all 5V analogue wind vanes will work

*/
#define WINDDIR_SENSORTYPE  10  // SEE INFO ABOVE!!!


// --------------------------------------------------------------------------------------
//          Analogue Vane Offset Calibration
// --------------------------------------------------------------------------------------
const int WDir_offs  = 0;   // Usually there is no need to change default value (zero)


// --------------------------------------------------------------------------------------
//   Define Rain Gauge tip boucket value (mm)
// --------------------------------------------------------------------------------------
/*
  Use 0.280 for standard FineOfset rain gauges (Datasheet value = 0.2794)
  Use 0.200 for standard metric Davis rain gauges
  Use 0.254 for standard imperial Davis rain gauges
*/  
#define COLLECTOR_TYPE  0.280  // Please note: Values must be in metric units. Max. resolution: 3 decimal digits
  

// --------------------------------------------------------------------------------------
//   Define type of UV Sensor
// --------------------------------------------------------------------------------------
#define UV_SENSOR  0      // 0= UVM-30A, 1= VEML6075, 9= Not used


// --------------------------------------------------------------------------------------
//   Soil / Leaf Interface Enable Disable
// --------------------------------------------------------------------------------------
#define SOILLEAF_INTERFACE        0    // 0 = Soil Leaf Interface not used, 1 = Enable Soil Leaf Interface
const byte Number_AnalogSensors = 2;   // Up to 4 analog sensors


// --------------------------------------------------------------------------------------
//   Define which data this unit will send. 0 = Not send this data, 1= Send this data
// --------------------------------------------------------------------------------------
#define ID0  1   // Temp/Hum Data
#define ID1  0   // Not Used
#define ID2  1   // Wind data
#define ID3  1   // Rain data
#define ID4  1   // SolRad / UV data
#define ID5  1   // Hardware Status - System Temp, Battery Voltage etc
#define ID7  0   // Send Soil & Leaf Temperature Data
#define ID9  0   // Send Soil & Leaf Moisture / Wetness Data


// --------------------------------------------------------------------------------------
//   VBat voltage fine tune (values in Volt, positive or negative)
// --------------------------------------------------------------------------------------
#define VBAT_OFFSET    0                  // Ex: 0.1 or -0.2


// *************************************************************************************
//     Hardware Settings
// *************************************************************************************
// Define if the TMP36 sensor is instaled
#define USE_TMP36       1          // 0= Not Instaled, 1= Intalled


// --------------------------------------------------------------------------------------
//   SHT31 I2C Address - Default address will work most of the times!
// --------------------------------------------------------------------------------------
#define SHT31_ADDRESS 0x44           // Default value is 0x44, but it can be changed to 0x45


// --------------------------------------------------------------------------------------
//   Debug
// --------------------------------------------------------------------------------------
#define ENABLE_DEBUG
#define DEBUG_ID0  
//#define DEBUG_ID2  
//#define DEBUG_ID3  
//#define DEBUG_ID4  
//#define DEBUG_ID5  
//#define DEBUG_SLINTERFACE
//#define EASYWEATHER_TEST  


// ---------------------------------------------------------------------------------------------------
//     End of user configurable options
// ---------------------------------------------------------------------------------------------------

Ground TX:
 
Code:
// --------------------------------------------------------------------------------------
//    WeatherDuino Pro2 Universal TX AT328 - Version: 7.0_b002
//           Start of user configurable options
// --------------------------------------------------------------------------------------


// --------------------------------------------------------------------------------------
//   Define ID and TX unit number
// --------------------------------------------------------------------------------------
#define Station_ID  0xA1    // Must be equal to your RX Unit (Value from 0x00 to 0xFF)  
#define Unit_ID        1    // If you use only one TX unit define it as Unit_ID = 0
                            // For a second TX unit, define it as Unit_ID = 1

// --------------------------------------------------------------------------------------
//   Define type of Temperature / Humidity sensor used as Sensor 0 and / or Sensor 1
// --------------------------------------------------------------------------------------
#define TH_SENSOR0  9      // [SENSOR 0] - 0 for SHT2x sensor, 1 for SHT31 sensor, 2 for HTU21 sensor, 9 for Not Used
#define TH_SENSOR1  1      // [SENSOR 1] - 0 for SHT1x sensor, 1 for DHT22 sensor, 9 for Not Used


// --------------------------------------------------------------------------------------
//   Define which Temp / Hum sensor controls the fan, and threshold values
// --------------------------------------------------------------------------------------
#define FANCONTROL_SENSOR  1      // 0 for Sensor 0, 1 for Sensor 1 (which sensor is used to control the RS Fan)
const int fanOn_HiTemp  = 26;     // RS Fan turn on when outside temperature is >= than this value (ºC)
const int fanOn_LowTemp =  2;     // RS Fan turn on when outside temperature is <= than this value (ºC)
const int fanOn_LowWind =  1;     // RS Fan turn on when Wind Average is <= than this value (m/s)


// --------------------------------------------------------------------------------------
//   Define type of Wind Speed sensor. See below for allowed types
// --------------------------------------------------------------------------------------
/*
--- Fine Offset Anemometers ---
Use 1O for standard FO anemometers
Use 11 for FO anemometer modified with 1 hall effect sensor

--- Inspeed Anemometers ---
Use 20 for Inspeed Vortex, digital 8 pulse revolution anemometer
Use 21 for Inspeed Vortex, hall efect sensor
Use 22 for Inspeed Vortex, read switch sensor

--- Davis Anemometers ---
Use 30 for Davis 6410, 7911 anemometer

--- Novalynx Anemometers ---
Use 40 for Novalynx, model 200-WS-02F

--- Environmental Measurements Limited ---
Use 50 for EML, model WSD1

--- Didcot Instrument Company ---
Use 60 for DIDCOT, model DWR205

--- Vector Instruments ---
Use 70 for Vector Instruments model A100LK
Use 71 for Vector Instruments model A100L2
Use 72 for Vector Instruments model A100R
*/
#define WINDSPEED_SENSORTYPE 10             // SEE INFO ABOVE!!!


// --------------------------------------------------------------------------------------
//   Define type of Wind Direction sensor
// --------------------------------------------------------------------------------------
/*
--- Fine Offset Wind Vane ---
Use 1O for standard FO wind vane

--- Analogue Wind Vanes ---
Use 20 for any 5V analogue wind vane. See bellow for a list of tested models

- Inspeed E-Vane 2
- Davis 6410
- Novalynx, model 200-WS-02F
- Environmental Measurements Limited, model model WSD1
- DIDCOT, model DWD205
- Almost all 5V analogue wind vanes will work

*/
#define WINDDIR_SENSORTYPE  10  // SEE INFO ABOVE!!!


// --------------------------------------------------------------------------------------
//          Analogue Vane Offset Calibration
// --------------------------------------------------------------------------------------
const int WDir_offs  = 0;   // Usually there is no need to change default value (zero)


// --------------------------------------------------------------------------------------
//   Define Rain Gauge tip boucket value (mm)
// --------------------------------------------------------------------------------------
/*
  Use 0.280 for standard FineOfset rain gauges (Datasheet value = 0.2794)
  Use 0.200 for standard metric Davis rain gauges
  Use 0.254 for standard imperial Davis rain gauges
*/  
#define COLLECTOR_TYPE  0.280  // Please note: Values must be in metric units. Max. resolution: 3 decimal digits
  

// --------------------------------------------------------------------------------------
//   Define type of UV Sensor
// --------------------------------------------------------------------------------------
#define UV_SENSOR  9      // 0= UVM-30A, 1= VEML6075, 9= Not used


// --------------------------------------------------------------------------------------
//   Soil / Leaf Interface Enable Disable
// --------------------------------------------------------------------------------------
#define SOILLEAF_INTERFACE        1    // 0 = Soil Leaf Interface not used, 1 = Enable Soil Leaf Interface
const byte Number_AnalogSensors = 4;   // Up to 4 analog sensors


// --------------------------------------------------------------------------------------
//   Define which data this unit will send. 0 = Not send this data, 1= Send this data
// --------------------------------------------------------------------------------------
#define ID0  1   // Temp/Hum Data
#define ID1  0   // Not Used
#define ID2  0   // Wind data
#define ID3  0   // Rain data
#define ID4  0   // SolRad / UV data
#define ID5  1   // Hardware Status - System Temp, Battery Voltage etc
#define ID7  1   // Send Soil & Leaf Temperature Data
#define ID9  1   // Send Soil & Leaf Moisture / Wetness Data


// --------------------------------------------------------------------------------------
//   VBat voltage fine tune (values in Volt, positive or negative)
// --------------------------------------------------------------------------------------
#define VBAT_OFFSET    0.8                  // Ex: 0.1 or -0.2


// *************************************************************************************
//     Hardware Settings
// *************************************************************************************
// Define if the TMP36 sensor is instaled
#define USE_TMP36       1          // 0= Not Instaled, 1= Intalled


// --------------------------------------------------------------------------------------
//   SHT31 I2C Address - Default address will work most of the times!
// --------------------------------------------------------------------------------------
#define SHT31_ADDRESS 0x44           // Default value is 0x44, but it can be changed to 0x45


// --------------------------------------------------------------------------------------
//   Debug
// --------------------------------------------------------------------------------------
#define ENABLE_DEBUG
#define DEBUG_ID0  
//#define DEBUG_ID2  
//#define DEBUG_ID3  
//#define DEBUG_ID4  
//#define DEBUG_ID5  
//#define DEBUG_SLINTERFACE
//#define EASYWEATHER_TEST  


// ---------------------------------------------------------------------------------------------------
//     End of user configurable options
// ---------------------------------------------------------------------------------------------------

Freshly downloaded from the forum configuration:
Code:
// --------------------------------------------------------------------------------------
//    WeatherDuino Pro2 Universal TX AT328 - Version: 7.0_b003
//           Start of user configurable options
// --------------------------------------------------------------------------------------


// --------------------------------------------------------------------------------------
//   Define ID and TX unit number
// --------------------------------------------------------------------------------------
#define Station_ID  0xA1    // Must be equal to your RX Unit (Value from 0x00 to 0xFF)  
#define Unit_ID        1    // If you use only one TX unit define it as Unit_ID = 0
                            // For a second TX unit, define it as Unit_ID = 1

// --------------------------------------------------------------------------------------
//   Define type of Temperature / Humidity sensor used as Sensor 0 and / or Sensor 1
// --------------------------------------------------------------------------------------
#define TH_SENSOR0  9      // [SENSOR 0] - 0 for SHT2x sensor, 1 for SHT31 sensor, 2 for HTU21 sensor, 9 for Not Used
#define TH_SENSOR1  1      // [SENSOR 1] - 0 for SHT1x sensor, 1 for DHT22 sensor, 9 for Not Used


// --------------------------------------------------------------------------------------
//   Define which Temp / Hum sensor controls the RS fan, and threshold values
// --------------------------------------------------------------------------------------
#define FANCONTROL_SENSOR  0      // 0 for Sensor 0, 1 for Sensor 1 (which sensor is used to control the RS Fan)
const int fanOn_HiTemp  =  19;     // RS Fan turn on when outside temperature is >= than this value (ºC)
const int fanOn_LowTemp =  2;     // RS Fan turn on when outside temperature is <= than this value (ºC)
const int fanOn_LowWind =  1;     // RS Fan turn on when Wind Average is <= than this value (m/s)


// --------------------------------------------------------------------------------------
//   Define type of Wind Speed sensor. See below for allowed types
// --------------------------------------------------------------------------------------
/*
--- Fine Offset Anemometers ---
Use 1O for standard FO anemometers
Use 11 for FO anemometer modified with 1 hall effect sensor

--- Inspeed Anemometers ---
Use 20 for Inspeed Vortex, digital 8 pulse revolution anemometer
Use 21 for Inspeed Vortex, hall efect sensor
Use 22 for Inspeed Vortex, read switch sensor

--- Davis Anemometers ---
Use 30 for Davis 6410, 7911 anemometer

--- Novalynx Anemometers ---
Use 40 for Novalynx, model 200-WS-02F

--- Environmental Measurements Limited ---
Use 50 for EML, model WSD1

--- Didcot Instrument Company ---
Use 60 for DIDCOT, model DWR205

--- Vector Instruments ---
Use 70 for Vector Instruments model A100LK
Use 71 for Vector Instruments model A100L2
Use 72 for Vector Instruments model A100R
*/
#define WINDSPEED_SENSORTYPE 10             // SEE INFO ABOVE!!!


// --------------------------------------------------------------------------------------
//   Define type of Wind Direction sensor
// --------------------------------------------------------------------------------------
/*
--- Fine Offset Wind Vane ---
Use 1O for standard FO wind vane

--- Analogue Wind Vanes ---
Use 20 for any 5V analogue wind vane. See bellow for a list of tested models

- Inspeed E-Vane 2
- Davis 6410
- Novalynx, model 200-WS-02F
- Environmental Measurements Limited, model model WSD1
- DIDCOT, model DWD205
- Almost all 5V analogue wind vanes will work

*/
#define WINDDIR_SENSORTYPE  10  // SEE INFO ABOVE!!!


// --------------------------------------------------------------------------------------
//          Analogue Vane Offset Calibration
// --------------------------------------------------------------------------------------
const int WDir_offs  = 0;   // Usually there is no need to change default value (zero)


// --------------------------------------------------------------------------------------
//   Define Rain Gauge tip boucket value (mm)
// --------------------------------------------------------------------------------------
/*
  Use 0.280 for standard FineOfset rain gauges (Datasheet value = 0.2794)
  Use 0.200 for standard metric Davis rain gauges
  Use 0.254 for standard imperial Davis rain gauges
*/  
#define COLLECTOR_TYPE  0.280  // Please note: Values must be in metric units. Max. resolution: 3 decimal digits
  

// --------------------------------------------------------------------------------------
//   Define type of UV Sensor
// --------------------------------------------------------------------------------------
#define UV_SENSOR  9      // 0= UVM-30A, 1= VEML6075, 9= Not used


// --------------------------------------------------------------------------------------
//   Soil / Leaf Interface Enable Disable
// --------------------------------------------------------------------------------------
#define SOILLEAF_INTERFACE        0    // 0 = Soil Leaf Interface not used, 1 = Enable Soil Leaf Interface
const byte Number_AnalogSensors = 2;   // Up to 4 analog sensors


// --------------------------------------------------------------------------------------
//   Define which data this unit will send. 0 = Not send this data, 1= Send this data
// --------------------------------------------------------------------------------------
#define ID0  1   // Temp/Hum Data
#define ID1  0   // Not Used
#define ID2  1   // Wind data
#define ID3  1   // Rain data
#define ID4  0   // SolRad / UV data
#define ID5  1   // Hardware Status - System Temp, Battery Voltage etc
#define ID7  0   // Send Soil & Leaf Temperature Data
#define ID9  0   // Send Soil & Leaf Moisture / Wetness Data


// --------------------------------------------------------------------------------------
//   VBat voltage fine tune (values in Volt, positive or negative)
// --------------------------------------------------------------------------------------
#define VBAT_OFFSET    0.0                  //


// *************************************************************************************
//     Hardware Settings
// *************************************************************************************
// Define if the TMP36 sensor is instaled
#define USE_TMP36       0          // 0= Not Instaled, 1= Intalled


// --------------------------------------------------------------------------------------
//   SHT31 I2C Address - Default address will work most of the times!
// --------------------------------------------------------------------------------------
#define SHT31_ADDRESS 0x44           // Default value is 0x44, but it can be changed to 0x45


// --------------------------------------------------------------------------------------
//   Debug
// --------------------------------------------------------------------------------------
#define ENABLE_DEBUG
#define DEBUG_ID0  
//#define DEBUG_ID2  
//#define DEBUG_ID3  
//#define DEBUG_ID4  
//#define DEBUG_ID5  
//#define DEBUG_SLINTERFACE
//#define EASYWEATHER_TEST  


// ---------------------------------------------------------------------------------------------------
//     End of user configurable options
// ---------------------------------------------------------------------------------------------------

For reference, I have tested this sensor using TX software build v7.0_b002 on my main board code and existing configuration with the same outcome.
   
Reply
#12

This evening I started to play with the routine within the WeatherDuino software which manages the DHT22 readings, with results I feel are interesting when the multiplier is adjusted.

Original code:
 
Code:
#if (TH_SENSOR1 == 1)
    // -----  Read temperature from DHT22 (in celsius) -------
    void read_DHT22()
    {
      dht.reading(T_ExtS1, H_ExtS1);
      T_ExtS1 = T_ExtS1 * 10;
      H_ExtS1 = H_ExtS1 * 10;
    }
  #endif

If I change the "*10;" to "*2;", each time the data is displayed, the numbers are doubled: 5.06, 10.12, 20.24, 40.48...
If the "*10;" is changed to "*100;", there is no clear pattern to the number outputs.

When analysing the serial output data when the routine multiplier is set to the default of "*10;", I note that the decimal point shift in a similar pattern to how it is being multiplied and the numbers doubled when I set the multiplier to 2.
 
Code:
Sending ID0...
  Sensor 0 - Temp: 0.00  Hum: 0.00
  Sensor 1 - Temp: 27.40  Hum: 59.20

Sending ID0...
  Sensor 0 - Temp: 0.00  Hum: 0.00
  Sensor 1 - Temp: 274.00  Hum: 0.00

In my tests, I note that once the humidity value exceeds 100, it will always return a 0.00 or a 99.90 result on the serial output.

Could the answer be within this test done within the routine file for these random numbers to be coming from the sensor? It is almost like a variable remembering/retaining the last value and not replacing it before it is processed again.


Attached Files Image(s)
       
Reply
#13

(31-12-2023, 06:26)Palmyweather Wrote:  If the "*10;" is changed to "*100;", there is no clear pattern to the number outputs.

Hi Mathew,

When you change the multiplier to *100 you are producing a variable overflow thus the random results.

Have you noticed that the first reading is always correct?
From your experiments, what seems to me is that this instruction:

Code:
dht.reading(T_ExtS1, H_ExtS1);

is only exectuded one time, or the values of the vars T_ExtS1 and H_ExtS1 aren't updated when it runs. The problem must be here. Why, I still don't know.
The DHTxx library have some debug options, try to enable them and see if any clue can come from them.

The mystery is why it stoped work with your new sensors, while it worked with old ones, and also works with my DHT22 sensors?

I haven't had time yet to test with the config files you sent, but I will do it as soon as I can. Indeed this thing started to be a more and more interesting mystery.

Which version of Arduino IDE are you using to compile the code?

Rgs.
Werk_AG

Reply
#14

Hi again

Yes, I notice the first reading is always correct. And it seems to never clear that variable once set. Hence my trial of the multiplier by 2, 10 and 100 which confirmed that the variable never updated.

Currently I am using the following to compile the code:
Arduino IDE: 1.8.5
Arduino AVR board version: 1.6.21

Sadly I am unsure how to enable the debug mode within the DHTxx library.

Probably a pointless test:
To try and confirm if the error is in the "dht.reading" line, I added two lines which set the variables to zero before the reading is done. Conclusion from doing this, it successfully takes one reading before returning zero after that. Therefore I conclude that it is not getting another reading to repopulate the variable, not calling the correct routine.
 
Code:
#if (TH_SENSOR1 == 1)
    // -----  Read temperature from DHT22 (in celsius) -------
    void read_DHT22()
    {
      T_ExtS1 = 0;  // Added line for testing
      H_ExtS1 = 0; // Added line for testing
      dht.reading(T_ExtS1, H_ExtS1);
      T_ExtS1 = T_ExtS1 * 10;
      H_ExtS1 = H_ExtS1 * 10;
    }
  #endif

Serial Output by adding above two lines of code:
 
Code:
Sending ID0...
  Sensor 0 - Temp: 0.00  Hum: 0.00
  Sensor 1 - Temp: 24.20  Hum: 54.10

Sending ID0...
  Sensor 0 - Temp: 0.00  Hum: 0.00
  Sensor 1 - Temp: 0.00  Hum: 0.00

Sending ID0...
  Sensor 0 - Temp: 0.00  Hum: 0.00
  Sensor 1 - Temp: 0.00  Hum: 0.00

Sending ID0...
  Sensor 0 - Temp: 0.00  Hum: 0.00
  Sensor 1 - Temp: 0.00  Hum: 0.00

Sadly I do not really know enough about the detailed workings of the code to be much help I'm sorry.

What I might try just for fun is buy some "generic" DHT22 sensors and see if I get any different results. Only thing is the time it will take to get from China with no local source.

I will continue with looking for some cost effective SHT10 temperature sensors too, but I do not think that will be easily found these days.

I would like to continue to work with SHT10 or DHT22 because of the distance in cable between sensor and transmitter as it would be challenging to position the ground sensors which are connected to this board while maintaining above ground temperature reading accuracy without the sun causing excessive heat build up during the day.

Thank you for your help,
Matthew
Reply
#15

(04-01-2024, 09:22)Palmyweather Wrote:  Probably a pointless test:
To try and confirm if the error is in the "dht.reading" line, I added two lines which set the variables to zero before the reading is done. Conclusion from doing this, it successfully takes one reading before returning zero after that. Therefore I conclude that it is not getting another reading to repopulate the variable, not calling the correct routine.
 
Code:
#if (TH_SENSOR1 == 1)
    // -----  Read temperature from DHT22 (in celsius) -------
    void read_DHT22()
    {
      T_ExtS1 = 0;  // Added line for testing
      H_ExtS1 = 0; // Added line for testing
      dht.reading(T_ExtS1, H_ExtS1);
      T_ExtS1 = T_ExtS1 * 10;
      H_ExtS1 = H_ExtS1 * 10;
    }
  #endif

That confirms my thoughts on last post. After the first reading, further readings fail.

If you want to enable the debug info of the DTHxx library, open the DHTxx.cpp file and on this line change the value to 1

Code:
#define DEBUG_DHT 0 // add code to send info over the serial port of non-zero

Save and compile (later don't forget to disable the Debug output).

If possible please also check if there is 5V on the Dat pin (provided by the pull-up resistor on the TX pcb).
Reply
#16

Thank you for the additional suggestions

Measuring the voltage across the data pin to ground gives 4.4VDC reading.

I have enabled the serial data output from the DHTxx library with the below results. I note that the serial data from the DHTxx library only displays once on the initial reading and not again.
 
Code:
DHT 14 3 4 4 4 4 3 12 4 4 12 4 12 4 12 4 4 4 3 4 3 4 4 4 4 12 12 12 3 4 4 12 4 4 4 12 12 12 3 4 4
HEX 15 2 54 0 E2 38 : 38
Sending ID0...
  Sensor 0 - Temp: 0.00  Hum: 0.00
  Sensor 1 - Temp: 22.60  Hum: 59.60

Sending ID0...
  Sensor 0 - Temp: 0.00  Hum: 0.00
  Sensor 1 - Temp: 226.00  Hum: 0.00

Sending ID0...
  Sensor 0 - Temp: 0.00  Hum: 0.00
  Sensor 1 - Temp: 293.92  Hum: 0.00

Sending ID0...
  Sensor 0 - Temp: 0.00  Hum: 0.00
  Sensor 1 - Temp: 317.76  Hum: 0.00

Sending ID0...
  Sensor 0 - Temp: 0.00  Hum: 0.00
  Sensor 1 - Temp: -99.20  Hum: 0.00

After board reset:
Code:
DHT 14 4 4 4 3 4 3 12 3 4 11 12 3 4 12 4 4 4 3 4 4 4 4 3 4 11 12 12 4 3 4 11 12 4 12 4 4 12 4 3 12
HEX 15 2 64 0 E3 49 : 49
Sending ID0...
  Sensor 0 - Temp: 0.00  Hum: 0.00
  Sensor 1 - Temp: 22.70  Hum: 61.20

Sending ID0...
  Sensor 0 - Temp: 0.00  Hum: 0.00
  Sensor 1 - Temp: 227.00  Hum: 0.00

Sending ID0...
  Sensor 0 - Temp: 0.00  Hum: 0.00
  Sensor 1 - Temp: 303.92  Hum: 0.00

Sending ID0...
  Sensor 0 - Temp: 0.00  Hum: 0.00
  Sensor 1 - Temp: -237.60  Hum: 0.00

Sending ID0...
  Sensor 0 - Temp: 0.00  Hum: 0.00
  Sensor 1 - Temp: 245.44  Hum: 0.00

So it looks like additional requests for data of the DHT sensor is not occurring.

As an idea, would you mind zipping up your working code with the DHT sensor you tested last week and supplying it with the library etc to see if I can get your code to work correctly on mine?

I have ordered new DHT22 sensors from China, due end of the month. It will be interesting to see what results I get then if we cannot find a solution before that point.

Thank you once again for your help.


Attached Files Image(s)
       
Reply
#17

(05-01-2024, 07:47)Palmyweather Wrote:  I have enabled the serial data output from the DHTxx library with the below results. I note that the serial data from the DHTxx library only displays once on the initial reading and not again.
 
Code:
DHT 14 3 4 4 4 4 3 12 4 4 12 4 12 4 12 4 4 4 3 4 3 4 4 4 4 12 12 12 3 4 4 12 4 4 4 12 12 12 3 4 4
HEX 15 2 54 0 E2 38 : 38
Sending ID0...
  Sensor 0 - Temp: 0.00  Hum: 0.00
  Sensor 1 - Temp: 22.60  Hum: 59.60

Sending ID0...
  Sensor 0 - Temp: 0.00  Hum: 0.00
  Sensor 1 - Temp: 226.00  Hum: 0.00

Sending ID0...
  Sensor 0 - Temp: 0.00  Hum: 0.00
  Sensor 1 - Temp: 293.92  Hum: 0.00

Sending ID0...
  Sensor 0 - Temp: 0.00  Hum: 0.00
  Sensor 1 - Temp: 317.76  Hum: 0.00

Sending ID0...
  Sensor 0 - Temp: 0.00  Hum: 0.00
  Sensor 1 - Temp: -99.20  Hum: 0.00

After board reset:
Code:
DHT 14 4 4 4 3 4 3 12 3 4 11 12 3 4 12 4 4 4 3 4 4 4 4 3 4 11 12 12 4 3 4 11 12 4 12 4 4 12 4 3 12
HEX 15 2 64 0 E3 49 : 49
Sending ID0...
  Sensor 0 - Temp: 0.00  Hum: 0.00
  Sensor 1 - Temp: 22.70  Hum: 61.20

Sending ID0...
  Sensor 0 - Temp: 0.00  Hum: 0.00
  Sensor 1 - Temp: 227.00  Hum: 0.00

Sending ID0...
  Sensor 0 - Temp: 0.00  Hum: 0.00
  Sensor 1 - Temp: 303.92  Hum: 0.00

Sending ID0...
  Sensor 0 - Temp: 0.00  Hum: 0.00
  Sensor 1 - Temp: -237.60  Hum: 0.00

Sending ID0...
  Sensor 0 - Temp: 0.00  Hum: 0.00
  Sensor 1 - Temp: 245.44  Hum: 0.00

So it looks like additional requests for data of the DHT sensor is not occurring.

The requests are happening, but the sensor doesn't reply within the time defined on the library, so the reading is aborted. I don't know why. Interistingly the wakeup timmings on the DHTxx libary are the same used by the other DHT library which works for you.



(05-01-2024, 07:47)Palmyweather Wrote:  As an idea, would you mind zipping up your working code with the DHT sensor you tested last week and supplying it with the library etc to see if I can get your code to work correctly on mine?

I did my tests with the original WeatherDuino TX software and the DHT22 sensor connected to the TX board. So you already have the code I used.

Maybe we should wait until you get the new batch of DHT22 sensors, but if you would like to continue doing more to discover this mistery, try this:

Search on the DHTxx.cpp file for the part of the code show bellow, them replace the value of "250" to "400" on the two places (lines 37 and 44). Save the changes, compile the code again and upload.
This just increases the time waiting for an answer.

Code:
for (timer = 0; timer < 250; ++timer)
        if (digitalRead(pin) != j)
          break;
#if DEBUG_DHT
    times[i] = timer;
#endif
    // if no transition was seen, return
    if (timer >= 250) {

Rgs.
Werk_AG

Reply
#18

I have run some tests by changing the two timer values within the DHTxx.cpp file.

Initially set to 400 per your suggestion. I get a single reading only and no further serial output data comes (left for 5 minutes before tying something else).

I also tried values of 300, 500, 260 with the same results: one single reading only displayed through the serial output.

Trying value 255 provides regular serial outputs, but only the initial output is the correct value.

I also tried lowering the timer value: 200, 150, 100 which provides regular serial outputs, but only the initial output is the correct value.

Serial output at timer values of 400:
Code:
DHT 14 4 4 4 4 4 4 4 12 12 12 12 4 12 12 4 12 4 4 4 4 4 3 3 12 4 3 3 11 3 3 4 12 3 4 4 4 4 4 4 4
HEX 15 1 ED 1 11 0 : 0
Sending ID0...
  Sensor 0 - Temp: 0.00  Hum: 0.00
  Sensor 1 - Temp: 27.30  Hum: 49.30

(No further data ever received)

Kind regards,
Matthew
Reply
#19

Today the second order of DHT22 sensors arrived. These are "generic" sensors. The first lot I ordered were "original" or "genuine" DHT22 sensors.

Sadly the results are the same with the second delivery of sensors.

Today's tests included editing the DHT library as previously suggested along with using the original values.
 
Code:
for (timer = 0; timer < 250; ++timer)
        if (digitalRead(pin) != j)
          break;
#if DEBUG_DHT
    times[i] = timer;
#endif
    // if no transition was seen, return
    if (timer >= 250) {

Links to the products I have purchased:
https://www.aliexpress.com/item/1005004445311402.html
https://www.aliexpress.com/item/1005005046929046.html

Sadly I think I will need to end my attempts to use the DHT22 sensor for this project and revert back to SHT10 which I know work.

Thank you for your help along this journey.
Matt


Attached Files Image(s)
           
Reply
#20

Hello Matt

Unfortunatelly I can't reproduce the issue. I tested with all DHT22 I have (4 units) and I can read data from all of them.

Test environment:

- Windows 11
- Arduino IDE 1.8.9
- Avr boards v1.6.21 (very important)
- TX board v3.12
- Published WeatherDuino_Pro2_Universal_TX_v7.0_b003 software
- Compiled with all debug options disabled except ENABLE_DEBUG and DEBUG_ID0


https://www.meteocercal.info/forum/video..._DHT22.mp4
Reply




Users browsing this thread: 1 Guest(s)