flashing/cycling letters

hi all
Newbe here
help please

i have compiled a code and it seams to work but the bottom two rows first two letters flash 0-0 on an ongoing event.
im using a 20x4 lcd the new i2c link the lcd, and wanting a couple of temperature readings to cycle every couple of seconds via Dallas temp probes
i will attach code
all help appreciated

cheers caveman

#include <OneWire.h> //This temperature sensor requires a 4.7k Ohm resistor across its pins 2 and three!!!!
#include <DallasTemperature.h>
#include <Wire.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h> // F Malpartida's NewLiquidCrystal library

#define I2C_ADDR 0x27 // Define I2C Address where the PCF8574A is
#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

int n = 1;

LiquidCrystal_I2C lcd(I2C_ADDR,En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin);

#define LED_OFF 0
#define LED_ON 1

int sensorPin = A0; // select the input pin for the 10K potentiometer
int sensorValue = 0; // variable to store the value coming from the sensor
int setTemp = 0; // variable to store temp desired
int SSRCPin = 5; //Turn on A/C unit
int SSRHPin = 6; //Turn on heat (electric or gas)
int hcLED = 4; //indicator for Cooling mode
int SwitchPin = 1; // To switch between Cooling and Heating
int SSRFan = 7; // To turn on and off the air handler fan
char* heat;
float currentTemp = 0;

//This temperature sensor requires a 4.7k Ohm resistor across its pins 2 and three!!!! Thats the middle pin and the GND pin
// Data wire is plugged into pin 2 on the Arduino
#define ONE_WIRE_BUS 2

// Setup a oneWire instance to communicate with any OneWire devices
OneWire oneWire(ONE_WIRE_BUS);

// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);

DeviceAddress boilertopThermometer = {
0x28, 0xFF, 0xD4, 0x57, 0x33, 0x04, 0x00, 0x56 };
DeviceAddress boilerbottomThermometer = {
0x28, 0xFF, 0xD8, 0x4C, 0x31, 0x04, 0x00, 0x94 };
DeviceAddress spareThermometer = {
0x28, 0x90, 0x60, 0x2C, 0x03, 0x00, 0x00, 0x38 };

void setup(void)
{

lcd.begin (20,4);

// Switch on the backlight
lcd.setBacklightPin(BACKLIGHT_PIN,POSITIVE);
lcd.setBacklight(HIGH);
lcd.home (); // go home

// Start up the library
sensors.begin();
// set the resolution to 9 bit (good enough?)
sensors.setResolution(boilertopThermometer, 20);
sensors.setResolution(boilerbottomThermometer, 20);
sensors.setResolution(spareThermometer, 20);

pinMode(SSRFan, OUTPUT); //set airhandler fan pin as output
digitalWrite(SSRFan, LOW);
pinMode(SSRHPin, OUTPUT);
digitalWrite(SSRHPin, LOW);
pinMode(SSRCPin, OUTPUT);
digitalWrite(SSRCPin, LOW);
pinMode(hcLED, OUTPUT);
digitalWrite(hcLED, LOW);
pinMode(SwitchPin, INPUT);
}

void printTemperature(DeviceAddress deviceAddress)
{

sensors.requestTemperatures(); // was in loop

float tempC = sensors.getTempC(deviceAddress);
if (tempC == -127.00) {
lcd.print("Error");
} else {
// lcd.print(tempC);
// lcd.print("/");
currentTemp = (DallasTemperature::toFahrenheit(tempC));
lcd.print(currentTemp);
}

}

