I would like to know if it's possible to use the HC-SR04 with the DHT11 into same INO project.
HC-SR04 works if I comment the two next lines :
Code: Select all
humidity = dht.readHumidity();
temperature = dht.readTemperature();
I can't have the two at the sametime.
Here my full code :
Code: Select all
// add library
#include "ZUNO_DHT.h"
// pin connection
#define DHTPIN 9
ZUNO_SETUP_CHANNELS(
ZUNO_SENSOR_MULTILEVEL(
ZUNO_SENSOR_MULTILEVEL_TYPE_DISTANCE,
0, // scale is meters
SENSOR_MULTILEVEL_SIZE_TWO_BYTES,
2, // two decimals after dot
getter
),
ZUNO_SENSOR_MULTILEVEL_TEMPERATURE(getterTemperature),
ZUNO_SENSOR_MULTILEVEL_HUMIDITY(getterHumidity)
);
//ZUNO_SETUP_ASSOCIATIONS(ZUNO_ASSOCIATION_GROUP_SET_VALUE); // to control other devices
int turn_on_distance_cm = 50; // Turn on light in CTRL_GROUP_1 if distance is < 50 cm
int readPin = 11;
int triggerPin = 10;
byte controlState = 0;
word lastValue;
int humidity; // here we will store the humidity
int temperature; // here we will store the temperature
DHT dht(DHTPIN, DHT11);
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(readPin, INPUT);
pinMode(triggerPin, OUTPUT);
digitalWrite(triggerPin, LOW);
dht.begin();
}
void loop() {
// obtaining readings from the sensor DHT
//humidity = dht.readHumidity();
//temperature = dht.readTemperature();
Serial.print("Humidity = ");
Serial.print(humidity);
Serial.print(" % ");
Serial.print("Temperature = ");
Serial.print(temperature);
Serial.println(" *C");
// send data to channels
zunoSendReport(2);
zunoSendReport(3);
int tmp;
// trigger measurement
digitalWrite(triggerPin, LOW);
delayMicroseconds(10);
digitalWrite(triggerPin, HIGH);
delayMicroseconds(10);
digitalWrite(triggerPin, LOW);
// read pulse width
tmp = pulseIn(readPin, HIGH, 100000);
if (tmp != 0) {
lastValue = tmp / 58; // convert to cm, see datasheet
Serial.print("CM : ");
Serial.println(lastValue);
// send report to controller (Life Line group)
zunoSendReport(1);
}
Serial.println("humtemp");
delay(1000);
}
word getter() {
return lastValue;
}
byte getterTemperature() {
return temperature;
}
byte getterHumidity() {
return humidity;
}
https://z-uno.z-wave.me/examples/dht11/
https://z-uno.z-wave.me/examples/hc-sr0 ... ce-sensor/
If I comment the two DHT11 lines, changes are taken (Message output) :
Code: Select all
Humidity = 0 % Temperature = 0 *C
CM : 108
humtemp
Change are not taken :
Code: Select all
Humidity = 0 % Temperature = 0 *C
CM : 222
humtemp
Is someone have any idea plz ?
Thanks a lot.
---
iData