Off Road Fridge Remote Temperature Monitor

Made a remote temperature monitor for my trucks fridge and freezer, and it seemed to work just fine at first. Both the remote monitor and the fridge unit were reporting 81deg for both freezer and fridge compartments before the fridge cooled down.

However, when the temperature dropped the remote monitor was way off.
The fridge unit was reporting 0deg and 30 deg - what I had set it too.
The remote unit I made was reporting 20deg and 42deg respectively.

What I know:
The location of the thermistor on the fridge unit is unknown.
The fridge unit thermistor spec is uknown.
The location of the thermistor on my remote unit is near the top of each compartment.

My Remote Unit is composed of the following:
Arduino Nano
Thermistor MPN: C1.4x.106
Thermistor Type: NTC 10k B=3435
Thermistor Cable Length: 16.5’
OLED

See fritzing diagram attached.

Code below:

/* REMOTE FRIDGE MONITOR
 *  
 *  
 *  
 *  Code hacked together using the following sources:
 *  Thermistor: https://learn.adafruit.com/thermistor/using-a-thermistor
 *  OLED: Unknown Source
 *  
 *  Connections as follows:
 *  OLED
 *  GRD: GRD
 *  VCC: 3.3v
 *  SCL: A5
 *  SCA: A4
 *  
 *  Thermistor 1
 *  GRD: GRD
 *  Positive: 10k resistor/A0/3v/AREF
 *  
 *  Thermistor 2
 *  GRD: GRD
 *  Positive: 10k resistor/A1/3v/AREF
 *  
 *  
 */


// LIBRARIES

#include <Adafruit_GFX.h>             // Adafruit Graphics Library for OLED
#include <ArducamSSD1306.h>           // Modification of Adafruit_SSD1306 for ESP8266 compatibility
#include <Wire.h>                     // For I2C comm, but needed for not getting compile error
#include <math.h>                     // Just for some math


// PIN DEFINITIONS

#define OLED_RESET  7                 // Pin 7 -RESET digital signal
#define THERMISTORPIN1 A0             // Which analog pin to connect to Thermistor    
#define THERMISTORPIN2 A1             // Which analog pin to connect to Thermistor
#define THERMISTORNOMINAL 10000       // Resistance at 25 degrees C = 10k
#define TEMPERATURENOMINAL 25         // Temp. for nominal resistance (almost always 25 C)
#define NUMSAMPLES 5                  // How many samples to take and average, more takes longer but is more 'smooth'
#define BCOEFFICIENT 3950             // The beta coefficient of the thermistor (usually 3000-4000)
#define SERIESRESISTOR 10000          // The value of the 'other' resistor

int samples[NUMSAMPLES];

ArducamSSD1306 display(OLED_RESET);   // FOR I2C


void setup(void)
{
  analogReference(EXTERNAL);
  
                                      // SSD1306 Init
  display.begin();                    // Switch OLED
  display.clearDisplay();             // Clear the buffer
}