void loop(void)
{

lcd.setCursor(0,0);
// 01234567890123456789
lcd.print("Boiler Top:");
//
lcd.setCursor(0,1);
lcd.print("Boiler Mid:");
//
lcd.setCursor(0,2);
lcd.print("Cooling water:");
//
lcd.setCursor(0,3);
lcd.print("Set:");

delay(500);

sensorValue = analogRead(sensorPin);

setTemp = sensorValue / 10.24; //Gives us a set temp range between 0 and 99 degrees

lcd.setCursor(16,0);
printTemperature(boilertopThermometer);
lcd.setCursor(16,1);
printTemperature(boilerbottomThermometer);
lcd.setCursor(16,2);
printTemperature(spareThermometer);
lcd.setCursor(16,3);
lcd.print(setTemp);

//Cooling Mode

int val = digitalRead(SwitchPin) ;// val represents digitalRead(SwitchPin);
// If the value of is 1 then make hcLED low (off) which sets the relay in a normally closed state. Hence, turning on the blue LED.
if (val == 1)
{
digitalWrite(hcLED, LOW);
}

/* If the SwitchPin reads 1 and the current temperature is greater than the set temperature (if its hot) turn on the A/C and internal fan */
if (val == 1 && (currentTemp > setTemp + 3))
{
digitalWrite(SSRFan, HIGH);
digitalWrite(SSRHPin, LOW);
digitalWrite(SSRCPin, HIGH);
}

/* Otherwise, if the SwitchPin reads 1 and the current temperature is less than the set temperature (the set temperature has been reached), turn off the A/C and internal fan */
else if (val == 1 && (currentTemp < setTemp - 3))
{
digitalWrite(SSRCPin, LOW);
digitalWrite(SSRFan, LOW);
}
// Heating Mode

// If the value of is 0 then make hcLED HIGH (on) which sets the relay in a normally open state. Hence, turning on the RED LED
if (val == 0)
{
digitalWrite(hcLED, HIGH);
}

/* If the SwitchPin reads 0 and the current temperature is less than the set temperature (if its cold) turn on the HEAT and internal fan */
if (val == 0 && (currentTemp < setTemp + 3))
{
digitalWrite(SSRFan, HIGH);
digitalWrite(SSRCPin, LOW);
digitalWrite(SSRHPin, HIGH);
}

/* If the SwitchPin reads 0 and the current temperature is greater than the set temperature (the set temperature has been reached) turn off the HEAT and internal fan */
else if (val == 0 && (currentTemp > setTemp - 3))
{
digitalWrite(SSRHPin, LOW);
digitalWrite(SSRFan, LOW);
}

}

OK Without spending too much time reverse engineering your entire sketch. This is the bit that catches my eye.

lcd.setCursor(16,0);
printTemperature(boilertopThermometer);
lcd.setCursor(16,1);
printTemperature(boilerbottomThermometer);
lcd.setCursor(16,2);
printTemperature(spareThermometer);
lcd.setCursor(16,3);
lcd.print(setTemp);

Now I see 2 problems with this.
problem 1
Am I to assume that your display is 16 characters wide? If so, setting your cursor position to the end of the line will make it impossible to print anything else on that line (the next character it attempts to print will go off the side of the screen)
So I'd suggest you change that 16 to something more realistic (perhaps 12)

Problem 2
where you say lcd.print(setTemp); set temp is an integer value. Therefore the print command will attempt to print a character code for whatever it holds. eg, if it holds 48 it will print the character '0' if setTemp holds a very low number it will not print anything at all. The way to get around this is to use lcd.print(setTemp,DEC);

Your other values may have the same issue as problem 2 also I haven't checked their data types.

Thank you very much, i can not believe i did that :roll_eyes: :blush:

to long looking at this and trying to get it to work :relaxed:

any other pointers graciously appreciated :slight_smile:

Cave

setTemp = sensorValue / 10.24; //Gives us a set temp range between 0 and 99 degrees

Think what will happen when setTemp goes from say 10 to 9. You will previously have printed 10, now you are going to print 9 in the same place so what will be on the screen is 90 unless you take steps to remove the 0 by printing a space.

You might also consider printing single digit numbers in the place where the second digit was in the previous 2 digit number as this looks better. To do this you need to proceed single digit numbers with a space.

setTemp = sensorValue / 10.24; //Gives us a set temp range between 0 and 99 degreesmay also not be doing what you want because both setTemp and sensorValue are declared as ints not floats.

have just modified the code to what i think you mean

Attached

please let me know if im correct :slight_smile:

#include <OneWire.h> //This temperature sensor requires a 4.7k Ohm resistor across its pins 2 and three!!!!
#include <DallasTemperature.h>
#include <Wire.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h> // F Malpartida's NewLiquidCrystal library

#define I2C_ADDR 0x27 // Define I2C Address where the PCF8574A is
#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

