Arduino Waterproof Thermistor LCD1602A

Hello world! Today i wanted to test a new sensor “Arduino Waterproof Thermistor” for my collection and i attached a 1602A LCD to it using a I2C on the LCD. You can easily change it in the code when you want to use normal wiring by uncommenting and commenting some lines. There are 2 codes 1 For fahrenheit & 1 for Celsius. Follow the next step for the Schematic Code & Parts list.

You can simply change the code to normal wiring on the Arduino Waterproof Thermistor if you do not want to use the I2C, I put the lines in the code already. I attached to codes for Celsius & Fahrenheit, but you can also edit those by uncommenting some lines & by commenting others. Just read the code, it’s all there.

Schematic:
Arduino Waterproof Thermistor
Simply wire everything up like the schematic, solder your sensor to a Prototype Board or use a breadboard.
I also added a scanner to find out your I2C address.

This is the Sensor i used.
Arduino Waterproof Thermistor

Parts list:
Arduino uno, I used the RobotDyn uno. (Has 8 analog pins)
NTC Thermistor Waterproof.
Jumper wires MM/FF/MF set
LCD 1602A
PerfBoard/Prototype Board or Breadboard
.

Code Celsius:

/*
Author: Danny van den Brande, Arduinosensors.nl. BlueCore Tech.
This code is written for the Thermistor, i attached a LCD1602A to
display the temperature, you can change Celsius to fahrenheit below in the code.
just uncomment line 73. you can use I2C or normal wiring.
 */
// 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    

//#include <LiquidCrystal.h> //uncomment when not using I2C
#include <LiquidCrystal_I2C.h>//uncomment when using a I2C

//LiquidCrystal lcd(12, 11, 5, 4, 3, 2); //Uncomment when not using a I2C
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);// Uncomment when using a I2C
//make sure you set the right adress. here are the most common ones.
//PCF8574 = 0x20, PCF8574A = 0x38, PCF8574AT = 0x3F.
 
int samples[NUMSAMPLES];
 
void setup(void) {
  Serial.begin(9600);
  analogReference(EXTERNAL);
  lcd.begin(16,2); 
  lcd.setCursor(2,0);  
  lcd.print("Thermistor");
  lcd.setCursor(1,1);
  lcd.print("BlueCore Tech");
  delay(3000);
  lcd.clear();
}
 
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 Celsius
//  steinhart = (steinhart * 9.0)/ 5.0 + 32.0;  // Uncomment if you want to use fahrenheit

  lcd.setCursor(2,0);
  lcd.print("Temperature "); 
//  Serial.print("Temperature "); 
  lcd.setCursor(3,1);
  lcd.print(steinhart);
//  Serial.print(steinhart);
  lcd.println(" *C              ");//Comment when using fahrenheit
//  lcd.println(" *F            ");//Uncomment when using fahrenheit
//  Serial.println(" *C");
//  Serial.println(" *F");
 
  delay(1000);
}

Code Fahrenheit:

/*
Author: Danny van den Brande, Arduinosensors.nl. BlueCore Tech.
This code is written for the Thermistor, i attached a LCD1602A to
display the temperature, you can change fahrenheit to celsius below in the code.
just comment line 73. you can use I2C or normal wiring.
 */
// 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    

//#include <LiquidCrystal.h> //uncomment when not using I2C
#include <LiquidCrystal_I2C.h>//uncomment when using a I2C

//LiquidCrystal lcd(12, 11, 5, 4, 3, 2); //Uncomment when not using a I2C
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);// Uncomment when using a I2C
//make sure you set the right adress. here are the most common ones.
//PCF8574 = 0x20, PCF8574A = 0x38, PCF8574AT = 0x3F.
 
int samples[NUMSAMPLES];
 
void setup(void) {
  Serial.begin(9600);
  analogReference(EXTERNAL);
  lcd.begin(16,2); 
  lcd.setCursor(2,0);  
  lcd.print("Thermistor");
  lcd.setCursor(1,1);
  lcd.print("BlueCore Tech");
  delay(3000);
  lcd.clear();
}
 
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 Celsius
  steinhart = (steinhart * 9.0)/ 5.0 + 32.0;  // Uncomment if you want to use fahrenheit

  lcd.setCursor(2,0);
  lcd.print("Temperature "); 
//  Serial.print("Temperature "); 
  lcd.setCursor(3,1);
  lcd.print(steinhart);
//  Serial.print(steinhart);
//  lcd.println(" *C              ");//Comment when using fahrenheit
  lcd.println(" *F            ");//Uncomment when using fahrenheit
//  Serial.println(" *C");
//  Serial.println(" *F");
 
  delay(1000);
}

Code i2C Scanner:

#include <Wire.h>

void setup() {
  Serial.begin (115200);

  // Leonardo: wait for serial port to connect
  while (!Serial) 
    {
    }

  Serial.println ();
  Serial.println ("I2C scanner. Scanning ...");
  byte count = 0;
  
  Wire.begin();
  for (byte i = 8; i < 120; i++)
  {
    Wire.beginTransmission (i);
    if (Wire.endTransmission () == 0)
      {
      Serial.print ("Found address: ");
      Serial.print (i, DEC);
      Serial.print (" (0x");
      Serial.print (i, HEX);
      Serial.println (")");
      count++;
      delay (1);  // maybe unneeded?
      } // end of good response
  } // end of for loop
  Serial.println ("Done.");
  Serial.print ("Found ");
  Serial.print (count, DEC);
  Serial.println (" device(s).");
}  // end of setup

void loop() {}

Danny van den Brande

http://www.arduinosensors.nl

Programmer, Game Designer, 3D Designer, Web Designer, Graphic Designer. Jup this website looks crappy.. :) But enjoy the projects! Everything you need is here.

Leave a Reply

Your email address will not be published. Required fields are marked *