void loop() {
  uint8_t i;
  uint8_t j;
  float average1;
  float average2;

 
  for (i=0; i< NUMSAMPLES; i++) {                 // Take N samples in a row at Thermistor 1, with a slight delay
   samples[i] = analogRead(THERMISTORPIN1);
   delay(10);
  }
  
  average1 = 0;                                   // Average all the Thermistor 1 samples out
  for (i=0; i< NUMSAMPLES; i++) {
     average1 += samples[i];
  }
  average1 /= NUMSAMPLES;

  for (j=0; j< NUMSAMPLES; j++) {                 // Take N samples in a row at Thermistor 2, with a slight delay
   samples[j] = analogRead(THERMISTORPIN2);
   delay(10);
  }
  average2 = 0;                                   // Average all the Thermistor 1 samples out
  for (j=0; j< NUMSAMPLES; j++) {
     average2 += samples[j];
  }
  average2 /= NUMSAMPLES;
  
  
  average1 = 1023 / average1 - 1;                 // Convert the value to resistance for Thermistor 1
  average1 = SERIESRESISTOR / average1;

  average2 = 1023 / average2 - 1;                 // Convert the value to resistance for Thermistor 2
  average2 = SERIESRESISTOR / average2;
  
  
  float steinhart1;                                     //Converting Thermistor 1 signal into temperature
  steinhart1 = average1 / THERMISTORNOMINAL;            // (R/Ro)
  steinhart1 = log(steinhart1);                         // ln(R/Ro)
  steinhart1 /= BCOEFFICIENT;                           // 1/B * ln(R/Ro)
  steinhart1 += 1.0 / (TEMPERATURENOMINAL + 273.15);    // + (1/To)
  steinhart1 = 1.0 / steinhart1;                        // Invert
  steinhart1 -= 273.15;                                 // convert to C
  steinhart1 = (1.8*steinhart1)+32;                     // convert to f
  steinhart1 = round(steinhart1);

  float steinhart2;                                     //Converting Thermistor 2 signal into temperature
  steinhart2 = average2 / THERMISTORNOMINAL;            // (R/Ro)
  steinhart2 = log(steinhart2);                         // ln(R/Ro)
  steinhart2 /= BCOEFFICIENT;                           // 1/B * ln(R/Ro)
  steinhart2 += 1.0 / (TEMPERATURENOMINAL + 273.15);    // + (1/To)
  steinhart2 = 1.0 / steinhart2;                        // Invert
  steinhart2 -= 273.15;                                 // convert to C
  steinhart2 = (1.8*steinhart2)+32;                     // convert to f
  steinhart2 = round(steinhart2);


  
  // Upper Yellow Text Box                              // SSD1306 Init
  display.setTextColor(WHITE,BLACK);                    // White is the font color, Black is the background. Having a black background is the key to not getting a flicker
  display.setTextSize(2);
  display.setCursor(0,2);                               // First number is alignment to the left, second number is vertical alignment
  display.println("FRZ");
  display.setCursor(64,2);
  display.println("REF");
  
  // Upper Yellow Text Box     
  display.setTextSize(4);
  display.setTextColor(WHITE,BLACK);
  display.setCursor(0,25);
  display.println(steinhart1,0);
  display.drawCircle(50,29,3,1);                        // Degree symbol
  display.setCursor(64,25);
  display.println(steinhart2,0);
  display.drawCircle(114,29,3,1);                       // Degree symbol
  display.display();
  delay(2000);

}

You’ve modified these parameters to match your thermistor/ circuit?

#define THERMISTORNOMINAL 10000       // Resistance at 25 degrees C = 10k
#define TEMPERATURENOMINAL 25         // Temp. for nominal resistance (almost always 25 C)
#define BCOEFFICIENT 3950             // The beta coefficient of the thermistor (usually 3000-4000)
#define SERIESRESISTOR 10000          // The value of the 'other' resistor

You know what, I did the 3950 which should be 3450. Nice catch. The rest is per spec.

Was that the only problem ?

If there is still an issue, provide a link to the data sheet of the thermistor.

The resistors in your Fritzing have a 220 Ohm colour scheme. I guess then that is only for illustration.

Hi,
Welcome to the forum.

Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html . Then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

Thanks.. Tom... :slight_smile:

I guess then that is only for illustration.

Fritzing diagrams are supposed to look cool, rather than convey useful or correct information.

Hi,
With 16 feet of cable on each sensor, you are asking for noise problems.
Have you put any bypass capacitors on the thermistor leads?

Tom.. :slight_smile:

6v6gt:
Was that the only problem ?

If there is still an issue, provide a link to the data sheet of the thermistor.

The resistors in your Fritzing have a 220 Ohm colour scheme. I guess then that is only for illustration.

I used a 10k resistor. Fritzing didn't have one loaded so I just used the one that was available.

TomGeorge:
Hi,
With 16 feet of cable on each sensor, you are asking for noise problems.
Have you put any bypass capacitors on the thermistor leads?

Tom.. :slight_smile:

Thanks Tom,

I did not. I'm new to electronics. The thermistor came with 16.5' of cable on it, and the reviews seemed to suggest that people were doing fine with that. Having said that, I only need about 10'.

I'll look into the bypass capacitors. Can you guide me a little?

Thanks again!

Got it to work. All that was incorrect was the B Coefficient. that did the trick. Thank you all for the help!

Sorry about the non-scrolling code.