int n = 1;

LiquidCrystal_I2C lcd(I2C_ADDR,En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin);

#define LED_OFF 0
#define LED_ON 1

int sensorPin = A0; // select the input pin for the 10K potentiometer
int sensorValue = 0; // variable to store the value coming from the sensor
int setTemp = 85; // variable to store temp desired
int SSRwaterpumpPin = 5; //Turn on water pump
int SSRHeaterPin = 6; //Turn on heat (electric or gas)
int hcLED = 4; //indicator for Cooling mode
int SwitchPin = 1; // To switch between Cooling and Heating
int SSRraditatorFan = 7; // To turn on and off the air radiator fan
char* heat;
float currentTemp = 0;

//This temperature sensor requires a 4.7k Ohm resistor across its pins 2 and three!!!! Thats the middle pin and the GND pin
// Data wire is plugged into pin 2 on the Arduino
#define ONE_WIRE_BUS 2

// Setup a oneWire instance to communicate with any OneWire devices
OneWire oneWire(ONE_WIRE_BUS);

// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);

DeviceAddress boilertopThermometer = {
0x28, 0xFF, 0xD4, 0x57, 0x33, 0x04, 0x00, 0x56 };
DeviceAddress boilerbottomThermometer = {
0x28, 0xFF, 0xD8, 0x4C, 0x31, 0x04, 0x00, 0x94 };
DeviceAddress spareThermometer = {
0x28, 0x90, 0x60, 0x2C, 0x03, 0x00, 0x00, 0x38 };

void setup(void)
{

lcd.begin (20,4);

// Switch on the backlight
lcd.setBacklightPin(BACKLIGHT_PIN,POSITIVE);
lcd.setBacklight(HIGH);
lcd.home (); // go home

// Start up the library
sensors.begin();
// set the resolution to 12 bit (good enough?)
sensors.setResolution(boilertopThermometer, 12);
sensors.setResolution(boilerbottomThermometer, 12);
sensors.setResolution(spareThermometer, 12);

pinMode(SSRraditatorFan, OUTPUT); //set airhandler fan pin as output
digitalWrite(SSRraditatorFan, LOW);
pinMode(SSRHeaterPin, OUTPUT);
digitalWrite(SSRHeaterPin, LOW);
pinMode(SSRwaterpumpPin, OUTPUT);
digitalWrite(SSRwaterpumpPin, LOW);
pinMode(hcLED, OUTPUT);
digitalWrite(hcLED, LOW);
pinMode(SwitchPin, INPUT);
}

void printTemperature(DeviceAddress deviceAddress)
{

sensors.requestTemperatures(); // was in loop

float tempC = sensors.getTempC(deviceAddress);
if (tempC == -127.00) {
lcd.print("Error");
}
else {
// lcd.print(tempC);
// lcd.print("/");
currentTemp = (DallasTemperature::toFahrenheit(tempC));
lcd.print(currentTemp);
}

}

