Trying to understand and code the DHT22 to display temp and humidity and then be able to control a servo based on the temperatures from the DHT's.
I'm still very new to Arduino all together. what are some tips on how to code this?
Adruino UNO R3
I have the code together for the sensors and lcds but im trying to get the servo incorporated into this. I am not having very much luck with finding videos or topics discussing the coding side.
Also if you have any tips on how to control the fan speed of a 5-12v 2 pin fan using the Arduino based upon the things mentioned above that would be helpful.
Temps and humidities
Thank you for any help!
//Libraries
#include <DHT.h>;
#include <LiquidCrystal.h>
#include <LiquidCrystal_I2C.h>
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Servo.h>
//Constants
DHT dht1(2, DHT22); //// Initialize DHT sensor for normal 16mhz Arduino
DHT dht2(3, DHT22);
DHT dht3(4, DHT22);
LiquidCrystal_I2C lcd1(0x23, 16, 2);// display 1
LiquidCrystal_I2C lcd2(0x25, 16, 2);// display 2
LiquidCrystal_I2C lcd3(0x26, 16, 2);// display 3
int chk;
float hum1; //Stores humidity value
float temp1; //Stores temperature value
float hum2;
float temp2;
float hum3;
float temp3;
void setup() {
dht1.begin();
dht2.begin();
dht3.begin();
// initialize the LCD
lcd1.init();//initialize LCD1
lcd2.init();//initialize LCD2
lcd3.init();
lcd1.backlight();// turn the backlight ON for the LCD1
lcd2.backlight();// turn the backlight ON for the LCD2
lcd3.backlight();
}
void loop()
{
delay(2000);
//Read data and store it to variables hum and temp
hum1 = dht1.readHumidity();
temp1= dht1.readTemperature();
hum2 = dht2.readHumidity();
temp2= dht2.readTemperature();
hum3 = dht3.readHumidity();
temp3= dht3.readTemperature();
lcd1.clear();
lcd1.setCursor(0,0);
lcd1.print("Temp: ");
lcd1.print(temp1);
lcd1.print(" ");
lcd1.print((char)223);
lcd1.print("C");
lcd1.setCursor(0,1);
lcd1.print("Hum: ");
lcd1.print(hum1);
lcd1.print(" %");
lcd2.clear();
lcd2.setCursor(0,0);
lcd2.print("Temp: ");
lcd2.print(temp2);
lcd2.print(" ");
lcd2.print((char)223);
lcd2.print("C");
lcd2.setCursor(0,1);
lcd2.print("Hum: ");
lcd2.print(hum2);
lcd2.print(" %");
lcd3.clear();
lcd3.setCursor(0,0);
lcd3.print("Temp: ");
lcd3.print(temp3);
lcd3.print(" ");
lcd3.print((char)223);
lcd3.print("C");
lcd3.setCursor(0,1);
lcd3.print("Hum: ");
lcd3.print(hum3);
lcd3.print(" %");
}