NTC thermistor (collection / list & code implementing)

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
5ko
Normal user
Posts: 33
Joined: 03 Jan 2016, 17:58
Contact:

NTC thermistor (collection / list & code implementing)

#1 Post by 5ko » 29 Mar 2016, 20:54

Part one (collection/ list )
My proposal is to insert in the analog readings sample / average option.
Reason:
Nearly all analog sensors suffer from low immunity to RFI / EMI noise and other interference, especially if our devices get out from the experimental phase.
In the industrial electronics is unavoidable for more precise readings.

Part two (if it can not be in collection list)
Somewhere in the forum I found that lists of wishes does do not extend to sensors that already exist in several forms, for example, thermal sensors ...So I need help with code.
An example of working with NTC Thermistor is described on pages Adafruit and with the Arduino gave a very good and accurate results.

https://learn.adafruit.com/thermistor/u ... thermistor
Final code:

Code: Select all

    // which analog pin to connect
    #define THERMISTORPIN A0         
    // resistance at 25 degrees C
    #define THERMISTORNOMINAL 10000      
    // temp. for nominal resistance (almost always 25 C)
    #define TEMPERATURENOMINAL 25   
    // how many samples to take and average, more takes longer
    // but is more 'smooth'
    #define NUMSAMPLES 5
    // The beta coefficient of the thermistor (usually 3000-4000)
    #define BCOEFFICIENT 3950
    // the value of the 'other' resistor
    #define SERIESRESISTOR 10000    
     
    int samples[NUMSAMPLES];
     
    void setup(void) {
      Serial.begin(9600);
      analogReference(EXTERNAL);
    }
     
    void loop(void) {
      uint8_t i;
      float average;
     
      // take N samples in a row, with a slight delay
      for (i=0; i< NUMSAMPLES; i++) {
       samples[i] = analogRead(THERMISTORPIN);
       delay(10);
      }
     
      // average all the samples out
      average = 0;
      for (i=0; i< NUMSAMPLES; i++) {
         average += samples[i];
      }
      average /= NUMSAMPLES;
     
      Serial.print("Average analog reading "); 
      Serial.println(average);
     
      // convert the value to resistance
      average = 1023 / average - 1;
      average = SERIESRESISTOR / average;
      Serial.print("Thermistor resistance "); 
      Serial.println(average);
     
      float steinhart;
      steinhart = average / THERMISTORNOMINAL;     // (R/Ro)
      steinhart = log(steinhart);                  // ln(R/Ro)
      steinhart /= BCOEFFICIENT;                   // 1/B * ln(R/Ro)
      steinhart += 1.0 / (TEMPERATURENOMINAL + 273.15); // + (1/To)
      steinhart = 1.0 / steinhart;                 // Invert
      steinhart -= 273.15;                         // convert to C
     
      Serial.print("Temperature "); 
      Serial.print(steinhart);
      Serial.println(" *C");
     
      delay(1000);
    }
Would be someone willing to help with the implementation of this code in ADS1115 plug in or if it's too much then instructed me on how to edit the code in plugin to send value as float...later I somehow put the rest of the code in the plug in.
The reason:
Even though we are in the era of digital sensors, many branded manufacturers still do not give up from analog NTC Thermistors and still produce serious machines / controllers with this type of sensor. What is the worst sometimes they are mechanically mounted or glued/molded so that the replacing them almost unfeasible.
Your help is appreciated

User avatar
costo
Normal user
Posts: 500
Joined: 21 Nov 2015, 15:03
Location: NL, zw-NB

Re: NTC thermistor (collection / list & code implementing)

#2 Post by costo » 29 Mar 2016, 22:25

How I would try to solve this:

Take the Analog _P002 plugin
rename all the instances of _002 to _110 (110 or any other number between 100 and 200)
Change in line 24 "Device[deviceCount].FormulaOption = true;" true to false
Save the plugin as _P110_Thermistor.

The not_so_easy part is to modify the routine where data is read and where you want to applly your own formula to the read data.

case PLUGIN_READ:
{
int value = analogRead(A0);
UserVar[event->BaseVarIndex] = (float)value;
String log = F("ADC : Analog value: ");
log += value;
addLog(LOG_LEVEL_INFO,log);
success = true;
break;
}

This you do this, it may work for one particular thermistor. Making the device parameters editable is more difficult.

riker1
Normal user
Posts: 344
Joined: 26 Dec 2017, 18:02

Re: NTC thermistor (collection / list & code implementing)

#3 Post by riker1 » 29 Oct 2018, 13:34

Hi

old thread but
is there a thermistor plugin available right now?

thanks

Post Reply

Who is online

Users browsing this forum: No registered users and 12 guests