void loop(void)
{

delay(500);

sensorValue = analogRead(sensorPin);

setTemp = sensorValue / 10.24; //Gives us a set temp range between 0 and 99 degrees

//
sensors.requestTemperatures();
float boilertopThermometer = sensors.getTempCByIndex(0);
lcd.setCursor(0, 0);
lcd.print("Boiler Top: ");
lcd.print(sensors.getTempCByIndex(0));
lcd.print("C");

float boilerbottomThermometer = sensors.getTempCByIndex(1);
lcd.setCursor(0, 1);
lcd.print("Boiler Mid: ");
lcd.print(sensors.getTempCByIndex(1));
lcd.print("C");
sensorValue = analogRead(sensorPin);

sensors.requestTemperatures();
float spareThermometer = sensors.getTempCByIndex(3);
lcd.setCursor(0, 2);
lcd.print("Cooling water: ");
lcd.print(sensors.getTempCByIndex(0));
lcd.print("C");

float temperature2 = sensors.getTempCByIndex(4);
lcd.setCursor(0, 3);
lcd.print("Set ");
lcd.print(sensors.getTempCByIndex(1));
lcd.print("C");

//Cooling Mode

int val = digitalRead(SwitchPin) ;// val represents digitalRead(SwitchPin);
// If the value of is 1 then make hcLED low (off) which sets the relay in a normally closed state. Hence, turning on the blue LED.
if (val == 1)
{
digitalWrite(hcLED, LOW);
}

/* If the SwitchPin reads 1 and the current temperature is greater than the set temperature (if its hot) turn on the water pump */
if (val == 1 && (currentTemp > setTemp + 3))
{
digitalWrite(SSRraditatorFan, LOW);
digitalWrite(SSRHeaterPin, LOW);
digitalWrite(SSRwaterpumpPin, HIGH);
}

/* Otherwise, if the SwitchPin reads 1 and the current temperature is less than the set temperature (the set temperature has been reached), turn off the A/C and internal fan */
else if (val == 1 && (currentTemp < setTemp - 3))
{
digitalWrite(SSRwaterpumpPin, LOW);
digitalWrite(SSRraditatorFan, LOW);
}
// Heating Mode

// If the value of the SwitchPin is 0 then make hcLED HIGH (on) which sets the relay in a normally open state. Hence, turning on the RED LED
if (val == 0)
{
digitalWrite(hcLED, HIGH);
}

/* If the SwitchPin reads 0 and the current temperature is less than the set temperature (if its cold) turn on the HEAT and internal fan */
if (val == 0 && (currentTemp < setTemp + 3))
{
digitalWrite(SSRraditatorFan, HIGH);
digitalWrite(SSRwaterpumpPin, LOW);
digitalWrite(SSRHeaterPin, HIGH);
}

/* If the SwitchPin reads 0 and the current temperature is greater than the set temperature (the set temperature has been reached) turn off the HEAT and internal fan */
else if (val == 0 && (currentTemp > setTemp - 3))
{
digitalWrite(SSRHeaterPin, LOW);
digitalWrite(SSRraditatorFan, LOW);
}
}

You're still not usng the ,DEC I told you about.

eg

lcd.print(sensors.getTempCByIndex(1));

Should be

lcd.print(sensors.getTempCByIndex(1),DEC);

And BTW. When posting code on the forum, it helps if you insert it between [ c o d e ] and [ / c o d e ] (without the spaces) tags.

oh ok my bad the posting code spaces not sure on this :~

just tried the DEC code and i get 9 dec points after the main figure

What I mean is,
On the form where you compile an answer to the thread, You'll see some buttons above the text area. If you click the one with a # symbol you will then have two tags within your text box. You paste your sketch in between them.

It gives a nice box like this once you've posted it. and also makes it more readable.

ok cheers
did i do good

#include <OneWire.h> //This temperature sensor requires a 4.7k Ohm resistor across its pins 2 and three!!!!
#include <DallasTemperature.h>
#include <Wire.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h>  // F Malpartida's NewLiquidCrystal library

#define I2C_ADDR    0x27  // Define I2C Address where the PCF8574A is
#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

int n = 1;

LiquidCrystal_I2C   lcd(I2C_ADDR,En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin);

#define  LED_OFF  0
#define  LED_ON  1

int sensorPin = A0;    // select the input pin for the 10K potentiometer
int sensorValue = 0;   // variable to store the value coming from the sensor
int setTemp = 0;       // variable to store temp desired
int SSRwaterpumpPin = 5;       //Turn on water pump
int SSRHeaterPin = 6;       //Turn on heat (electric or gas)
int hcLED = 4;         //indicator for Cooling mode
int SwitchPin = 1;     // To switch between Cooling and Heating
int SSRraditatorFan = 7;        // To turn on and off the air radiator fan
char* heat;
float currentTemp = 0;


//This temperature sensor requires a 4.7k Ohm resistor across its pins 2 and three!!!! Thats the middle pin and the GND pin
// Data wire is plugged into pin 2 on the Arduino
#define ONE_WIRE_BUS 2

// Setup a oneWire instance to communicate with any OneWire devices
OneWire oneWire(ONE_WIRE_BUS);

// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);

DeviceAddress boilertopThermometer = {
  0x28, 0xFF, 0xD4, 0x57, 0x33, 0x04, 0x00, 0x56 };
