Skip to content

Commit

Permalink
Arduino ci (#4)
Browse files Browse the repository at this point in the history
* update to 0.2.7
  • Loading branch information
RobTillaart authored Dec 20, 2020
1 parent 27d02ce commit ff02f93
Show file tree
Hide file tree
Showing 10 changed files with 131 additions and 89 deletions.
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

# DHTstable

Arduino Library for the DHT temperature and humidity sensor.
Arduino Library for the DHT11 and DHT22 temperature and humidity sensor.

## Description

Expand All @@ -14,20 +14,23 @@ This version is stable for both ARM and AVR.

0.2.5 is a migration to its own repository.
0.2.6 fixed URL to new repro
0.2.7 getTemperature() and getHumidity() added
added arduino-ci + unit test.

The latest developments for the DHT sensors are done in https://github.com/RobTillaart/DHTNEW
which is also tested on an ESP32.
There are some interface differences but these are relative small.

It is adviced to upgrade to the DHTNEW library if one needs new functionality.

## Multiple DHT.h includes
## Multiple dht.h includes

Note that the include file is called dht.h (for compatibily reasons)
this might need a rename in sketch and library if there is a conflict.

## TODO (optional)
* rename it to dhtstable.h + dhtstable.cpp ( 0.3.0 version some day )

- rename files to dhtstable.h + dhtstable.cpp ( 0.3.0 version some day )

## Operational

Expand Down
59 changes: 36 additions & 23 deletions dht.cpp
Original file line number Diff line number Diff line change
@@ -1,33 +1,35 @@
//
// FILE: dht.cpp
// AUTHOR: Rob Tillaart
// VERSION: 0.2.6
// VERSION: 0.2.7
// PURPOSE: DHT Temperature & Humidity Sensor library for Arduino
// URL: https://github.com/RobTillaart/DHTstable
//
// HISTORY:
// 0.2.6 2020-07-20 update URL in .cpp
// 0.2.5 2020-06-30 move to own repository; update headers mainly.
// 0.2.4 2018-04-03 add get-/setDisableIRQ(bool b)
// 0.2.3 2018-02-21 change #defines in const int to enforce return types.
// https://github.com/RobTillaart/Arduino/issues/94
// 0.2.2 2017-12-12 add support for AM23XX types more explicitly
// 0.2.1 2017-09-20 fix https://github.com/RobTillaart/Arduino/issues/80
// 0.2.0 2017-07-24 fix https://github.com/RobTillaart/Arduino/issues/31 + 33
// 0.1.13 fix negative temperature
// 0.1.12 support DHT33 and DHT44 initial version
// 0.1.11 renamed DHTLIB_TIMEOUT
// 0.1.10 optimized faster WAKEUP + TIMEOUT
// 0.1.09 optimize size: timeout check + use of mask
// 0.1.08 added formula for timeout based upon clockspeed
// 0.1.07 added support for DHT21
// 0.1.06 minimize footprint (2012-12-27)
// 0.1.05 fixed negative temperature bug (thanks to Roseman)
// 0.1.04 improved readability of code using DHTLIB_OK in code
// 0.1.03 added error values for temp and humidity when read failed
// 0.1.02 added error codes
// 0.1.01 added support for Arduino 1.0, fixed typos (31/12/2011)
// 0.1.0 by Rob Tillaart (01/04/2011)
// 0.2.7 2020-12-20 add arduino-CI, unit test,
// reset(), getTemperature(), getHumidity()
// 0.2.6 2020-07-20 update URL in .cpp
// 0.2.5 2020-06-30 move to own repository; update headers mainly.
// 0.2.4 2018-04-03 add get-/setDisableIRQ(bool b)
// 0.2.3 2018-02-21 change #defines in const int to enforce return types.
// https://github.com/RobTillaart/Arduino/issues/94
// 0.2.2 2017-12-12 add support for AM23XX types more explicitly
// 0.2.1 2017-09-20 fix https://github.com/RobTillaart/Arduino/issues/80
// 0.2.0 2017-07-24 fix https://github.com/RobTillaart/Arduino/issues/31 + 33
// 0.1.13 fix negative temperature
// 0.1.12 support DHT33 and DHT44 initial version
// 0.1.11 renamed DHTLIB_TIMEOUT
// 0.1.10 optimized faster WAKEUP + TIMEOUT
// 0.1.09 optimize size: timeout check + use of mask
// 0.1.08 added formula for timeout based upon clockspeed
// 0.1.07 added support for DHT21
// 0.1.06 minimize footprint (2012-12-27)
// 0.1.05 fixed negative temperature bug (thanks to Roseman)
// 0.1.04 improved readability of code using DHTLIB_OK in code
// 0.1.03 added error values for temp and humidity when read failed
// 0.1.02 added error codes
// 0.1.01 added support for Arduino 1.0, fixed typos (31/12/2011)
// 0.1.0 by Rob Tillaart (01/04/2011)
//
// inspired by DHT11 library
//
Expand All @@ -38,6 +40,17 @@
//
// PUBLIC
//
dht::dht()
{
reset();
}

void dht::reset()
{
temperature = 0.0;
humidity = 0.0;
_disableIRQ = false;
}

// return values:
// DHTLIB_OK
Expand Down
22 changes: 16 additions & 6 deletions dht.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//
// FILE: dht.h
// AUTHOR: Rob Tillaart
// VERSION: 0.2.6
// VERSION: 0.2.7
// PURPOSE: DHT Temperature & Humidity Sensor library for Arduino
// URL: https://github.com/RobTillaart/DHTstable
//
Expand All @@ -18,7 +18,7 @@
#include <Arduino.h>
#endif

#define DHT_LIB_VERSION "0.2.6 - dhtstable"
#define DHT_LIB_VERSION "0.2.7 - dhtstable"

const int DHTLIB_OK = 0;
const int DHTLIB_ERROR_CHECKSUM = -1;
Expand All @@ -38,6 +38,10 @@ const int DHTLIB_TIMEOUT = (F_CPU/40000);
class dht
{
public:
dht();

void reset();

// return values:
// DHTLIB_OK
// DHTLIB_ERROR_CHECKSUM
Expand All @@ -55,18 +59,24 @@ class dht
inline int read2320(uint8_t pin) { return read(pin); }; //.ok
inline int read2322(uint8_t pin) { return read(pin); }; // ok

// preferred interface.
float getHumidity() { return humidity; };
float getTemperature() { return temperature; };

// write access will be obsolete in future version
float humidity;
float temperature;

bool getDisableIRQ() { return _disableIRQ; };
void setDisableIRQ(bool b ) { _disableIRQ = b; };
bool getDisableIRQ() { return _disableIRQ; };
void setDisableIRQ(bool b ) { _disableIRQ = b; };

private:
uint8_t bits[5]; // buffer to receive data
int _readSensor(uint8_t pin, uint8_t wakeupDelay);
bool _disableIRQ = false;
};

#endif
//


// END OF FILE
//
33 changes: 17 additions & 16 deletions examples/dht11_test/dht11_test.ino
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
//
// FILE: dht11_test.ino
// AUTHOR: Rob Tillaart
// VERSION: 0.1.2
// VERSION: 0.2.0
// PURPOSE: DHT library test sketch for DHT11 && Arduino
// URL: https://github.com/RobTillaart/DHTstable
//
// HISTORY:
// 0.1.2 add URL in header
// 0.2.0 use getHumidity() and getTemperature()
// 0.1.2 add URL in header

#include <dht.h>

#include "dht.h"

dht DHT;

Expand All @@ -17,7 +19,7 @@ dht DHT;
void setup()
{
Serial.begin(115200);
Serial.println("DHT TEST PROGRAM ");
Serial.println(__FILE__);
Serial.print("LIBRARY VERSION: ");
Serial.println(DHT_LIB_VERSION);
Serial.println();
Expand All @@ -32,25 +34,24 @@ void loop()
switch (chk)
{
case DHTLIB_OK:
Serial.print("OK,\t");
break;
Serial.print("OK,\t");
break;
case DHTLIB_ERROR_CHECKSUM:
Serial.print("Checksum error,\t");
break;
Serial.print("Checksum error,\t");
break;
case DHTLIB_ERROR_TIMEOUT:
Serial.print("Time out error,\t");
break;
Serial.print("Time out error,\t");
break;
default:
Serial.print("Unknown error,\t");
break;
Serial.print("Unknown error,\t");
break;
}
// DISPLAY DATA
Serial.print(DHT.humidity, 1);
Serial.print(DHT.getHumidity(), 1);
Serial.print(",\t");
Serial.println(DHT.temperature, 1);
Serial.println(DHT.getTemperature(), 1);

delay(2000);
}
//

// END OF FILE
//
28 changes: 14 additions & 14 deletions examples/dht12_test/dht12_test.ino
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
//
// FILE: dht12_test.ino
// AUTHOR: Rob Tillaart
// VERSION: 0.1.1
// VERSION: 0.2.0
// PURPOSE: DHT library test sketch for DHT12 && Arduino
// URL: https://github.com/RobTillaart/DHTstable
//
// HISTORY:
// 0.2.0 use getHumidity() and getTemperature()
// 0.1.1 add URL in header

#include <dht.h>
Expand All @@ -17,7 +18,7 @@ dht DHT;
void setup()
{
Serial.begin(115200);
Serial.println("DHT TEST PROGRAM ");
Serial.println(__FILE__);
Serial.print("LIBRARY VERSION: ");
Serial.println(DHT_LIB_VERSION);
Serial.println();
Expand All @@ -32,25 +33,24 @@ void loop()
switch (chk)
{
case DHTLIB_OK:
Serial.print("OK,\t");
break;
Serial.print("OK,\t");
break;
case DHTLIB_ERROR_CHECKSUM:
Serial.print("Checksum error,\t");
break;
Serial.print("Checksum error,\t");
break;
case DHTLIB_ERROR_TIMEOUT:
Serial.print("Time out error,\t");
break;
Serial.print("Time out error,\t");
break;
default:
Serial.print("Unknown error,\t");
break;
Serial.print("Unknown error,\t");
break;
}
// DISPLAY DATA
Serial.print(DHT.humidity, 1);
Serial.print(DHT.getHumidity(), 1);
Serial.print(",\t");
Serial.println(DHT.temperature, 1);
Serial.println(DHT.getTemperature(), 1);

delay(2000);
}
//

// END OF FILE
//
26 changes: 14 additions & 12 deletions examples/dht22_test/dht22_test.ino
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
//
// FILE: dht22_test.ino
// AUTHOR: Rob Tillaart
// VERSION: 0.1.4
// VERSION: 0.2.0
// PURPOSE: DHT library test sketch for DHT22 && Arduino
// URL: https://github.com/RobTillaart/DHTstable
//
// HISTORY:
// 0.1.4 add URL in header
// 0.1.03 extended stats for all errors
// 0.1.02 added counters for error-regression testing.
// 0.1.01
// 0.1.00 initial version
// 0.2.0 use getHumidity() and getTemperature()
// 0.1.4 add URL in header
// 0.1.03 extended stats for all errors
// 0.1.02 added counters for error-regression testing.
// 0.1.01 ?
// 0.1.00 initial version
//

#include <dht.h>
#include "dht.h"

dht DHT;

Expand All @@ -34,7 +35,7 @@ struct
void setup()
{
Serial.begin(115200);
Serial.println("dht22_test.ino");
Serial.println(__FILE__);
Serial.print("LIBRARY VERSION: ");
Serial.println(DHT_LIB_VERSION);
Serial.println();
Expand Down Expand Up @@ -70,14 +71,16 @@ void loop()
Serial.print("Unknown error,\t");
break;
}

// DISPLAY DATA
Serial.print(DHT.humidity, 1);
Serial.print(DHT.getHumidity(), 1);
Serial.print(",\t");
Serial.print(DHT.temperature, 1);
Serial.print(DHT.getTemperature(), 1);
Serial.print(",\t");
Serial.print(stop - start);
Serial.println();

// DISPLAY COUNTERS
if (counter.total % 20 == 0)
{
Serial.println("\nTOT\tOK\tCRC\tTO\tUNK");
Expand All @@ -100,6 +103,5 @@ void loop()
}
delay(2000);
}
//

// END OF FILE
//
Loading

0 comments on commit ff02f93

Please sign in to comment.