You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have added a DHT11 sensor and ldr sensor to you code and it is working well. Add if you like.
The DHT.h library needs to be version 0.1.13. Doesnt compile right with latest
LDR is wired to A0 with a voltage divider....I used a variable resistor to tweak and did most of my testing on an uno to get max voltage below 1v. This Works very well surprisingly very sensitive. In a dark room i get 0 and the glow from laptop screen is picked up.
DHT11 is going to D6 GPIO12
//Extra Sensors Setup
//Light Reading**********************************************
unsigned long previousLightMillis = 0;
const int lightInterval = 120000;
//Temp Sensor************************************************
#include <dht.h>
dht DHT;
#define DHT11_PIN 12
int inPin = 12;
//Start Extra Sensors in main loop
extraSensor();
//More Sensors
void extraSensor() {
if (millis() - previousLightMillis >= lightInterval) {
I have added a DHT11 sensor and ldr sensor to you code and it is working well. Add if you like.
The DHT.h library needs to be version 0.1.13. Doesnt compile right with latest
LDR is wired to A0 with a voltage divider....I used a variable resistor to tweak and did most of my testing on an uno to get max voltage below 1v. This Works very well surprisingly very sensitive. In a dark room i get 0 and the glow from laptop screen is picked up.
DHT11 is going to D6 GPIO12
//Extra Sensors Setup
//Light Reading**********************************************
unsigned long previousLightMillis = 0;
const int lightInterval = 120000;
//Temp Sensor************************************************
#include <dht.h>
dht DHT;
#define DHT11_PIN 12
int inPin = 12;
//Start Extra Sensors in main loop
extraSensor();
//More Sensors
void extraSensor() {
if (millis() - previousLightMillis >= lightInterval) {
//Read Analog Light Sensor
int sensorValue = analogRead(A0);
Serial.println(sensorValue);
previousLightMillis = millis();
String lighttopic = "home/Light";
sendMQTT(lighttopic,String(sensorValue));
//Read DHT Sensor
int chk = DHT.read11(DHT11_PIN);
float temp = DHT.temperature;
Serial.print("Temperature = ");
Serial.println(1.8temp+32);
Serial.print("Humidity = ");
Serial.println(DHT.humidity);
String temptopic = "home/DHT/temp";
sendMQTT(temptopic,String(1.8temp+32));
String humiditytopic = "home/DHT/humidity";
sendMQTT(humiditytopic,String(DHT.humidity));
}
}
The text was updated successfully, but these errors were encountered: