Good day,
I am using an Arduino Nano to read the temperature and humidity and set the value to a dimmer and send all of the temperature information to a raspberry pi via a nrf24l01+
I have used this library to control the dimmer:
I can control the dimmer from 1 to 99% and it works fine.
I used the Arduino library for the DHT22 and when i run the code i get the humidity and temperature fine as well, but when i combine both codes, the dimmer keeps working but for the humidity and temperature, i get NAN values.
Am i doing something wrong?
As soon as i comment this line i get the temperature and humidity again:
dimmer.begin(NORMAL_MODE, ON); //dimmer initialisation: name.begin(MODE, STATE)
here is the code i have used:
/**************
#include <RBDdimmer.h>//
#include <DHT.h>;
//#define USE_SERIAL SerialUSB //Serial for boards whith USB serial port
#define outputPin 8
#define DHTPIN 3 // what pin we're connected to
#define DHTTYPE DHT22 // DHT 22 (AM2302)
DHT dht(DHTPIN, DHTTYPE); //// Initialize DHT sensor for normal 16mhz Arduino
//dimmerLamp dimmer(outputPin, zerocross); //initialase port for dimmer for ESP8266, ESP32, Arduino due boards
dimmerLamp dimmer(outputPin); //initialase port for dimmer for MEGA, Leonardo, UNO, Arduino M0, Arduino Zero
float hum; //Stores humidity value
float temp; //Stores temperature value
void setup() {
Serial.begin(9600);
dimmer.begin(NORMAL_MODE, ON); //dimmer initialisation: name.begin(MODE, STATE)
Serial.println("--- Simple dimmer example ---");
dht.begin();
}
void loop() {
hum = dht.readHumidity();
temp = dht.readTemperature();
Serial.print("Humidity: ");
Serial.print(hum);
Serial.print(" %, Temp: ");
Serial.print(temp);
Serial.println(" Celsius");
dimmer.setPower(90); // setPower(90%);
delay(1000);
dimmer.setPower(10); // setPower(10%);
delay(2000);
}
Thanks a lot for your help!