Ardumotive Arduino Greek Playground
  • Home
    • About us
    • License
  • Arduino
    • Tutorials
    • Workshop
  • Raspberry Pi
  • DIY 3D Printer
  • News
    • Events >
      • Unboxing & Review
    • Blog
The 1st Arduino Playground in Greece - Open Source Hardware

Θερμοκρασία και υγρασία

Available Languages
Picture
Picture

Εισαγωγή

Picture
To DHT-21 (γνωστό και ως AM2301) είναι ένα αισθητήριο που χρησιμοποιείτε για την εύρεση της σχετικής υγρασίας και θερμοκρασίας στον χώρο.
Σε αυτόν τον οδηγό θα μάθετε πως να χρησιμοποιείτε τον αισθητήρα DHT-21 με το Arduino uno. Η υγρασία και θερμοκρασία του χώρου θα εκτυπώνονται στην σειριακή οθόνη. 

Σχετικά με το DHT-21

Το DHT-21 είναι ένας βασικός, χαμηλού κόστους, αισθητήρας για την εύρεση υγρασίας και θερμοκρασίας στον χώρο. Στο εσωτερικό του κρύβει έναν αισθητήρα υγρασίας και ένα θερμίστορ (μεταβλητή αντίσταση που η τιμή της αλλάζει σε σχέση με την θερμοκρασία) 'διαβάζοντας' έτσι τον αέρα που το περιβάλει. 
​

Τεχνικές πληροφορίες:
  • Πηγή : 3.3-5.2V
  • Υγρασία: 0-99.9%,  ακρίβεια 3%RH
  • Θερμοκρασία: -40 to 80°C, ακρίβεια ±0.5°C
Picture

Τα υλικά που θα χρειαστούμε

Για το tutorial αυτό θα χρειαστούμε:
  • Arduino uno
  • Breadboard (προαιρετικό)
  • DHT-21 (ΑΜ2301)
Picture

Το κύκλωμα

Η συνδεσμολογία είναι αρκετά εύκολη, 
  • το κόκκινο καλώδιο στο 5V ή 3.3V pin του Arduino
  • το μαύρο καλώδιο σε ενα απ' τα GND pins του Arduino
  • το κίτρινο καλώδιο στο pin 2 του Arduino

Ο κώδικας

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/* How to use the DHT-21 sensor with Arduino uno
   Temperature and humidity sensor
   More info: http://www.ardumotive.com/how-to-use-dht-21-sensor-en.html
   Dev: Michalis Vasilakis // Date: 19/11/2016 // www.ardumotive.com */

//Libraries
#include <dht.h>
dht DHT;
//Constants
#define DHT21_PIN 2     // DHT 21  (AM2301) - what pin we're connected to

//Variables
float hum;  //Stores humidity value
float temp; //Stores temperature value

void setup()
{
    Serial.begin(9600);
}

void loop()
{
    int chk = DHT.read21(DHT21_PIN);
    //Read data and store it to variables hum and temp
    hum = DHT.humidity;
    temp= DHT.temperature;
    //Print temp and humidity values to serial monitor
    Serial.print("Humidity: ");
    Serial.print(hum);
    Serial.print(" %, Temp: ");
    Serial.print(temp);
    Serial.println(" Celsius");
    delay(2000); //Delay 2 sec.
}
Κατεβάστε τον κώδικα απ' εδώ και ανοίξτε το αρχείο με το Arduino IDE. Μέσα θα βρείτε και την βιβλιοθήκη DHT.h.
dht21_tutorial.zip
File Size: 11 kb
File Type: zip
Download File

Ανοίξτε την σειριακή οθόνη απ' το μενού εργαλεία του Arduino IDE.

Το αποτέλεσμα:
Picture

Συγχαρητήρια! 

Picture
Μόλις ολοκληρώσατε άλλο ένα "How to" tutorial και μάθατε πως να χρησιμοποιείτε το DHT-21.
Ελπίζω να σας άρεσε, αν θέλετε μπορείτε να αφήσετε το σχόλιο σας παρακάτω.
​
Picture

Search Engine

Picture

Licence 

Picture

Help us to grow up!

Picture


Donate us
About us
License
Cookies policy

Visit the biggest Arduino Shop in Greece!

Picture
find us on dwrean.net
find us on Codebender
find us on Instructables
Developed and designed by Vasilakis Michalis Copyright © 2013 Ardumotive All Rights Reserved
All trademarks referenced herein are properties of their
Powered by Create your own unique website with customizable templates.
Design by DivTag Templates