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
Greek
English

Εισαγωγή

Στο σημερινό tutorial θα μάθουμε να χρησιμοποιούμε τον αισθητήρα θερμοκρασίας DS18B20 της εταιρίας Dallas.

Με την βοήθεια του Arduino uno θα μπορέσουμε να μετρήσουμε την θερμοκρασία του χώρου μας και να την εκτυπώσουμε στην σειριακή οθόνη του Arduino IDE.

Περισσότερες πληροφορίες για το DS18B20 απευθείας απ' το datasheet του

The DS18B20 communicates over a 1-Wire bus that by definition requires only one data line (and ground) for communication with Arduino. It has an operating temperature range of -55°C to +125°C and is accurate to ±0.5°C over the range of -10°C to +85°C. In addition, the DS18B20 can derive power directly from the data line (“parasite power”), eliminating the need for an external power supply.
Each DS18B20 has a unique 64-bit serial code, which allows multiple DS18B20s to function on the same 1-Wire bus. Thus, it is simple to use one microprocessor to control many DS18B20s distributed over a large area. Applications that can benefit from this feature include HVAC environmental controls, temperature monitoring systems inside buildings, equipment, or machinery, and process monitoring and control systems.
Picture
Basic Features:
  • Unique 1-Wire Interface Requires Only One Port Pin for Communication
  • Each Device has a Unique 64-Bit Serial Code Stored in an On-Board ROM
  • Requires No External Components
  • Can Be Powered from Data Line; Power Supply Range is 3.0V to 5.5V
  • Measures Temperatures from -55°C to +125°C (-67°F to +257°F)
  • ±0.5°C Accuracy from -10°C to +85°C

​Βρείτε περισσότερες πληροφορίες εδώ: datasheet

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

  • Arduino uno
  • Breadboard
  • Αισθητήρα θερμοκρασίας DS18B20
  • Αντίσταση 4.7KΩ
Picture

Το κύκλωμα

Picture
  • Ενώνουμε το GND με το Vdd pin του DS18B20 με το GND του Arduino
  • Το Pin 2 (το pin που είναι στη μέση "D") του DS18B20 με το Pin 2 του Arduino 
  • Στο Pin2 του DS18B20 βάζουμε την αντίσταση 4.7KOhm και την ενώνουμε με το pin 5V του Arduino

Ο κώδικας

  • Serial.println(sensors.getTempCByIndex(0)); θερμοκρασία σε βαθμούς κελσίου
  • Serial.println(sensors.getTempFByIndex(0)); θερμοκρασία σε fahrenheit.
 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
/* Arduino DS18B20 temp sensor tutorial
   More info: http://www.ardumotive.com/how-to-use-the-ds18b20-temperature-sensor-en.html
   Date: 19/6/2015 // www.ardumotive.com */

//Include libraries
#include <OneWire.h>
#include <DallasTemperature.h>

// Data wire is plugged into pin 2 on the Arduino
#define ONE_WIRE_BUS 2
// Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)
OneWire oneWire(ONE_WIRE_BUS);
// Pass our oneWire reference to Dallas Temperature. 
DallasTemperature sensors(&oneWire);

void setup(void)
{
  Serial.begin(9600); //Begin serial communication
  Serial.println("Arduino Digital Temperature // Serial Monitor Version"); //Print a message
  sensors.begin();
}

void loop(void)
{ 
  // Send the command to get temperatures
  sensors.requestTemperatures();  
  Serial.print("Temperature is: ");
  Serial.println(sensors.getTempCByIndex(0)); // Why "byIndex"? You can have more than one IC on the same bus. 0 refers to the first IC on the wire
  //Update value every 1 sec.
  delay(1000);
}
Κατεβάστε τον κώδικα απ' εδώ και ανοίξτε το αρχείο με το Arduino IDE. Μέσα θα βρείτε και τις σχετικές βιβλιοθήκες.
ds18b20_tutorial.zip
File Size: 19 kb
File Type: zip
Download File


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


Μπορείτε να κάνετε τις δικές σας αλλαγές στον κώδικα, δοκιμάστε για παράδειγμα να αλλάξετε τον χρόνο ανανέωσης - delay - και δείτε πως αυτό επηρεάζει το πρόγραμμα σας.

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

Picture
Μόλις ολοκληρώσατε άλλο ένα Arduino tutorial της σελίδας μας!

Tip: Το DS1820 βγαίνει και σε αδιάβροχη έκδοση (δείτε εικόνα εδώ)

Ελπίζω να σας άρεσε, πείτε μου στα σχόλια παρακάτω!
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