Skip to main content

Arduino Code Temperature Sensor

 //Libraries

#include <DHT.h>

//I2C LCD:

#include <LiquidCrystal_I2C.h>

#include <Wire.h>


LiquidCrystal_I2C lcd(0x27,16,2); // set the LCD address to 0x27 for a 16 chars and 2 line display

  

//Constants

#define DHTPIN A3     // what pin we're connected to

#define DHTTYPE DHT11   // DHT 11

DHT dht(DHTPIN, DHTTYPE); //// Initialize DHT sensor for normal 16mhz Arduino


//Variables

//int chk;

int h;  //Stores humidity value

int t; //Stores temperature value


void setup()

{

    Serial.begin(9600);

    Serial.println("Temperature and Humidity Sensor Test");

    dht.begin();

    lcd.init(); //initialize the lcd

    lcd.backlight(); //open the backlight

}


void loop()

{

    //Read data and store it to variables h (humidity) and t (temperature)

    // Reading temperature or humidity takes about 250 milliseconds!

    h = dht.readHumidity();

    t = dht.readTemperature();

    

    //Print temp and humidity values to serial monitor

    Serial.print("Humidity: ");

    Serial.print(h);

    Serial.print(" %, Temp: ");

    Serial.print(t);

    Serial.println(" ° Celsius");

        

// set the cursor to (0,0):

// print from 0 to 9:


    lcd.setCursor(0, 0);

    lcd.println(" Simple Circuits");

    

    lcd.setCursor(0, 1);

    lcd.print(" T:");

    lcd.print(t);

    lcd.print("C");

     

    lcd.setCursor(11, 1);

    lcd.print("H:");

    lcd.print(h);

    lcd.print("%");

    

  delay(1000); 

}

Comments

  1. ca ne marche pas

    ReplyDelete
  2. ye toh work bhi nahi karta hai

    ReplyDelete
    Replies
    1. bhai mere me to work kar rha hai. aapne library add nhi kri hogi shayad se ek bar check karo.

      Delete
    2. Kindly give all details how add library

      Delete
    3. learn from yt bro

      Delete
  3. no entioendo la libreria

    ReplyDelete
  4. Replies
    1. Project ka photo send kar degiye ga sir

      Delete
  5. can i have your humid libraries and for the lcd

    ReplyDelete
  6. Yehi project hai itna hi sirf

    ReplyDelete
  7. For those who need libraries:
    #include → Library name: DHT Sensor Library
    #include → Library name: LiquidCrystal_I2C
    #include → Library name: Wire (built-in with Arduino)

    ReplyDelete

Post a Comment

Popular posts from this blog

Solar Tracking System

Dual-Axis Solar Tracking System | Arduino SimpleCircuits Arduino Solar DIY Renewable Energy Project Dual-Axis Solar Tracking System Build a high-performance solar tracker that follows the sun in real-time. Four LDR sensors, an Arduino UNO, and two servo motors — boosting energy capture by up to 40% versus fixed mounts. 40% More Efficient 4 LDR Sensors 2 Servo Axes <300mA Power Draw Finished Build System Overview How the System Works The tracker reads the sky through four LDR sensors placed around the panel, computes intensity deltas, and drives two SG90 servos in a real-time closed loop — keeping the panel perpendicular to sunlight from sunrise to sunset. ...

Arduino Code Car Parking System

 // Created by Simple Circuits  #include <Wire.h>  #include <LiquidCrystal_I2C.h> LiquidCrystal_I2C lcd(0x27,16,2);    #include <Servo.h>  Servo myservo; int IR1 = 2; int IR2 = 3; int Slot = 4;           //Total number of parking Slots int flag1 = 0; int flag2 = 0; void setup() {   Serial.begin(9600);      lcd.init(); //initialize the lcd     lcd.backlight(); //open the backlight     pinMode(IR1, INPUT); pinMode(IR2, INPUT);    myservo.attach(4); myservo.write(100); lcd.setCursor (0,0); lcd.print("     ARDUINO    "); lcd.setCursor (0,1); lcd.print(" PARKING SYSTEM "); delay (2000); lcd.clear();   } void loop(){  if(digitalRead (IR1) == LOW && flag1==0){ if(Slot>0){flag1=1; if(flag2==0){myservo.write(0); Slot = Slot-1;} }else{ lcd.setCursor (0,0); lcd.print("    SORRY :(    ");   lc...

Arduino Code

 //define Pins #include <Servo.h> Servo servo; int trigPin = 11; int echoPin = 12; // defines variables long duration; int distance; void setup()  {   servo.attach(13);   servo.write(180);  delay(2000);    // Sets the trigPin as an Output pinMode(trigPin, OUTPUT); // Sets the echoPin as an Input  pinMode(echoPin, INPUT); } void loop()  { // Clears the trigPin digitalWrite(trigPin, LOW); delayMicroseconds(2); // Sets the trigPin on HIGH state for 10 micro seconds digitalWrite(trigPin, HIGH); delayMicroseconds(10); digitalWrite(trigPin, LOW); // Reads the echoPin, returns the sound wave travel time in microseconds duration = pulseIn(echoPin, HIGH); // Calculating the distance distance= duration*0.034/2; // Prints the distance on the Serial Monitor Serial.print("Distance: "); Serial.println(distance); if ( distance <= 25   ) // Change Distance according to Ultrasonic Sensor Placement  { servo.write(180); delay(3000); ...