3 Temp & Humidity display with servo control- newbie

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(" %");

 
}

have a read of how-to-get-the-best-out-of-this-forum
what microcontroller are you using?
does the display of temp and humidity on the LCD work OK?
what happens when you attempt to control the servos?
have you tested the servos in a seperate program?
upload your code - select < CODE/ > and paste text where it says “type or paste code here”
upload a schematic showing the wiring and how you power the devices

Start with some relevant sketches from the examples menu in the IDE. Try to read and understand them, and then combine them. There is no magic involved that you have not yet found out about. You need to understand each of the sketches you want to combine, line-by-line.

You won't find another project that is 100% identical to your own from which you can simply copy the complete code. But you may find similar projects, each of which has some things in common with your project, and learn by reading and understanding the code from those projects.

What are the specs of the fan? How many pins/wires does the fan have? The easiest type to use with Arduino are the 4-pin type. For those, you don't need need much hardware to control them, maybe just a capacitor and flyback diode to protect the Arduino. For 2 pin fans, you will need a transistor of some kind, plus a resistor and the capacitor and flyback diode.

1 Like

post the code

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.