DeviceAddress boilerbottomThermometer = {
  0x28, 0xFF, 0xD8, 0x4C, 0x31, 0x04, 0x00, 0x94 };
DeviceAddress spareThermometer = {
  0x28, 0x90, 0x60, 0x2C, 0x03, 0x00, 0x00, 0x38 };

void setup(void)
{

  lcd.begin (20,4);

  // Switch on the backlight
  lcd.setBacklightPin(BACKLIGHT_PIN,POSITIVE);
  lcd.setBacklight(HIGH);
  lcd.home ();                   // go home

    // Start up the library
  sensors.begin();
  // set the resolution to 12 bit (good enough?)
  sensors.setResolution(boilertopThermometer, 20);
  sensors.setResolution(boilerbottomThermometer, 20);
  sensors.setResolution(spareThermometer, 20);


  pinMode(SSRraditatorFan, OUTPUT); //set raditator fan pin as output
  digitalWrite(SSRraditatorFan, LOW);
  pinMode(SSRHeaterPin, OUTPUT);
  digitalWrite(SSRHeaterPin, LOW);
  pinMode(SSRwaterpumpPin, OUTPUT);
  digitalWrite(SSRwaterpumpPin, LOW);
  pinMode(hcLED, OUTPUT);
  digitalWrite(hcLED, LOW);
  pinMode(SwitchPin, INPUT);
}

void printTemperature(DeviceAddress deviceAddress)
{

  sensors.requestTemperatures();  // was in loop

  float tempC = sensors.getTempC(deviceAddress);
  if (tempC == -127.00) {
    lcd.print("Error");
  }
  else {
    // lcd.print(tempC);
    // lcd.print("/");
    currentTemp = (DallasTemperature::toFahrenheit(tempC));
    lcd.print(currentTemp);
  }

}

void loop(void)
{
 
 
  delay(500);

  sensorValue = analogRead(sensorPin); 
 
  setTemp = sensorValue / 10.24; //Gives us a set temp range between 10 and 99 degrees

  //
  sensors.requestTemperatures();
  float boilertopThermometer = sensors.getTempCByIndex(0);
  lcd.setCursor(0, 0);
  lcd.print("Boiler Top:    ");
  lcd.print(sensors.getTempCByIndex(0));
  lcd.print("C");
 
  float boilerbottomThermometer = sensors.getTempCByIndex(1);
  lcd.setCursor(0, 1);
  lcd.print("Boiler Mid:    ");
  lcd.print(sensors.getTempCByIndex(1));
  lcd.print("C");
  sensorValue = analogRead(sensorPin); 
 
  sensors.requestTemperatures();
  float spareThermometer = sensors.getTempCByIndex(2);
  lcd.setCursor(0, 2);
  lcd.print("Cooling water: ");
  lcd.print(sensors.getTempCByIndex(2));
  lcd.print("C");
 
 lcd.setCursor(0,3);
 lcd.print("Set:");
 lcd.setCursor(16,3);
 lcd.print(setTemp,DEC);
 lcd.print("C");

  //Cooling Mode


  int val = digitalRead(SwitchPin) ;// val represents digitalRead(SwitchPin);
  // If the value of  is 1 then make hcLED low (off) which sets the relay in a normally closed state. Hence, turning on the blue LED.
  if (val == 1)
  {
    digitalWrite(hcLED, LOW);
  }

  /* If the SwitchPin reads 1 and the current temperature is greater than the set temperature (if its hot) turn on the water pump */
  if (val == 1 && (currentTemp > setTemp + 3))
  {
    digitalWrite(SSRraditatorFan, LOW);
    digitalWrite(SSRHeaterPin, LOW);
    digitalWrite(SSRwaterpumpPin, HIGH);
  }

  /* Otherwise, if the SwitchPin reads 1 and the current temperature is less than the set temperature (the set temperature has been reached), turn off the A/C and internal fan */
  else if (val == 1 && (currentTemp < setTemp - 3))
  {
    digitalWrite(SSRwaterpumpPin, LOW);
    digitalWrite(SSRraditatorFan, LOW);
  }
  // Heating Mode
 

  // If the value of the SwitchPin is 0 then make hcLED HIGH (on) which sets the relay in a normally open state. Hence, turning on the RED LED
  if (val == 0)
  {
    digitalWrite(hcLED, HIGH);
  }

  /* If the SwitchPin reads 0 and the current temperature is less than the set temperature (if its cold) turn on the HEAT and internal fan */
  if (val == 0 && (currentTemp < setTemp + 3))
  {
    digitalWrite(SSRraditatorFan, HIGH);
    digitalWrite(SSRwaterpumpPin, LOW); 
    digitalWrite(SSRHeaterPin, HIGH);
  }

  /* If the SwitchPin reads 0 and the current temperature is greater than the set temperature (the set temperature has been reached) turn off the HEAT and internal fan */
  else if (val == 0 && (currentTemp > setTemp - 3))
  {
    digitalWrite(SSRHeaterPin, LOW);
    digitalWrite(SSRraditatorFan, LOW);
}
}

