INFO: Dieses Forum nutzt Cookies...
Cookies sind für den Betrieb des Forums unverzichtbar. Mit der Nutzung des Forums erklärst Du dich damit einverstanden, dass wir Cookies verwenden.

Es wird in jedem Fall ein Cookie gesetzt um diesen Hinweis nicht mehr zu erhalten. Desweiteren setzen wir Google Adsense und Google Analytics ein.

Antwort schreiben 
 
Themabewertung:
  • 0 Bewertungen - 0 im Durchschnitt
  • 1
  • 2
  • 3
  • 4
  • 5
Temperatursensor NTC 5K
15.12.2020, 18:39
Beitrag #1
Temperatursensor NTC 5K
Hallo an alle,
ich habe einen Temp Sensor NTC 5K an meinen Arduino angeschlossen und gebe die Temp. an ein I2c Display aus. Soweit funktionier alles.
Nun habe ich vor mit einem zweiten Temp Sensor eine zweite Temperatur anzeigen zu lassen.
Ich habe auf einem Bradboard die Schaltung ein zweites mal aufgebaut und das Datenkabel an einen anderen Analogpin angeschlossen und das Display so Programmier das es zwei Temperaturen anzeigt.
Mein Problem ist allerdings das es keine getrenten Temp anzeigen gibt.
Wenn ich Senor 1 erwärme dann steigen beide Werte im Display.

Wie bekommt man das hin, das Sensor 1 und 2 jeder seinen aktuellen Wert ausgibt?

Das ist mein verwendeter Code:
Code:
/*   /* 0- General */

    int decimalPrecision = 1;           // decimal places for all values shown in LED Display & Serial Monitor


    /* 1- Temperature Measurement */
    
    int ThermistorPin = A1;            // The analog input pin for measuring temperature
    int ThermistorPin2 = A2;
    float voltageDividerR1 = 10000;    // Resistor value in R1 for voltage devider method
    float BValue = 2500;               // The B Value of the thermistor for the temperature measuring range
    float R1 = 5000;                   // Thermistor resistor rating at based temperature (25 degree celcius)
    float T1 = 298.15;                 /* Base temperature T1 in Kelvin (default should be at 25 degree)*/
    float R2 ;                         /* Resistance of Thermistor (in ohm) at Measuring Temperature*/
    float R3;
    float T2 ;                          /* Measurement temperature T2 in Kelvin */
    float T3 ;                        /* Measurement temperature T3 in Kelvin */
    
    float a ;                        /* Use for calculation in Temperature*/
    float b ;                         /* Use for calculation in Temperature*/
    float c ;                         /* Use for calculation in Temperature*/
    float d ;                         /* Use for calculation in Temperature*/
    float e = 2.718281828 ;           /* the value of e use for calculation in Temperature*/
    
    float tempSampleRead  = 0;       /* to read the value of a sample including currentOffset1 value*/
    float tempLastSample  = 0;       /* to count time for each sample. Technically 1 milli second 1 sample is taken */
    float tempSampleSum   = 0;       /* accumulation of sample readings */
    float tempSampleCount = 0;       /* to count number of sample. */
    float tempMean ;                  /* to calculate the average value from all samples, in analog values*/


    /* 2 - LCD Display  */

                  
    #include <LiquidCrystal_I2C.h>
    LiquidCrystal_I2C lcd(0x27, 16, 2);
    unsigned long startMillisLCD;         /* start counting time for LCD Display */
    unsigned long currentMillisLCD;          /* current counting time for LCD Display */
    const unsigned long periodLCD = 1000;   // refresh every X seconds (in seconds) in LED Display. Default 1000 = 1 second


    
void setup()
{
    /* 0- General */
    
    Serial.begin(9600);
    lcd.begin();                                  /* Tell Arduino that our LCD has 16 columns and 2 rows*/
    lcd.setCursor(0,0);                               /* Set LCD to start with upper left corner of display*/  
    startMillisLCD = millis();                        /* Start counting time for LCD display*/

}

void loop()

