Sorry, I had the code on the other workstation and couldn’t get to it till now…
#include <Wire.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h>
#include <OneWire.h>
#include <DallasTemperature.h>
#define I2C_ADDR 0x27 // <<----- Add your address here. Find it from I2C Scanner
#define BACKLIGHT_PIN 3
#define En_pin 2
#define Rw_pin 1
#define Rs_pin 0
#define D4_pin 4
#define D5_pin 5
#define D6_pin 6
#define D7_pin 7
#define ONE_WIRE_BUS 2
const float UPPER_LIMIT = 30.0;
const float LOWER_LIMIT = 29.0;
const char DEGREES_CHAR = (char)223;
int sensorValue1 = 0;
int sensorValue2 = 0;
int temperature1=0;
float f1 = 0;
float t1 = 0;
int temperature2=0;
float f2 = 0;
float t2 = 0;
bool isSwitchedOn = true;
int stateVar = 0;
int numOfReadings = 10;
int screenRefreshTime = 1;
LiquidCrystal_I2C lcd(I2C_ADDR,En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin);
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
sensors.begin();
lcd.begin(16,2);
pinMode(RELAY, OUTPUT);
// Switch on the backlight
lcd.setBacklightPin(BACKLIGHT_PIN,POSITIVE);
lcd.setBacklight(HIGH);
lcd.home ();
}
void loop() {
//sensors.requestTemperatures();
int sensorValue1 = analogRead(A0);
temperature1=map(sensorValue1,205,1023,-5000,15000);
f1 = temperature1;
t1 += f1/100.0;
//t1 = sensors.getTempCByIndex(0);
//controlRelayByTemperature(t1);
int sensorValue2 = analogRead(A1);
temperature2=map(sensorValue2,205,1023,-5000,15000);
f2 = temperature2;
t2 += f2/100.0;
//t2 = sensors.getTempCByIndex(1);
if(stateVar == (numOfReadings - 1)){
t1 /= numOfReadings;
t2 /= numOfReadings;
printTemperature(1, t1);
printTemperature(2, t2);
t1 = 0;
t2 = 0;
}
delay(( screenRefreshTime * 1000) / numOfReadings);
stateVar++;
stateVar %= numOfReadings;
}
void printTemperature(int sensorNumber, float tempera){
lcd.setCursor (0,sensorNumber-1);
lcd.print("Sonda ");
lcd.print(sensorNumber);
lcd.print(": ");
lcd.print(tempera,2);
lcd.print(DEGREES_CHAR);
lcd.print("C ");
}
void controlRelayByTemperature(float tempera){
if(!isSwitchedOn){
if(tempera > UPPER_LIMIT){
digitalWrite(RELAY, 0);
isSwitchedOn = true;
}
}
if(isSwitchedOn){
if(tempera < LOWER_LIMIT){
digitalWrite(RELAY, 1);
isSwitchedOn = false;
}
}
}
Code is kinda patched up with bunch of useless stuff I did while testing, but I think you’ll get the idea.
I’m using -50 to 150 degrees 4-20mA transmitter, similar to the one in the picture.

I’m using an RTD because I need to fit them into pipes and quite frankly I had them laying around. Also, I have a few of the DS18B20 sensors but they’re not waterproof and I managed to destroyed one while testing too hot of a measurement, I guess the 125°C top temperature is too close to needed…