You did good :slight_smile:
Now you just need to change lines that look like this

lcd.print(currentTemp);

So they look like this

 lcd.print(currentTemp,DEC);

hope i'm on the correct track

#include <OneWire.h> //This temperature sensor requires a 4.7k Ohm resistor across its pins 2 and three!!!!
#include <DallasTemperature.h>
#include <Wire.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h>  // F Malpartida's NewLiquidCrystal library

#define I2C_ADDR    0x27  // Define I2C Address where the PCF8574A is
#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

int n = 1;

LiquidCrystal_I2C   lcd(I2C_ADDR,En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin);

#define  LED_OFF  0
#define  LED_ON  1

int sensorPin = A0;    // select the input pin for the 10K potentiometer
int sensorValue = 0;   // variable to store the value coming from the sensor
int setTemp = 0;       // variable to store temp desired
int SSRwaterpumpPin = 5;       //Turn on water pump
int SSRHeaterPin = 6;       //Turn on heat (electric or gas)
int hcLED = 4;         //indicator for Cooling mode
int SwitchPin = 1;     // To switch between Cooling and Heating
int SSRraditatorFan = 7;        // To turn on and off the air radiator fan
char* heat;
float currentTemp = 0;


//This temperature sensor requires a 4.7k Ohm resistor across its pins 2 and three!!!! Thats the middle pin and the GND pin
// Data wire is plugged into pin 2 on the Arduino
#define ONE_WIRE_BUS 2

// Setup a oneWire instance to communicate with any OneWire devices
OneWire oneWire(ONE_WIRE_BUS);

// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);

DeviceAddress boilermid = {
  0x28, 0xFF, 0xD4, 0x57, 0x33, 0x04, 0x00, 0x56 };
DeviceAddress boilerbottom = {
  0x28, 0xFF, 0xD8, 0x4C, 0x31, 0x04, 0x00, 0x94 };
DeviceAddress cooling = {
  0x28, 0x90, 0x60, 0x2C, 0x03, 0x00, 0x00, 0x38 };

void setup(void)
{

  lcd.begin (20,4);

  // Switch on the backlight
  lcd.setBacklightPin(BACKLIGHT_PIN,POSITIVE);
  lcd.setBacklight(HIGH);
  lcd.home ();                   // go home

    // Start up the library
  sensors.begin();
  // set the resolution to 12 bit (good enough?)
  sensors.setResolution(boilermid, 20);
  sensors.setResolution(boilerbottom, 20);
  sensors.setResolution(cooling, 20);


  pinMode(SSRraditatorFan, OUTPUT); //set raditator fan pin as output
  digitalWrite(SSRraditatorFan, LOW);
  pinMode(SSRHeaterPin, OUTPUT);
  digitalWrite(SSRHeaterPin, LOW);
  pinMode(SSRwaterpumpPin, OUTPUT);
  digitalWrite(SSRwaterpumpPin, LOW);
  pinMode(hcLED, OUTPUT);
  digitalWrite(hcLED, LOW);
  pinMode(SwitchPin, INPUT);
}

void printTemperature(DeviceAddress deviceAddress)
{

  sensors.requestTemperatures();  // was in loop

  float tempC = sensors.getTempC(deviceAddress);
  if (tempC == -127.00) {
    lcd.print("Error");
  }
  else {
    // lcd.print(tempC);
    // lcd.print("/");
    currentTemp = (DallasTemperature::toFahrenheit(tempC));
    lcd.print(currentTemp,DEC);
  }

}

