Skip to content

Commit ccdf651

Browse files
committed
0.1.3 DHT2pin
1 parent 2aa605a commit ccdf651

File tree

7 files changed

+107
-64
lines changed

7 files changed

+107
-64
lines changed

libraries/DHT2pin/.arduino-ci.yml

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
platforms:
2+
rpipico:
3+
board: rp2040:rp2040:rpipico
4+
package: rp2040:rp2040
5+
gcc:
6+
features:
7+
defines:
8+
- ARDUINO_ARCH_RP2040
9+
warnings:
10+
flags:
11+
12+
packages:
13+
rp2040:rp2040:
14+
url: https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json
15+
116
compile:
217
# Choosing to run compilation tests on 2 different Arduino platforms
318
platforms:
@@ -7,5 +22,7 @@ compile:
722
# - leonardo
823
- m4
924
- esp32
10-
# - esp8266
11-
# - mega2560
25+
- esp8266
26+
# - mega2560
27+
- rpipico
28+

libraries/DHT2pin/CHANGELOG.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Change Log DHT2pin
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](http://keepachangelog.com/)
6+
and this project adheres to [Semantic Versioning](http://semver.org/).
7+
8+
9+
## [0.1.3] - 2022-11-01
10+
- add changelog.md
11+
- add rp2040 to build-CI
12+
13+
## [0.1.2] - 2021-12-16
14+
- update library.json, license, minor edits
15+
16+
## [0.1.1] - 2020-12-19
17+
- added arduino-ci + unit test
18+
19+
## [0.1.0] - 2020-06-30
20+
- own repository
21+
- #pragma once
22+
23+
## [0.0.3]
24+
- Fix issue #33
25+
26+
## [0.0.2]
27+
- support for non "F_CPU" boards especially Galileo
28+
- Tested and verified by Maria Emanuella Moura Silva (thanks)
29+
- changed name to DHT2pin
30+
31+
## [0.0.1] - 2016-09-05
32+
- initial version - based upon 0.1.13 DHT
33+

libraries/DHT2pin/dht2pin.cpp

Lines changed: 35 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,29 @@
11
//
22
// FILE: DHT2pin.cpp
33
// AUTHOR: Rob Tillaart
4-
// VERSION: 0.1.2
4+
// VERSION: 0.1.3
55
// PURPOSE: Experimental DHT Temperature & Humidity Sensor library for Arduino
66
// URL: https://github.com/RobTillaart/DHT2pin
77
// http://arduino.cc/playground/Main/DHTLib
88
//
9-
// HISTORY:
10-
// 0.1.2 2021-12-16 update library.json, license, minor edits
11-
// 0.1.1 2020-12-19 added arduino-ci + unit test
12-
// 0.1.0 2020-06-30 own repository; #pragma once
13-
// 0.0.3 Fix issue #33
14-
// 0.0.2 support for non "F_CPU" boards especially Galileo
15-
// Tested and verified by Maria Emanuella Moura Silva (thanks)
16-
// changed name to DHT2pin
17-
// 0.0.1 initial version - 2016 SEP 05 (based upon 0.1.13 DHT)
18-
//
9+
// HISTORY: see changelog.md
10+
1911

2012
#include "DHT2pin.h"
2113

14+
2215
/////////////////////////////////////////////////////
2316
//
24-
// PUBLIC
17+
// PUBLIC
2518
//
2619

27-
// return values:
28-
// DHTLIB_OK
29-
// DHTLIB_ERROR_CHECKSUM
30-
// DHTLIB_ERROR_TIMEOUT
20+
// return values:
21+
// DHTLIB_OK
22+
// DHTLIB_ERROR_CHECKSUM
23+
// DHTLIB_ERROR_TIMEOUT
3124
int DHT2pin::read11()
3225
{
33-
// READ VALUES
26+
// READ VALUES
3427
int rv = _readSensor(DHTLIB_DHT11_WAKEUP);
3528
if (rv != DHTLIB_OK)
3629
{
@@ -39,38 +32,38 @@ int DHT2pin::read11()
3932
return rv;
4033
}
4134

42-
// CONVERT AND STORE
35+
// CONVERT AND STORE
4336
humidity = bits[0]; // bits[1] == 0;
4437
temperature = bits[2]; // bits[3] == 0;
4538

46-
// TEST CHECKSUM
47-
// bits[1] && bits[3] both 0
39+
// TEST CHECKSUM
40+
// bits[1] && bits[3] both 0
4841
uint8_t sum = bits[0] + bits[2];
4942
if (bits[4] != sum) return DHTLIB_ERROR_CHECKSUM;
5043

5144
return DHTLIB_OK;
5245
}
5346

5447

55-
// return values:
56-
// DHTLIB_OK
57-
// DHTLIB_ERROR_CHECKSUM
58-
// DHTLIB_ERROR_TIMEOUT
48+
// return values:
49+
// DHTLIB_OK
50+
// DHTLIB_ERROR_CHECKSUM
51+
// DHTLIB_ERROR_TIMEOUT
5952
int DHT2pin::read()
6053
{
61-
// READ VALUES
54+
// READ VALUES
6255
int rv = _readSensor(DHTLIB_DHT_WAKEUP);
6356
if (rv != DHTLIB_OK)
6457
{
65-
humidity = DHTLIB_INVALID_VALUE; // invalid value, or is NaN prefered?
66-
temperature = DHTLIB_INVALID_VALUE; // invalid value
67-
return rv; // propagate error value
58+
humidity = DHTLIB_INVALID_VALUE; // invalid value, or is NaN prefered?
59+
temperature = DHTLIB_INVALID_VALUE; // invalid value
60+
return rv; // propagate error value
6861
}
6962

70-
// CONVERT AND STORE
63+
// CONVERT AND STORE
7164
humidity = word(bits[0], bits[1]) * 0.1;
7265
temperature = word(bits[2] & 0x7F, bits[3]) * 0.1;
73-
if (bits[2] & 0x80) // negative temperature
66+
if (bits[2] & 0x80) // negative temperature
7467
{
7568
temperature = -temperature;
7669
}
@@ -86,28 +79,28 @@ int DHT2pin::read()
8679

8780
/////////////////////////////////////////////////////
8881
//
89-
// PRIVATE
82+
// PRIVATE
9083
//
9184

92-
// return values:
93-
// DHTLIB_OK
94-
// DHTLIB_ERROR_TIMEOUT
85+
// return values:
86+
// DHTLIB_OK
87+
// DHTLIB_ERROR_TIMEOUT
9588
int DHT2pin::_readSensor(uint8_t wakeupDelay)
9689
{
97-
// INIT BUFFERVAR TO RECEIVE DATA
90+
// INIT BUFFERVAR TO RECEIVE DATA
9891
uint8_t mask = 128;
9992
uint8_t idx = 0;
10093

101-
// EMPTY BUFFER
94+
// EMPTY BUFFER
10295
for (uint8_t i = 0; i < 5; i++) bits[i] = 0;
10396

104-
// REQUEST SAMPLE
97+
// REQUEST SAMPLE
10598
digitalWrite(_wpin, LOW);
10699
delay(wakeupDelay);
107100
digitalWrite(_wpin, HIGH);
108101
delayMicroseconds(40);
109102

110-
// GET ACKNOWLEDGE or TIMEOUT
103+
// GET ACKNOWLEDGE or TIMEOUT
111104
uint16_t loopCnt = DHTLIB_TIMEOUT;
112105
while(digitalRead(_rpin) == LOW)
113106
{
@@ -152,6 +145,7 @@ int DHT2pin::_readSensor(uint8_t wakeupDelay)
152145

153146
return DHTLIB_OK;
154147
}
155-
//
156-
// END OF FILE
157-
//
148+
149+
150+
// -- END OF FILE --
151+

libraries/DHT2pin/dht2pin.h

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,16 @@
22
//
33
// FILE: dht2pin.h
44
// AUTHOR: Rob Tillaart
5-
// VERSION: 0.1.2
5+
// VERSION: 0.1.3
66
// PURPOSE: DHT Temperature & Humidity Sensor library for Arduino
77
// URL: https://github.com/RobTillaart/DHT2pin
88
// http://arduino.cc/playground/Main/DHTLib
9-
//
10-
// HISTORY:
11-
// see dht.cpp file
12-
//
9+
1310

1411
#include <Arduino.h>
1512

16-
#define DHT2PIN_LIB_VERSION (F("0.1.2"))
13+
14+
#define DHT2PIN_LIB_VERSION (F("0.1.3"))
1715

1816
#define DHTLIB_OK 0
1917
#define DHTLIB_ERROR_CHECKSUM -1
@@ -26,11 +24,11 @@
2624
#define DHTLIB_DHT11_WAKEUP 18
2725
#define DHTLIB_DHT_WAKEUP 1
2826

29-
// max timeout is 100usec.
30-
// For a 16Mhz proc that is max 1600 clock cycles
31-
// loops using TIMEOUT use at least 4 clock cycli
32-
// so 100 us takes max 400 loops
33-
// so by dividing F_CPU by 40000 we "fail" as fast as possible
27+
// max timeout is 100usec.
28+
// For a 16Mhz proc that is max 1600 clock cycles
29+
// loops using TIMEOUT use at least 4 clock cycli
30+
// so 100 us takes max 400 loops
31+
// so by dividing F_CPU by 40000 we "fail" as fast as possible
3432
#ifdef F_CPU
3533
#define DHTLIB_TIMEOUT (F_CPU/40000)
3634
#else
@@ -40,10 +38,10 @@
4038
class DHT2pin
4139
{
4240
public:
43-
// return values:
44-
// DHTLIB_OK
45-
// DHTLIB_ERROR_CHECKSUM
46-
// DHTLIB_ERROR_TIMEOUT
41+
// return values:
42+
// DHTLIB_OK
43+
// DHTLIB_ERROR_CHECKSUM
44+
// DHTLIB_ERROR_TIMEOUT
4745
DHT2pin(uint8_t rpin, uint8_t wpin)
4846
{
4947
_rpin = rpin;
@@ -72,10 +70,10 @@ class DHT2pin
7270
private:
7371
uint8_t _rpin;
7472
uint8_t _wpin;
75-
uint8_t bits[5]; // buffer to receive data
73+
uint8_t bits[5]; // buffer to receive data
7674
int _readSensor(uint8_t wakeupDelay);
7775
};
7876

79-
//
80-
// END OF FILE
81-
//
77+
78+
// -- END OF FILE --
79+

libraries/DHT2pin/library.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"type": "git",
1616
"url": "https://github.com/RobTillaart/DHT2pin"
1717
},
18-
"version": "0.1.2",
18+
"version": "0.1.3",
1919
"license": "MIT",
2020
"frameworks": "arduino",
2121
"platforms": "*",

libraries/DHT2pin/library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=DHT2pin
2-
version=0.1.2
2+
version=0.1.3
33
author=Rob Tillaart <[email protected]>
44
maintainer=Rob Tillaart <[email protected]>
55
sentence=Experimental library of the DHT library that uses 2 pins.

libraries/DHT2pin/test/unit_test_001.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ unittest(test_constructor)
5555
assertEqualFloat(-999, DHT.humidity, 0.001);
5656
}
5757

58+
5859
unittest_main()
5960

6061
// --------

0 commit comments

Comments
 (0)