RobotDynOfficial / RBDDimmer

The following library is used for work with dimmer, it gives ability to control large ammoun of dimmer. This lib uses with Leonardo, Mega, UNO, ESP8266, ESP32, Arduino M0, Arduino Zero, Arduino Due, STM32.
241 stars 112 forks source link

problem with dimmer and DHT11 sensor #37

Open RickyD8540 opened 4 years ago

RickyD8540 commented 4 years ago

Hi everyone, I have recently started programming my arduino again and stumbled upon a problem that i don't really understand. I am writing a program that uses a dht11 to detect air humidity and above a certain value i want it to turn on an ac fan by using an AC dimmer. however, my dht11 returns nan except when i put the dimmer.begin statement from the setup in comments. Then it just gives the correct value.

i am using an arduino uno but also tried it on my nano with the same result. the libraries i'm using are the ADAFruit DHT sensor library and the RoboDyn RBDDimmer i've added the outputs of my serial monitor as images below. the one is with the dimmer.begin in comments that shows that my dht is working fine and the other is without the comments where it returns nan

`

include "DHT.h"

include

define dhtPin 12 //dht datapin on d12

define dhtType DHT11

DHT dht(dhtPin, dhtType); float humidityVal; //air humidity int relaisPin = 11; //#define zeroCross 2 dimmerLamp dimmer(relaisPin); void setup() { Serial.begin(9600); pinMode(relaisPin, OUTPUT); pinMode(dhtPin, INPUT); dht.begin(); //dimmer.begin(NORMAL_MODE,OFF); Serial.println("dimmer started"); } void loop() { readDHT(); Serial.println(); //add empty line Serial.println(humidityVal); delay(1000); setDimmer(); delay(500); } void readDHT(){ humidityVal = dht.readHumidity(); //read humidity value if (isnan(humidityVal)){ Serial.println("FAILED to read DHT SENSOR!"); } else { Serial.print("humidity: "); Serial.println(humidityVal); } } void setDimmer(){ if (humidityVal>60){ dimmer.setPower(85); Serial.println("dimmer set to 85"); } else { dimmer.setPower(0); Serial.println("dimmer set to 0"); } } ` prob1 prob2

nnnnaufalir commented 1 year ago

are you solved with this issues? i have same issues too