void loop(void)
{
 
 
  delay(500);

  sensorValue = analogRead(sensorPin); 
 
  setTemp = sensorValue / 10.24; //Gives us a set temp range between 10 and 99 degrees

  //
  sensors.requestTemperatures();
  float boilermid = sensors.getTempCByIndex(0);
  lcd.setCursor(0, 0);
  lcd.print("Boiler Mid:    ");
  lcd.print(sensors.getTempCByIndex(0));
  lcd.print("C");
 
  float boilerbottom = sensors.getTempCByIndex(1);
  lcd.setCursor(0, 1);
  lcd.print("Boiler Bottom: ");
  lcd.print(sensors.getTempCByIndex(1));
  lcd.print("C"); 
 
  float cooling = sensors.getTempCByIndex(2);
  lcd.setCursor(0, 2);
  lcd.print("Cooling water: ");
  lcd.print(sensors.getTempCByIndex(2));
  lcd.print("C");
 
 lcd.setCursor(0,3);
 lcd.print("Set:");
 lcd.setCursor(17,3);
 lcd.print(setTemp,DEC);
 lcd.print("C");

  //Cooling Mode


  int val = digitalRead(SwitchPin) ;// val represents digitalRead(SwitchPin);
  // If the value of  is 1 then make hcLED low (off) which sets the relay in a normally closed state. Hence, turning on the blue LED.
  if (val == 1)
  {
    digitalWrite(hcLED, LOW);
  }

  /* If the SwitchPin reads 1 and the current temperature is greater than the set temperature (if its hot) turn on the water pump */
  if (val == 1 && (boilermid > setTemp))
  {
    digitalWrite(SSRraditatorFan, LOW);
    digitalWrite(SSRHeaterPin, LOW);
    digitalWrite(SSRwaterpumpPin, HIGH);
  }
  
/* If the SwitchPin reads 1 and the current temperature is greater than the set temperature (if its hot) turn on the water pump */
  if (val == 1 && (boilermid > setTemp))
  {
    digitalWrite(SSRraditatorFan, LOW);
    digitalWrite(SSRHeaterPin, LOW);
    digitalWrite(SSRwaterpumpPin, HIGH);
  }
  /* Otherwise, if the SwitchPin reads 1 and the current temperature is less than the set temperature (the set temperature has been reached), turn off the A/C and internal fan */
  else if (val == 1 && (currentTemp < setTemp - 3))
  {
    digitalWrite(SSRwaterpumpPin, LOW);
    digitalWrite(SSRraditatorFan, LOW);
  }
  // Heating Mode
 

  // If the value of the SwitchPin is 0 then make hcLED HIGH (on) which sets the relay in a normally open state. Hence, turning on the RED LED
  if (val == 0)
  {
    digitalWrite(hcLED, HIGH);
  }

  /* If the SwitchPin reads 0 and the current temperature is less than the set temperature (if its cold) turn on the HEAT and internal fan */
  if (val == 0 && (currentTemp < setTemp + 3))
  {
    digitalWrite(SSRraditatorFan, HIGH);
    digitalWrite(SSRwaterpumpPin, LOW); 
    digitalWrite(SSRHeaterPin, HIGH);
  }

  /* If the SwitchPin reads 0 and the current temperature is greater than the set temperature (the set temperature has been reached) turn off the HEAT and internal fan */
  else if (val == 0 && (currentTemp > setTemp - 3))
  {
    digitalWrite(SSRHeaterPin, LOW);
    digitalWrite(SSRraditatorFan, LOW);
}
}
  lcd.setCursor(17,3);
  lcd.print(setTemp,DEC);
  lcd.print("C");

When setTemp is 10 this will print 10C at column 17
When setTemp is 9 this will print 9C at column 17 but the C previously printed will still be there so what you will see is 9CC

What you need is something like

  lcd.setCursor(17,3);
  if (setTemp <= 9)
    {  
      lcd.Print(" ");
    }
  lcd.print(setTemp,DEC);
  lcd.print("C");

thank you greatly appreciated :slight_smile: