Δευτέρα 13 Φεβρουαρίου 2012

Digital Thermometer with Arduino Uno

Below, is my effort to design a digital thermometer using the Arduino Uno. My attempt was a continuous research in the internet, googling every time my questions that born in my mind. All the code is copying and pasting from other users attempts, with big or small changes from me, but adapted to fit to my project.

There is a lot of fun out there with the microcontrollers. You can control every electronic device from one thermometer to a big project of a chemical process. The field is huge, but I want to share only a foo sand with yours.

The project is consists of three parts or steps:



  • Design the circuit in Fritzing IDE and then making it in a real breadboard.
  • Write a code in Arduino IDE in order to make the microcontroller to work properly with serial communication port of my PC. Also the Arduino IDE help the user to download the program into chip microcontroller enable it to work alone until a new program insert to it.
  • Write a code in Processing IDE to make a usefriendly window interface. This allows to monitoring the measured values and saves data in real time. All the programs are free to download, accompanied by many examples. With a little google help it is easy to understand and how to make your "homemade" code. All the code is based on the processing language with smal changes for arduino software.
Of course you can use one software for all, but this is another issue.

The circuit is using as temperature sensor, a thermistor of 10k with a resistor of 10k in series, making a voltage devider like below (my preference voltage operation is 5.0 volt):


Voltage Divider connected with arduino microcontroller pins

Below is the breadboard schematic of the circuit, which is designed in Fritzing software. The file is free to download.


Breadboard circuit of digital thermometer
The mathematical model which is used to determine the temperature, is the Steinhart-Hart Thermistor Equation:



where:


  • a, b and c are called the Steinhart-Hart parameters, and must be specified for each device. 
  • T is the temperature in kelvin and 
  • R is the thermistor resistance in ohms. 

The error in the Steinhart-Hart equation is generally less than 0.02 °C in the measurement of temperature over a 200 °C range. As an example, typical values for a thermistor with a resistance of 3000 Ω at room temperature (25 °C = 298.15 K) are:



The constants for a thermistor 10.000 ohms, that I use in my circuit, are:


α = 0.001129148
b = 0.000234125 
c = 8.76741E-08

The results are screening in a mobile LCD screen. The screen belongs to the Nokia 5110 and it is compatible with 3310 LCD, because they have the same controller (PCD8544 ). It functions in 2.7 to 3.3 volt, has 48x84 pixel matrix and 8 connection pins.


Nokia LCD 5110 (Familly of PCD8544 controller)
In order to make the LCD screen working properly you have to download the corresponding library and connect the LCD pins with the Arduino Uno pins, like below:

LCD Nokia 5110 and 3310 connection information 
The measured values are being monitoring by the user with a user friendly program. Also the measured values are screening in the LCD while you can save the data in EXCEL file every time the sensor is measuring the temperature

Arduino Program
Below is the code written in Arduino IDE. Copy and paste it in the Arduino software.
All the code is free to download.



The heart of the code is below:

float temp;
float tempDEC;
for (int i=0; i<=7; i++){
samples[i] = Thermistor(analogRead(ThermistorPIN));
temp = temp + samples[i];
}
temp = temp/8.0;
Serial.println(temp,DEC);


The microcontroller takes first, 8 samples and then compute the average value (temp = temp/8.0;). After that procedure, the Arduino send the signal in PC through serial communication port of my PC, with full decimal precision ( Serial.println(temp,DEC); ).

Processing Program (Userfriendly Interface)
Below is the code written in processing language and the screenshot of the program. I tried to write a lot of comments inside the code in order to understand someone what is the "mechanism" behind each line and what you expect to get if you make changes. The experiment is the begining to answer your questions.


Digital Thermometer monitoring program

Below you can see the video that describes the monitoring program:


You can copy and paste the code for the monitoring program in the Processing IDE, here.


The data are saving in EXCEL file within 3 columns. The 1st column records the date, the 2nd the time and 3rd the temperature value with 2 decimals. The name of the file includes all the date information and it's a unique every time runing the program.

The filename form is:
data_ddmmyyyy-hhmmss.xls

The file is saving in the folder name "datalogger", which is created the first time you runing the interface. Also, I wrote a macro excel command which creates the graph in automated way. The macro is free to download. Insert the code in the module of "personal.xls" file in able to run the macro every time you want. Below is the macro with instructions where to put:


At the begining of my journey, my little knowledge about the microcontrollers it leads me to more and more questions, for small and big issues. My reasearch leads me to add and write code to overcome the new problems optimizing my project. However my knowledge remains in minimum level until now. I hope to help someone who is in the begining, like me.

Have a nice fun !!

37 σχόλια:

  1. hi sir,

    I em doing a project on such a topic in where i am supposed to build a weather station in my aerostat. I want to put a real time graph for my data which i take using different sensors and arduino. Your excel code is quite helpful in my case but i want to use GUI so that i can graph the GPS data too. Could you guide me?

    ΑπάντησηΔιαγραφή
  2. Απαντήσεις
    1. If you mean the usefriendly interface of my digital thermometer project, you can download the code and get your answers. First you can download the Processing IDE and then copy and paste the code from my blog to the IDE. Then, try to find how your microcontroller send measurement values (GPS data) to your PC via USB. Try this simple code in Processing IDE:

      import processing.serial.*;
      Serial myPort;

      void setup () {
      println(Serial.list());
      myPort = new Serial(this, Serial.list()[0], 9600);
      myPort.bufferUntil('\n');
      }

      void draw () {
      while (myPort.available() > 0 ) {
      String inString = myPort.readStringUntil(10);
      if (inString != null) {
      println(inString);
      }
      }
      }

      run the code and open serial monitor. You have to define how your Arduino send values to the PC (line feed '\n' = 10 in ASCII or Carriage return '\r' = 13 in ASCII).
      Then you have to convert string into real number (float or int).
      If you get number then you can make your chart, playing with this Processing commands:

      rect: to design rectangular
      line: to design chart lines
      fill, stroke and text to make more beautiful graphics.

      As you can see in my Arduino code, I have one sensor which sends one temperature value per time to serial port in linefeed ('\n') and print as an ASCII-encoded decimal (Serial.println(temp,DEC)). If you have to send multiple values per time, I think you have to send them separeted by tab ('\t') (every data several columns in one row)

      Διαγραφή
  3. καλησπερα πολυ καλη η δουλεια!!!!θα ηθελα λιγο την πολυτιμη βοηθεια σου, θελω να βαλω στον arduino τον συγκεκριμενο κωδικα https://github.com/adafruit/Light-and-Temp-logger/blob/master/lighttemplogger.pde αν γινεται μπορεις να μου πεις τι πρεπει να αλλαξω για να δουλευει σωστα η processing?


    ΣΕ ΕΥΧΑΡΙΣΤΩ ΠΟΛΥ!!!!!

    ΑπάντησηΔιαγραφή
  4. Ευθύμη σε ευχαριστώ πολύ. Από ότι βλέπω ο κώδικας έχει 2 πράγματα που κι εγώ θέλω να βάλω στο θερμόμετρο, όπως την SD κάρτα και το Real Time clock, οπότε θα μπορούσαμε να βοηθηθούμε και οι δυο μας. Καταρχήν όταν λες δεν δουλεύει σωστά o κώδικας, σε τι ακριβώς δεν δουλεύει; Βγάζει κάποιο μήνυμα, δεν παίρνεις τα σωστά αποτελέσματα;
    Αρχικά θα σου έλεγα να δοκιμάσεις την SD μόνη της χωρίς το τσιπάκι DS1307 και να δοκιμάσεις να ελέγξεις τα pin του arduino σε αυτή την αντιστοιχία (Vcc-->3.3v, GND-->GND, CS-->10, MOSI(DI)-->11, SCK(CLK)-->13, MISO(DO)-->12). Εάν έχεις αυτή την κάρτα, που έχω κι εγώ (http://talesazevedo.blogspot.com/2012/03/ywrobot-sdcard-shield-arduino.html), τότε CS-->4 και το ΙΝ-->10.
    Όσο αφορά το DS1307 το 5ο ποδαράκι του chip-->analog 4 και το 6ο-->analog 5 του arduino. Ότι έχω με βέλος δείχνει το pin του arduino.
    Εάν δουλεύει σωστά θα ήθελα να μου πεις και εμένα για να το δοκιμάσω. Θέλω να βάλω ρολόι, SD κάρτα και EEPROM στο Θερμόμετρο.

    ΑπάντησηΔιαγραφή
  5. Ο ΚΩΔΙΚΑΣ ΔΟΥΛΕΥΕΙ ΣΩΣΤΑ,ΑΛΛΑ ΟΤΑΝ ΠΑΣ ΝΑ ΤΡΕΞΕΙΣ ΤΗΝ PROCESSING ΔΕΝ ΒΓΑΖΕΙ ΑΠΟΤΕΛΕΣΜΑΤΑ.ΚΑΙ ΤΟ ΡΟΛΟΙ ΔΟΥΛΕΥΕΙ ΣΩΣΤΑ,ΤΟ ΜΟΝΟ ΠΟΥ ΘΕΛΕΙ ΕΙΝΑΙ ΝΑ ΒΑΛΕΙΣ ΜΕΣΑ ΕΚΕΙ ΠΟΥ ΛΕΕΙ 10 ΤΟ 4 ΘΑ ΤΟ ΨΑΞΩ ΟΜΩΣ ΚΑΙ ΘΑ ΣΕ ΕΝΗΜΕΡΩΣΩ ΣΥΝΤΟΜΑ

    ΑπάντησηΔιαγραφή
    Απαντήσεις
    1. Άλλαξε το const int chipSelect = 10; σε const int chipSelect = 4; ενώ το pinMode(10, OUTPUT); θα το αφήσεις ως έχει για να δουλέψει σωστά η SD library, ανεξάρτητα εάν είναι συνδεδεμένο ή όχι.
      Αυτό σημαίνει το CS pin της κάρτας θα το συνδέσεις στο 4. Δοκίμασε το παράδειγμα του arduino (Examples-->SD-->CardInfo), αλλά και όλα τα παραδείγματα που έχει για SD.

      Διαγραφή
  6. δουλευει κανονικα ο κωδικας αλλα η processing με αυτο τον κωδικα δε βγαζει αποτελεσματα καθολου

    ΑπάντησηΔιαγραφή
    Απαντήσεις
    1. Στην κάρτα δημιουργείται αρχείο; Μέσα στο αρχείο τα αποτελέσματα είναι αυτά που περιμένεις ή είναι άδειο;

      Διαγραφή
  7. ναι δουλευει κανονικα,ολα καλα,αλλα το μονο ειναι processing δεν βγαζει κανενα αποτελεσμα.

    ΑπάντησηΔιαγραφή
  8. κανονικα δημιουργειται και εχω τα αποτελεσματα που θελω αλλα μονο η processing einai thema

    ΑπάντησηΔιαγραφή
  9. ΘΕΛΩ ΝΑ ΦΤΙΑΞΩ ΤΟ ΕΞΗΣ.ΝΑ ΒΑΛΩ ΤΟ ΡΟΛΟΙ ΤΗΝ SD ΚΑΙ ΣΤΗΝ ΣΥΝΕΧΕΙΑ ΝΑ ΕΧΩ ΤΟ ΙΔΙΟ ΓΡΑΦΗΜΑ ΜΕΣΩ ETHERNET,ΑΝ ΔΕΝ ΚΑΤΑΦΕΡΩ ΝΑ ΚΑΝΩ ΤΗΝ PROCESSING ΝΑ ΔΟΥΛΕΥΕΙ ΣΑΝ WEB SERVER. ΤΕΛΟΣ ΘΕΛΩ ΝΑ ΚΑΝΩ ΤΟ ΠΡΟΓΡΑΜΜΑ ΣΟΥ ΓΙΑ ANDROID.ΑΥΤΑ ΤΑ ΛΙΓΑ!!!!!!!!

    ΑπάντησηΔιαγραφή
  10. Αν κατάλαβα καλά θέλεις να κάνεις ένα interface, αλλά αυτός ο κώδικας είναι για να κάνει τον μικροελεγκτή να δουλέψει και να στείλει δεδομένα στο PC σου. Για να αξιοποιήσεις τα δεδομένα μέσα από ένα interface, πρέπει να το κάνεις μέσα από το IDE της Processing (http://processing.org/). Αυτός ο κώδικας που δείχνεις είναι ένα υποσύνολο της Processing προσαρμοσμένος για το arduino με λιγότερες εντολές (Arduino IDE) και όχι πάντως για να κάνεις παραθυριακή εφαρμογή και να παρακολουθείς τα δεδομένα σου με κάποιο γράφημα στον υπολογιστή σου.
    Η κανονική processing είναι άλλη ιστορία, παρόλα αυτά δεν θα δυσκολευτείς γιατί έχει την ίδια λογική.

    ΑπάντησηΔιαγραφή
  11. με το συγκεκριμενο ομως κωδικα που εχεις φτιαξει πως θα το κανουμε να δουλεψει με την sd και το ρολοι???

    ΑπάντησηΔιαγραφή
  12. Προτείνω για περισσότερο μοίρασμα γνώσης, εάν θέλεις, στείλε email στο dmaggioris@gmail.com, γιατί το κείμενο που έχω γράψει είναι μεγάλο και δεν το κάνει δεκτό το blog.

    ΑπάντησηΔιαγραφή
  13. οταν εβαλα τον κωδικα που ποσταρες στον Narendran Nv μου εβγαζε κανονικα τα αποτελεσματα κατω,ενω με τον αλλο κωδικα δεν επαιρνα αποτελεσματα στην οθονη.γιατι?

    ΑπάντησηΔιαγραφή
  14. Γιατί ο άλλος κώδικας είναι για τον μικροελεγκτή arduino, ενώ αυτός είναι της processing. Καταρχήν στον κώδικα της Processing, η υπορουτίνα επανάληψης του arduino (void loop()) έχει "αντικατασταθεί" με την void draw(). Την void draw() δεν την αναγνωρίζει το arduino. Μετά οι εντολές του arduino έχουν μία μικρή διαφοροποίηση με αυτές της processing. Στην ουσία το arduino είναι ένας μικρός κλώνος της processing. Για παράδειγμα στην processing δεν υπάρχει το Serial.print("kati"). Αρκεί να γράψεις μόνο print("kati") και φυσικά έχει και άλλες μικροδιαφορές. Παρόλα αυτά έχω καταλάβει ότι με την processing, φορτώνοντας την βιβλιοθήκη του arduino μπορείς να γράψεις και κώδικα για τον μικροεπεξεργαστή, αλλά δεν το έχω δοκιμάσει. Για την ώρα φορτώνω τον κώδικα στο arduino από τοn μεταγλωττιστή arduino και το γραφικό περιβάλλον με τον μεταγλωττιστή Processing.

    ΑπάντησηΔιαγραφή
  15. #include

    File myFile;

    int ledPin = 2;


    int result;

    #define ThermistorPIN 0 // Analog Pin 0
    float vcc = 5.03; // only used for display purposes, if used, set to the real measured Vcc (voltameter).
    float pad = 9970; // pad resistor value. Set the real value of the resistor in ohms(measure with ohmmeter)
    float thermr = 10000; // thermistor nominal resistance in ohms
    float samples[8]; // sampling array (8 samples/one measure). You can change this if you wish

    float Thermistor(int RawADC) {
    long Resistance;
    float Temp; // Dual-Purpose variable to save space.

    Resistance=((1024 * pad / RawADC) - pad);
    Temp = log(Resistance); // Saving the Log(resistance) so not to calculate it 4 times later
    Temp = 1 / (0.001129148 + (0.000234125 * Temp) + (0.0000000876741 * Temp * Temp * Temp));
    Temp = Temp - 273.15; // Convert Kelvin to Celsius

    return Temp;
    }

    void setup() {
    Serial.begin(9600);
    pinMode(ledPin, OUTPUT); //enable pin of LCD backlight
    Serial.print("Initializing SD card...");
    pinMode(10, OUTPUT);
    if (!SD.begin(4)) {
    Serial.println("initialization failed!");
    return;
    }
    Serial.println("initialization done.");
    myFile = SD.open("therm.txt", FILE_WRITE);


    }

    void loop() {
    digitalWrite(ledPin, HIGH); //LCD backlight on

    float temp;
    float tempDEC;

    // Temperature sampling (frequency=8)
    for (int i=0; i<=7; i++){
    samples[i] = Thermistor(analogRead(ThermistorPIN));
    temp = temp + samples[i];
    }

    temp = temp/8.0; // better precision
    if (myFile) {
    Serial.print("Writing to therm.txt...");
    myFile.print ("Η θερμοκρασία είναι: ");
    myFile.println(temp,DEC);


    // close the file:


    }

    // output the signal to serial (COM) port
    Serial.println(temp,DEC);

    // print the temperature value in LCD screen

    delay(5000);






    }



    δες λιγο τον κωδικα που εβαλα μου βγαζει προβλημα στην processing,

    ΑπάντησηΔιαγραφή
    Απαντήσεις
    1. Τι ακριβώς μήνυμα σου βγάζει στην Processing; Ο κώδικας αυτός στο arduino φαίνεται οκ. Αυτό που έχω να παρατηρήσω είναι ότι στην θύρα σου δίνεις την πρώτη φορά που συνδέεις το arduino έχεις 3 σήματα εάν έχεις την κάρτα επάνω και στην συνέχεια άλλα 2 (εάν και πάλι έχεις την κάρτα συνδεδεμένη) και μετά στο loop έχεις κάθε φορά 2 σήματα, εάν υπάρχει το αρχείο στην κάρτα σου, αλλιώς 1 σήμα εάν δεν υπάρχει αρχείο στην κάρτα. Προφανώς, στην processing δεν έχεις βάλει να ξεχωρίζει ποιο από τα σήματα κάθε φορά θέλεις (προφανώς θέλεις πάντα την θερμοκρασία (temp). Το αποτέλεσμα είναι να παίρνεις όταν τρέχεις την processing πότε: "Initializing SD card...", πότε "initialization failed!", "initialization done.", "Writing to therm.txt..." και την τιμή της θερμοκρασίας. Κατ' εμέ θα μπορούσες να κάνεις το εξής: Εάν θέλεις να παίρνεις μηνύματα π.χ. αρχικοποίηση κάρτας ή θέλεις να γράφει κάποιο επαναλαμβανόμενο μήνυμα και μετά από αυτό την τιμή της θερμοκρασίας τότε γράψε π.χ.:
      if (myFile) {
      String msg1 = W;
      ...}
      ή οποιοδήποτε μήνυμα (στο setup ή στο loop)
      και στείλε το στην θύρα (Serial.println(msg1); ή Serial.println(msg2); κλπ) και μετά στην processing θα ψαρέψεις τα σήματα, ως εξής (με βάση το σχόλιο στον Narendran Nv):
      ....if (inString != null) {
      if (inString == "W") println("Writing to therm.txt...");
      if (inString == "A") println("mpla mpla mpla...")
      if ((inString != "W") & (inString != "A")){
      tempC = float(inString); // αυτή είναι η μεταβλητή που θέλεις
      }
      ...}
      Τα παραπάνω μηνύματα μπορείς να τα γράψεις και στο γραφικό περιβάλλον με text ("μήνυμα", συντεταγμένη Χ, συντεταγμένη Υ)

      Το 2ο πρόβλημα που μπορείς να έχεις είναι ότι θα εάν έχεις ορίσει κάποιο font όπως στον κώδικά μου:
      PFont font10;
      PFont font12;
      PFont font24;
      θα πρέπει να εγκαταστήσεις πρώτα, αλλιώς θα σου βγάλει μήνυμα πριν τρέξει η processing. Πως τα εγκαθιστάς; Πηγαίνεις στο Tools --> Create Font --> επιλέγεις το είδος της γραμματοσειράς και το μέγεθος και πατάς οκ. Πιστεύω πως είναι αυτά, αλλιώς πες μου τι γράφει.

      Διαγραφή
  16. δεν βγαζει αποτελεσματα με τον κωδικα που εχω βαλει. εγω το μονο που θελω ειναι τα ιδια αποτελεσματα που εχω στο serial να μου τα αποθηκευει σε ενα txt.

    ΑπάντησηΔιαγραφή
  17. Έχεις δίκιο. Δεν σώζεις τις τιμές στην κάρτα σου. Μόνο το αρχείο ανοίγεις.
    Γράψε μετά το: myFile.println(temp,DEC);

    myFile.flush();

    και θα έχεις τιμές στο αρχείο σου.

    ΑπάντησηΔιαγραφή
  18. Αυτό το σχόλιο αφαιρέθηκε από τον συντάκτη.

    ΑπάντησηΔιαγραφή
  19. Δεν έχεις δηλώσει την library για την κάρτα SD
    #include

    για δοκίμασε τώρα

    ΑπάντησηΔιαγραφή
  20. ναι το καταλαβα!!!! αλλα αυτο που δεν καταλαβα ειναι στο

    String inString = myPort.readStringUntil(10);


    πρεπει να βαλω την com που χρησιμοποιω?

    ΑπάντησηΔιαγραφή
  21. Ποια port χρησιμοποιείς για το arduino; Δες κάτω δεξιά (μπλε γραμμή).
    Στο setup ορίζεις να ψάχνει τις θύρες από το 0:
    myPort = new Serial(this, Serial.list()[0], 9600);

    Εάν θέλεις αντί για 0 βάζεις την θύρα που έχεις συνδέσει το arduino. Εγώ έχω την COM 5, άρα μπορώ να γράψω:
    myPort = new Serial(this, Serial.list()[5], 9600);

    ΑπάντησηΔιαγραφή
  22. #include
    File myFile;
    int ledPin = 2;
    int result;
    #define ThermistorPIN 0 // Analog Pin 0
    float vcc = 5.03; // only used for display purposes, if used, set to the real measured Vcc (voltameter).
    float pad = 9970; // pad resistor value. Set the real value of the resistor in ohms(measure with ohmmeter)
    float thermr = 10000; // thermistor nominal resistance in ohms
    float samples[8]; // sampling array (8 samples/one measure). You can change this if you wish
    float Thermistor(int RawADC) {
    long Resistance;
    float Temp; // Dual-Purpose variable to save space.
    Resistance=((1024 * pad / RawADC) - pad);
    Temp = log(Resistance); // Saving the Log(resistance) so not to calculate it 4 times later
    Temp = 1 / (0.001129148 + (0.000234125 * Temp) + (0.0000000876741 * Temp * Temp * Temp));
    Temp = Temp - 273.15; // Convert Kelvin to Celsius
    return Temp;
    }
    void setup() {
    Serial.begin(9600);
    pinMode(ledPin, OUTPUT); //enable pin of LCD backlight
    Serial.print("Initializing SD card...");
    pinMode(10, OUTPUT);
    if (!SD.begin(4)) {
    Serial.println("initialization failed!");
    return;
    }
    Serial.println("initialization done.");
    myFile = SD.open("therm.txt", FILE_WRITE);
    }
    void loop() {
    digitalWrite(ledPin, HIGH); //LCD backlight on

    float temp;
    float tempDEC;

    for (int i=0; i<=7; i++){
    samples[i] = Thermistor(analogRead(ThermistorPIN));
    temp = temp + samples[i];
    }
    temp = temp/8.0; // better precision
    Serial.println(temp,DEC);
    myFile.print ("Η θερμοκρασία είναι: ");
    myFile.println(temp,DEC);
    myFile.flush();
    delay(5000);
    }

    ΑπάντησηΔιαγραφή
  23. Στο #include δηλώνεις βιβλιοθήκη. Δεν την έχεις δηλώσει.
    #include

    (sorry ξέχασα να στο γράψω)

    ΑπάντησηΔιαγραφή
  24. Δες email. Δεν μου έγραφε στα σχόλια μετά το include τo SD.h

    ΑπάντησηΔιαγραφή
  25. Βήμα - βήμα τώρα.
    "Ψάρεψε" τα σήματα στην processing και αξιοποίησε τα.
    Όπως είπαμε τα σήματα που θα πάρεις θα είναι σε μορφή string, όπως και η μεταβλητή σου.
    Μετά κάνεις την μεταβλητή σου πραγματικό αριθμό (float) και μετά αρχίζει το παιχνίδι με τα γραφικά.

    Παρεμπιπτόντως, τα κατάφερα με το ρολόι. Έφταιγε ο κρύσταλλος. Είναι κυλινδρικός και είναι για ρολόι (τον αγόρασα το απόγευμα). Στα site διάβασα ότι πρέπει να έχει 12.5pF για να δουλέψει σωστά και να κρατήσει συγχρονισμένο το ρολόι. Εγώ είχα τα σωστά κΗZ (32.768), αλλά δεν είχα την σωστή χωρητικότητα.
    Άλλο ένα πράγμα που μάθαμε και σήμερα!

    ΑπάντησηΔιαγραφή
  26. με την καρτα το εκανα να δουλεψει τελικα αλλα αυτο που εχω προβλημα τωρα ειναι με το ρολοι, αλλα παλι η processing δεν βγαζει αποτελεσματα καθολου!!!
    δεν μπορω να καταλαβω γιατι μου το κανει αυτο.αφου στην ουσια τα υπολοιπα τα βαζω να αποθηκευονται στην sd χωρις να επηρεαζει το "ψαρεμα"

    σου επισυναπτω τον κωδικα ,

    #include
    #include
    #include "RTClib.h"
    RTC_DS1307 RTC;

    File myFile;
    int ledPin = 2;
    int result;
    #define ThermistorPIN 0 // Analog Pin 0
    float vcc = 5.03; // only used for display purposes, if used, set to the real measured Vcc (voltameter).
    float pad = 9970; // pad resistor value. Set the real value of the resistor in ohms(measure with ohmmeter)
    float thermr = 10000; // thermistor nominal resistance in ohms
    float samples[8]; // sampling array (8 samples/one measure). You can change this if you wish
    float Thermistor(int RawADC) {
    long Resistance;
    float Temp; // Dual-Purpose variable to save space.
    Resistance=((1024 * pad / RawADC) - pad);
    Temp = log(Resistance); // Saving the Log(resistance) so not to calculate it 4 times later
    Temp = 1 / (0.001129148 + (0.000234125 * Temp) + (0.0000000876741 * Temp * Temp * Temp));
    Temp = Temp - 273.15; // Convert Kelvin to Celsius
    return Temp;
    }
    void setup() {

    Serial.begin(9600);
    Wire.begin();
    RTC.begin();

    if (! RTC.isrunning()) {
    Serial.println("RTC is NOT running!");
    // following line sets the RTC to the date & time this sketch was compiled
    RTC.adjust(DateTime(__DATE__, __TIME__));
    }


    pinMode(ledPin, OUTPUT); //enable pin of LCD backlight
    Serial.print("Initializing SD card...");
    pinMode(10, OUTPUT);
    if (!SD.begin(4)) {
    Serial.println("initialization failed!");
    return;
    }
    Serial.println("initialization done.");
    myFile = SD.open("therm.txt", FILE_WRITE);
    }
    void loop() {

    DateTime now = RTC.now();

    DateTime future (now.unixtime() + 7 * 86400L + 30);

    digitalWrite(ledPin, HIGH); //LCD backlight on

    float temp;
    float tempDEC;

    for (int i=0; i<=7; i++){
    samples[i] = Thermistor(analogRead(ThermistorPIN));
    temp = temp + samples[i];
    }
    temp = temp/8.0; // better precision
    Serial.println(temp,DEC);
    myFile.print ("Η θερμοκρασία είναι: ");
    myFile.print(temp,DEC);
    myFile.print("στις :");
    myFile.print(future.year(), DEC);
    myFile.print('/');
    myFile.print(future.month(), DEC);
    myFile.print('/');
    myFile.print(future.day(), DEC);
    myFile.print(' ');
    myFile.print(future.hour(), DEC);
    myFile.print(':');
    myFile.print(future.minute(), DEC);
    myFile.print(':');
    myFile.println(future.second(), DEC);

    myFile.flush();
    delay(5000);
    }

    ΑπάντησηΔιαγραφή
  27. In this post there is no any SD card, but in this post(http://roscovnicoff.blogspot.gr/2012/07/temperature-datalogger.html) the digital thermometer is converted to temperature datalogger device. Thus, it is necessary to have a storage medium to record the temperature data. In my case, I use an SD card to record data at time step, that I have already set through the menu. I transferred the ATmega microcontroller to independent circuit with 9v battery and I connected an LCD monitor and an SD card to it. This post is in greek, but the images and code can speak for you! If you want any help, I am at your disposal

    ΑπάντησηΔιαγραφή
  28. A thermometer is a useful tool in our world today as it can tell you the thermometers of whatever it’s being used to measure. The temperature is one of the most important factors in a weather forecast, so a weather thermometer is one of the most important resources available to those who research the weather. The development of the thermometer can be traced back to Galileo Galilei in the 16th century. Although Galileo himself didn’t single-handedly come up with the invention of the thermometer , he found that objects of different densities rise and fall. This is the primary principle behind the first thermometers . The liquid inside the temperate gauge rises when it gets warmer, because it becomes less dense. The colder the air, the lower the liquid drops in the temperature gauge, because colder air is denser than warmer air.

    ΑπάντησηΔιαγραφή
  29. Hi,
    I have read whole post & found that it is very interesting for Digital Thermostat.Very great blog & I hope that you will be posting more lots of information about this topic. Thanks for sharing this information.

    ΑπάντησηΔιαγραφή
  30. I need help with making a program that will input 3 temp readings from different sensors using NTC resistance so I can set up different outputs to turn a boiler burner off/on. Thank you.

    ΑπάντησηΔιαγραφή
  31. How can I adapt this code to read negative temperatures? I'm having problems with the string joinnum. Thanks fot the project it's what I needed to make my weather station!

    ΑπάντησηΔιαγραφή