{
  
    /* Temp L.: - Temperature Measurement */

    if(millis() >= tempLastSample + 1)                                  /* every 1 milli second taking 1 reading */
        {
            tempSampleRead = analogRead(ThermistorPin);
            tempSampleSum = tempSampleSum+tempSampleRead;            /* add all analog value for averaging later*/
            tempSampleCount = tempSampleCount+1;                    /* keep counting the sample quantity*/
            tempLastSample = millis();                              /* reset the time in order to repeat the loop again*/
        }

    if(tempSampleCount == 1000)                                        /* after 1000 sample readings taken*/
        {
            tempMean = tempSampleSum / tempSampleCount;              /* find the average analog value from those data*/
            R2 = (voltageDividerR1*tempMean)/(1023-tempMean);        /* convert the average analog value to resistance value*/
    
            a = 1/T1;                                                /* use for calculation */
            b = log10(R1/R2);                                        /* use for calculation */
            c = b / log10(e);                                       /* use for calculation */
            d = c / BValue ;                                       /* use for calculation */
            T2 = 1 / (a- d);                                /* the measured temperature value based on calculation (in Kelvin) */
            Serial.print(T2 - 273.15,decimalPrecision);     /* display in Serial monitor the temperature in Celcius*/
            Serial.println(" °C");
            
            tempSampleSum = 0;                      /* reset all the total analog value back to 0 for the next count */
            tempSampleCount = 0;                  /* reset the total number of samples taken back to 0 for the next count*/
        }
    
    /* Temp L.: - LCD Display  */
        
    currentMillisLCD = millis();                                /* Set counting time for LCD Display*/
    if (currentMillisLCD - startMillisLCD >= periodLCD)                /* for every x seconds, run the codes below*/
        {
            lcd.setCursor(0,0);                                   /* Set cursor to first colum 0 and second row 1  */
            lcd.print("Temp L.:");
            lcd.print(T2 - 273.15,decimalPrecision);           /* display current value in LCD in first row  */
            lcd.print(char(223));                               /* print the symbol "degree"*/
            lcd.print("C                  ");
            startMillisLCD = currentMillisLCD ;               /* Set the starting point again for next counting time */
        }

        {
  
    /* Temp R.: - Temperature Measurement */

    if(millis() >= tempLastSample + 1)                           /* every 1 milli second taking 1 reading */
        {
            tempSampleRead = analogRead(ThermistorPin2);
            tempSampleSum = tempSampleSum+tempSampleRead;       /* add all analog value for averaging later*/
            tempSampleCount = tempSampleCount+1;               /* keep counting the sample quantity*/
            tempLastSample = millis();                      /* reset the time in order to repeat the loop again*/
        }

    if(tempSampleCount == 1000)                               /* after 1000 sample readings taken*/
        {
            tempMean = tempSampleSum / tempSampleCount;                 /* find the average analog value from those data*/
            R3 = (voltageDividerR1*tempMean)/(1023-tempMean);     /* convert the average analog value to resistance value*/
    
            a = 1/T1;                                               /* use for calculation */
            b = log10(R1/R3);                                                                          
            c = b / log10(e);                                                                          
            d = c / BValue ;                                                                          
            T3 = 1 / (a- d);                              /* the measured temperature value based on calculation (in Kelvin) */
            Serial.print(T3 - 273.15,decimalPrecision);  /* display in Serial monitor the temperature in Celcius*/
            Serial.println(" °C");
            
            tempSampleSum = 0;                   /* reset all the total analog value back to 0 for the next count */
            tempSampleCount = 0;                       /* reset the total number of samples taken back to 0 for the next count*/
        }
    
    /* Temp R.: - LCD Display  */
        
    currentMillisLCD = millis();                                  /* Set counting time for LCD Display*/
    if (currentMillisLCD - startMillisLCD >= periodLCD)                   /* for every x seconds, run the codes below*/
        {
            lcd.setCursor(0,1);                                             /* Set cursor to first colum 0 and second row 1  */
            lcd.print("Temp R.:");
            lcd.print(T3 - 273.15,decimalPrecision);                  /* display current value in LCD in first row  */
            lcd.print(char(223));                                      /* print the symbol "degree"*/
            lcd.print("C                  ");
            startMillisLCD = currentMillisLCD ;                 /* Set the starting point again for next counting time */
        }

        }}

Nach diesem Prinziep habe ich meine Sensoren angeschlossen, nur eben zwie mal statt nur einmal.
Alle Beiträge dieses Benutzers finden
Diese Nachricht in einer Antwort zitieren
15.12.2020, 20:07
Beitrag #2
RE: Temperatursensor NTC 5K
Das macht so ja nun auch keinen Sinn, oder soll ich meinen Beitrag auch nochmal Wiederholen ?

Gruß Dieter

I2C = weniger ist mehr: weniger Kabel, mehr Probleme. Cool
Alle Beiträge dieses Benutzers finden
Diese Nachricht in einer Antwort zitieren
17.12.2020, 17:21
Beitrag #3
RE: Temperatursensor NTC 5K
Sorry für dieses Chaos, aber ich habe deinen Tipp befolgt und dieses ist herrausgekommen und es Funktioniert jetzt.

