Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
SmartHome
NodeManager_GasSensor
Commits
df306b8d
Commit
df306b8d
authored
Jul 29, 2017
by
user2684
Committed by
GitHub
Jul 29, 2017
Browse files
DHT library update and fixes (#175, #145, #176, #148)
parent
89ba0f4c
Changes
3
Hide whitespace changes
Inline
Side-by-side
NodeManager.cpp
View file @
df306b8d
...
...
@@ -1268,22 +1268,23 @@ SensorDHT::SensorDHT(NodeManager* node_manager, int child_id, int pin, DHT* dht,
// what to do during before
void
SensorDHT
::
onBefore
()
{
// initialize the dht library
_dht
->
begin
();
}
// what to do during setup
void
SensorDHT
::
onSetup
()
{
// initialize the dht library
_dht
->
setup
(
_pin
,
_dht_type
);
}
// what to do during loop
void
SensorDHT
::
onLoop
()
{
wait
(
_dht
->
getMinimumSamplingPeriod
());
_dht
->
readSensor
(
true
);
// temperature sensor
if
(
_sensor_type
==
SensorDHT
::
TEMPERATURE
)
{
// read the temperature
float
temperature
=
_dht
->
readTemperature
();
// convert it
temperature
=
_node_manager
->
celsiusToFahrenheit
(
temperature
);
float
temperature
=
_dht
->
getTemperature
();
if
(
!
_node_manager
->
getIsMetric
())
temperature
=
_dht
->
toFahrenheit
(
temperature
);
#if DEBUG == 1
Serial
.
print
(
F
(
"DHT I="
));
Serial
.
print
(
_child_id
);
...
...
@@ -1296,8 +1297,7 @@ void SensorDHT::onLoop() {
// humidity sensor
else
if
(
_sensor_type
==
SensorDHT
::
HUMIDITY
)
{
// read humidity
float
humidity
=
_dht
->
readHumidity
();
if
(
isnan
(
humidity
))
return
;
float
humidity
=
_dht
->
getHumidity
();
#if DEBUG == 1
Serial
.
print
(
F
(
"DHT I="
));
Serial
.
print
(
_child_id
);
...
...
@@ -2965,12 +2965,11 @@ int NodeManager::registerSensor(int sensor_type, int pin, int child_id) {
else
if
(
sensor_type
==
SENSOR_LATCHING_RELAY
)
return
registerSensor
(
new
SensorLatchingRelay
(
this
,
child_id
,
pin
));
#endif
#if MODULE_DHT == 1
else
if
(
sensor_type
==
SENSOR_DHT11
||
sensor_type
==
SENSOR_DHT22
||
sensor_type
==
SENSOR_DHT21
)
{
else
if
(
sensor_type
==
SENSOR_DHT11
||
sensor_type
==
SENSOR_DHT22
)
{
int
dht_type
;
if
(
sensor_type
==
SENSOR_DHT11
)
dht_type
=
DHT11
;
else
if
(
sensor_type
==
SENSOR_DHT21
)
dht_type
=
DHT21
;
else
if
(
sensor_type
==
SENSOR_DHT22
)
dht_type
=
DHT22
;
DHT
*
dht
=
new
DHT
(
pin
,
dht_type
);
if
(
sensor_type
==
SENSOR_DHT11
)
dht_type
=
DHT
::
DHT11
;
else
if
(
sensor_type
==
SENSOR_DHT22
)
dht_type
=
DHT
::
DHT22
;
DHT
*
dht
=
new
DHT
();
// register temperature sensor
registerSensor
(
new
SensorDHT
(
this
,
child_id
,
pin
,
dht
,
SensorDHT
::
TEMPERATURE
,
dht_type
));
// register humidity sensor
...
...
NodeManager.h
View file @
df306b8d
...
...
@@ -114,7 +114,7 @@
#ifndef MODULE_DIGITAL_OUTPUT
#define MODULE_DIGITAL_OUTPUT 0
#endif
// Enable this module to use one of the following sensors: SENSOR_DHT11, SENSOR_DHT22
, SENSOR_DHT21
// Enable this module to use one of the following sensors: SENSOR_DHT11, SENSOR_DHT22
#ifndef MODULE_DHT
#define MODULE_DHT 0
#endif
...
...
@@ -221,7 +221,6 @@ enum supported_sensors {
// DHT11/DHT22 sensors, return temperature/humidity based on the attached DHT sensor
SENSOR_DHT11
,
SENSOR_DHT22
,
SENSOR_DHT21
,
#endif
#if MODULE_SHT21 == 1
// SHT21 sensor, return temperature/humidity based on the attached SHT21 sensor
...
...
@@ -827,7 +826,7 @@ class SensorDHT: public Sensor {
const
static
int
HUMIDITY
=
1
;
protected:
DHT
*
_dht
;
int
_dht_type
=
DHT11
;
int
_dht_type
;
float
_offset
=
0
;
int
_sensor_type
=
0
;
};
...
...
README.md
View file @
df306b8d
...
...
@@ -152,7 +152,7 @@ The next step is to enable NodeManager's additional functionalities and the modu
#define MODULE_DIGITAL_INPUT 0
// Enable this module to use one of the following sensors: SENSOR_DIGITAL_OUTPUT, SENSOR_RELAY, SENSOR_LATCHING_RELAY
#define MODULE_DIGITAL_OUTPUT 0
// Enable this module to use one of the following sensors: SENSOR_DHT11, SENSOR_DHT22
, SENSOR_DHT21
// Enable this module to use one of the following sensors: SENSOR_DHT11, SENSOR_DHT22
#define MODULE_DHT 0
// Enable this module to use one of the following sensors: SENSOR_SHT21
#define MODULE_SHT21 0
...
...
@@ -196,7 +196,7 @@ Some of the modules above rely on third party libraries. Those libraries are not
Module | Required Library
------------- | -------------
MODULE_SHT21 | https://github.com/SodaqMoja/Sodaq_SHT2x
MODULE_DHT | https://github.com/
adafruit/DHT-sensor-library
MODULE_DHT | https://github.com/
mysensors/MySensorsArduinoExamples/tree/master/libraries/DHT
MODULE_DS18B20 | https://github.com/milesburton/Arduino-Temperature-Control-Library
MODULE_BH1750 | https://github.com/claws/BH1750
MODULE_MLX90614 | https://github.com/adafruit/Adafruit-MLX90614-Library
...
...
@@ -1325,3 +1325,4 @@ v1.6:
*
SensorMQ now depends on its own module
*
Added automatic off capability (safeguard) to SensorDigitalOutput
*
Any sensor can now access all NodeManager's functions
*
DHT sensor now using MySensors' DHT library
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment