PT100 temperature sensore

Hallo everyone, i have this code as to read the temprature with pt100 in arduino.

But i want to connect an LED and a botton as to turn on LED blink unti 250' Celsius and when reached on 250' the LED start blinking for 3 times . each time half second, and after 5 second LED trun completely off.

i request you please help me complete this code.

#include <Wire.h>
#include <LiquidCrystal_I2C.h> // i2c library for lcd
LiquidCrystal_I2C lcd(0x27,16,2); //i2c address 0x27
unsigned long time1 = 0;
const int analogInPin = A0; // signal pin of pt100 connected to pin A0

const int SensorValueLow = 463;
const int SensorValueDiff = 36;
const int TempValueDiff = 42;
const int TempValueLow = 9;

int sensorValue = 0;
double Temp = 0;
#define minTempC 0 // about 109F
#define maxTempC 150 // about 183F
#define startTempC 29 // initial set temperature value
float setTempC;
#define buttonDN 5 // push button pin 1 connect digital pin 4
#define buttonUP 4 // push button pin 2 connect digital pin 5
#define role 8 // relay pin connect digital pin 8
#define coi 3
byte degree[8] = { // this line to display degrees C
0B01110,
0B01010,
0B01110,
0B00000,
0B00000,
0B00000,
0B00000,
0B00000
};

void setup()
{
Serial.begin(9600);
pinMode(buttonDN, INPUT_PULLUP);
pinMode(buttonUP, INPUT_PULLUP);
pinMode(role, OUTPUT);//SIZE ROLAY CHAN
pinMode(coi, OUTPUT);//how much
digitalWrite(coi,HIGH);
setTempC = startTempC;
}

void loop()
{
sensorValue = analogRead(analogInPin);
Temp = sensorValue-SensorValueLow;
Temp = Temp/SensorValueDiff;
Temp = Temp*TempValueDiff;
Temp = Temp+TempValueLow;
Temp = Temp - 32;
setTemperature();
setHeater();
displayLCD();

}

void displayLCD(){
lcd.init();
lcd.backlight();// tarpaulin turns off the LCD screen
lcd.clear();
lcd.home ();
Serial.print("C = ");
Serial.println(Temp);

lcd.setCursor(0,0);
lcd.print("Temp: ");
lcd.setCursor(10,0);
lcd.print(Temp);
lcd.print("");
lcd.write(1);
lcd.print("C");

lcd.setCursor(0,1);
lcd.print("bis : ");
lcd.setCursor(5,1);
lcd.print(round(setTempC));
lcd.print("");
lcd.write(1);
lcd.print("C");
lcd.createChar(1, degree);

}

void setTemperature()
{
if (digitalRead(buttonDN)==HIGH){ // Where the push button is pressed
setTempC++; // increase the setting value by 1 unit
if(setTempC < minTempC) setTempC = minTempC;

}
if (digitalRead(buttonUP)==HIGH){
                    setTempC--;//  decrease the setting value by 1 unit
  if(setTempC > maxTempC) setTempC = maxTempC;

}

}

void setHeater()
{

 if ((setTempC) > (Temp + 0.5 ) ) {
             digitalWrite(role, LOW);
             lcd.setCursor(11,1);
             lcd.print("up"); 
             //delay(10000); 

           }
       else  if ((setTempC) <= (Temp - 0.5)){
             digitalWrite(role, HIGH);
             //digitalWrite(coi, LOW);
             beep();
             lcd.setCursor(11,1);
             lcd.print("Done");
           //  delay(10000);  
                            
   }

}

void beep() { // The buzzer sounds when the set temperature is less than the current temperature

        digitalWrite(coi, LOW);
        delay(800);  
        digitalWrite(coi, HIGH);
        delay(800);    

}

Why? Will you (or something else) be watching intently enough to notice the final three blinks?

void setTemperature()
{
    if (digitalRead(buttonDN)==HIGH){ // Where the push button is pressed
        setTempC++; // increase the setting value by 1 unit
        if(setTempC < minTempC) setTempC = minTempC;
    }
    if (digitalRead(buttonUP)==HIGH){
        setTempC--;//  decrease the setting value by 1 unit
        if(setTempC > maxTempC) setTempC = maxTempC;
    }
}

the above looks problematic because it recognizes when a button is being pressed and not the event of it be pressed. it will inc/decrement setTempC multiple times as long as the button is pressed. the code needs to recognize the change in state and when it goes from not pressed to pressed

where in the code do you want this to happen? and do you really mean 250 deg C?

i'm curious, what is this calculation doing? does Temp represent the temperature in deg C?

You are reading the PT100 sensor from the analog input, correct?
Can you tell us how the sensor is connected? i.e. through a resistor to +V, or with an amplifier or ???

its connected over a resistor. and yes i need 250 degrees celsius. the connections and wiring is save and works until 300 celsius

i found it in this way. but if you have a better suggestion please give me.

the bottons i donnt need. it was just to check if I can manually change the settings . but everytime changing the settings is not necessary . i will delete the degrees buttons. i need only a start botton, just to click on botton and arduino turn the LED on and wait until temperature is 250 celsius and then 3 times blink. and LED turn off . until I click back again on botton

Are you aware the PT100 changes only 0.362 ohms / °C? Will you be able to get the resolution you require using the PT100 and a resistor into an analog input?

thanks for your suggestion Mr. John.,
i change the resistor and use a lower power resistor.

the problem is i cant find the mathematic calculation to add in arduino and calculate the signal from pt100 in arduino .

i need to know how to calculate the signal of pt100 from voltage to temperature in arduino.

i have this code also. but it calculate signal of a Thermistor. and i wanna replace it to pt100

can you please help me to calculate it ?

#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
int ThermistorPin = A0;
int Vo;
float R1 = 100000;
float logR2, R2, T;
float c1 = 1.009249522e-03, c2 = 2.378405444e-04, c3 = 2.019202697e-07;
const int relay = 10;
const int button = 8;
int state = 0;
void setup()
{
pinMode(button, INPUT);
pinMode(relay, OUTPUT);
digitalWrite(relay, LOW);
Serial.begin(9600);
}
void loop(){
Vo = analogRead(ThermistorPin);
R2 = R1 * (1023.0 / (float)Vo - 1.0);
logR2 = log(R2);
T = (1.0 / (c1 + c2logR2 + c3logR2logR2logR2));
T = T - 273.15;
lcd.print("Temp:");
lcd.setCursor(6, 1);
lcd.print(T); // print tempereature on LCD
lcd.setCursor(0, 1);
delay(100);
state=digitalRead(button);
if (state==1 && T < 28)
{digitalWrite (relay, HIGH);}

else
{
digitalWrite(relay, LOW);
}
Serial.print("Temperature: ");
Serial.print(T);
Serial.println("c");
delay(50);
}

Hi,

You should use one of these amplifier boards. It amplifies the small PT100 changes in resistance so it can be read by a Arduino.

And you can use this library to read the MAX31865

thnkyou so much

@ahmad007 as a "thank you you should learn how to post code as a code-section
and then you should
re-edit your postings with code

best regards Stefan

Hi John

I need help

How can I help ?

Kindly visit

And tell what you think

After connecting and uploading library codes as adviced by adafruit pdf.

The rtd reading in the room was -242°C

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.