Code:
/* 0- General */

    int decimalPrecision = 1;           // decimal places for all values shown in LED Display & Serial Monitor


    /* 1- Temperature Measurement */
    
    int ThermistorPin = A1;            // The analog input pin for measuring temperature
    int ThermistorPin2 = A2;
    float voltageDividerR1 = 10000;    // Resistor value in R1 for voltage devider method
    float BValue = 3650;               // The B Value of the thermistor for the temperature measuring range
    float R1 = 5000;                   // Thermistor resistor rating at based temperature (25 degree celcius)
    float T1 = 298.15;                 /* Base temperature T1 in Kelvin (default should be at 25 degree)*/
    float R2 ;                         /* Resistance of Thermistor (in ohm) at Measuring Temperature*/
    float R3 ;
    float T2 ;                          /* Measurement temperature T2 in Kelvin */
    float T3 ;                        /* Measurement temperature T3 in Kelvin */
    
    float a ;                        /* Use for calculation in Temperature*/
    float b ;                         /* Use for calculation in Temperature*/
    float c ;                         /* Use for calculation in Temperature*/
    float d ;                         /* Use for calculation in Temperature*/
    float e = 2.718281828 ;           /* the value of e use for calculation in Temperature*/
    
    float tempSampleRead  = 0;       /* to read the value of a sample including currentOffset1 value*/
    float tempLastSample  = 0;       /* to count time for each sample. Technically 1 milli second 1 sample is taken */
    float tempSampleSum   = 0;       /* accumulation of sample readings */
    float tempSampleCount = 0;       /* to count number of sample. */
    float tempMean ;                  /* to calculate the average value from all samples, in analog values*/

    float tempSampleRead2  = 0;       /* to read the value of a sample including currentOffset1 value*/
    float tempLastSample2  = 0;       /* to count time for each sample. Technically 1 milli second 1 sample is taken */
    float tempSampleSum2   = 0;       /* accumulation of sample readings */
    float tempSampleCount2 = 0;       /* to count number of sample. */
    float tempMean2 ;                  /* to calculate the average value from all samples, in analog values*/


    /* 2 - LCD Display  */

                  
    #include <LiquidCrystal_I2C.h>
    LiquidCrystal_I2C lcd(0x27, 16, 2);
    unsigned long startMillisLCD;         /* start counting time for LCD Display */
    unsigned long currentMillisLCD;          /* current counting time for LCD Display */
    const unsigned long periodLCD = 1000;   // refresh every X seconds (in seconds) in LED Display. Default 1000 = 1 second


    
void setup()
{
    /* 0- General */
    
    Serial.begin(9600);
    lcd.begin();                                  /* Tell Arduino that our LCD has 16 columns and 2 rows*/
    lcd.setCursor(0,0);                               /* Set LCD to start with upper left corner of display*/  
    startMillisLCD = millis();                        /* Start counting time for LCD display*/

}

void loop()

{
  
    /* Temp L.: - Temperature Measurement */

    if(millis() >= tempLastSample + 1)                                  /* every 1 milli second taking 1 reading */
        {
            tempSampleRead = analogRead(ThermistorPin);
            tempSampleSum = tempSampleSum+tempSampleRead;            /* add all analog value for averaging later*/
            tempSampleCount = tempSampleCount+1;                    /* keep counting the sample quantity*/
            tempLastSample = millis();                              /* reset the time in order to repeat the loop again*/
        }

    if(tempSampleCount == 1000)                                        /* after 1000 sample readings taken*/
        {
            tempMean = tempSampleSum / tempSampleCount;              /* find the average analog value from those data*/
            R2 = (voltageDividerR1*tempMean)/(1023-tempMean);        /* convert the average analog value to resistance value*/
    
            a = 1/T1;                                                /* use for calculation */
            b = log10(R1/R2);                                        /* use for calculation */
            c = b / log10(e);                                       /* use for calculation */
            d = c / BValue ;                                       /* use for calculation */
            T2 = 1 / (a- d);                                /* the measured temperature value based on calculation (in Kelvin) */
            Serial.print(T2 - 273.15,decimalPrecision);     /* display in Serial monitor the temperature in Celcius*/
            Serial.println(" °C");
            
            tempSampleSum = 0;                      /* reset all the total analog value back to 0 for the next count */
            tempSampleCount = 0;                  /* reset the total number of samples taken back to 0 for the next count*/
        }
    
    /* Temp L.: - LCD Display  */
        
    currentMillisLCD = millis();                                /* Set counting time for LCD Display*/
    if (currentMillisLCD - startMillisLCD >= periodLCD)                /* for every x seconds, run the codes below*/
        {
            lcd.setCursor(0,0);                                   /* Set cursor to first colum 0 and second row 1  */
            lcd.print("Temp L.:");
            lcd.print(T2 - 273.15,decimalPrecision);           /* display current value in LCD in first row  */
            lcd.print(char(223));                               /* print the symbol "degree"*/
            lcd.print("C                  ");
            startMillisLCD = currentMillisLCD ;               /* Set the starting point again for next counting time */
        }

        {
  
    /* Temp R.: - Temperature Measurement */

    if(millis() >= tempLastSample2 + 1)                           /* every 1 milli second taking 1 reading */
        {
            tempSampleRead2 = analogRead(ThermistorPin2);
            tempSampleSum2 = tempSampleSum2+tempSampleRead2;       /* add all analog value for averaging later*/
            tempSampleCount2 = tempSampleCount2+1;               /* keep counting the sample quantity*/
            tempLastSample2 = millis();                      /* reset the time in order to repeat the loop again*/
        }

    if(tempSampleCount2 == 1000)                               /* after 1000 sample readings taken*/
        {
            tempMean2 = tempSampleSum2 / tempSampleCount2;                 /* find the average analog value from those data*/
            R3 = (voltageDividerR1*tempMean2)/(1023-tempMean2);     /* convert the average analog value to resistance value*/
    
            a = 1/T1;                                               /* use for calculation */
            b = log10(R1/R3);                                                                          
            c = b / log10(e);                                                                          
            d = c / BValue ;                                                                          
            T3 = 1 / (a- d);                              /* the measured temperature value based on calculation (in Kelvin) */
            Serial.print(T3 - 273.15,decimalPrecision);  /* display in Serial monitor the temperature in Celcius*/
            Serial.println(" °C");
            
            tempSampleSum2 = 0;                   /* reset all the total analog value back to 0 for the next count */
            tempSampleCount2 = 0;                       /* reset the total number of samples taken back to 0 for the next count*/
        }
    
    /* Temp R.: - LCD Display  */
        
    currentMillisLCD = millis();                                  /* Set counting time for LCD Display*/
    if (currentMillisLCD - startMillisLCD >= periodLCD)                   /* for every x seconds, run the codes below*/
        {
            lcd.setCursor(0,1);                                             /* Set cursor to first colum 0 and second row 1  */
            lcd.print("Temp R.:");
            lcd.print(T3 - 273.15,decimalPrecision);                  /* display current value in LCD in first row  */
            lcd.print(char(223));                                      /* print the symbol "degree"*/
            lcd.print("C                  ");
            startMillisLCD = currentMillisLCD ;                 /* Set the starting point again for next counting time */
        }

        }}

Ich habe die Codes für die Berechnung Dupliziert und umbenannt so das der zweite Sensor seine eigene Rechenformel hat.

Vielen dank für für den Hinweis und Entschuldiung das ich der Meinung war, dass das Thema "Arduinoprojekte" besser zu meinem Arduinoprojekt passen würde. Wenn ich gewust hätte das es nur an der Programmierung liegt hätte ich es natürlich gleich in den Tread "Programmierung " geschrieben.
Alle Beiträge dieses Benutzers finden
Diese Nachricht in einer Antwort zitieren
17.12.2020, 17:27
Beitrag #4
RE: Temperatursensor NTC 5K
Ok, alles klar.
Dann hat mein Tipp aus dem gelöschten Thread dich ja doch noch erreicht. Wink

Prima, dass es jetzt funktioniert und danke für deine Rückmeldung.

Gruß Dieter

I2C = weniger ist mehr: weniger Kabel, mehr Probleme. Cool
Alle Beiträge dieses Benutzers finden
Diese Nachricht in einer Antwort zitieren
Antwort schreiben 


Möglicherweise verwandte Themen...
Thema: Verfasser Antworten: Ansichten: Letzter Beitrag
  Temperatursensor ST1147 "misst" falschherum DerMaschbaustudent 20 1.006 26.11.2020 11:44
Letzter Beitrag: Bitklopfer
  Temperatursensor DS18B20 direkt auslesen Igom 9 1.775 26.03.2020 19:21
Letzter Beitrag: hotsystems
  Temperatursensor Obermuda 5 3.718 11.01.2017 11:37
Letzter Beitrag: Obermuda
  Digitaler und analoger Temperatursensor unterschiedlich Pit 3 3.184 16.01.2016 19:05
Letzter Beitrag: Pit
Question Arduino Temperatursensor in exel datei loggen Tom 2 4.450 12.07.2015 10:30
Letzter Beitrag: rkuehle
  Temperatursensor Programmierung Anton11 6 5.387 29.05.2015 09:55
Letzter Beitrag: fraju
  Temperatursensor SHT75 um 3 Grad ungenau Cray-1 4 3.677 26.01.2015 14:45
Letzter Beitrag: RMR
  KTY Temperatursensor mit einem I2C Display auslesen. Einsteiger94 2 2.975 27.10.2014 21:09
Letzter Beitrag: Bitklopfer
  433 MHz Temperatursensor mit einem Arduino Uno auslesen Freddy 1 13.422 16.12.2013 00:10
Letzter Beitrag: rkuehle

Gehe zu:


Benutzer, die gerade dieses Thema anschauen: 1 Gast/Gäste