Temperature sensors error compiling on Uno but works on Mega?

I've been messing around trying to teach myself coding over the past few weeks and i'm starting to get the hang of it. I wrote some code a few weeks ago for a 2 way differential temperature controller to control the heating of 2 heat stores from a single solar panel and control 8 relays I built it up and tested it on an Arduino Mega.I left if running for a few days on my desk to check at all operated OK. I then realised I only needed a 4 relay module and an Uno so I ordered the Uno and 4 relay modules and started on my next project an irrigation timer. I've now used the Mega and 8 way relay board on that and it's fitted into a box and up and running watering the garden nicely. I've now gone back to my temperature controller and connected everything up and checked the code as the relay digital pins are different on the UNO than the Mega. When I compile it I get 2 new error messages on the lines

struct ts t;
DS3231_init(DS3231_INTCN);

if i remove them it complies but the temperature sensors all read -127 ??

Have I missed something out going from a Mega to an Uno? surely the code should work the same as long as you alter the pins to match the wiring on the Uno?

#include <OneWire.h>
#include <DallasTemperature.h>
#define ONE_WIRE_BUS 2 // Data wire for temp sensors is plugged into digital pin 2 on the Arduino
#include <LiquidCrystal.h>
#include <DS3231.h>
#include <Wire.h>

// struct ts t;  Romoved to make it run in UNO

// 4 Relay Module configured for Opto-isolation
// Arduino Uno pins 3 to 5 connected to IN1 to IN3
// Arduino Uno 5v+ to VCC on relay board
// Arduino Uno GND to GND on relay board
// GRD and JD VCC conected to seperate 5v+ supply
  

//LCD pin to Arduino
const int pin_RS = 8; 
const int pin_EN = 9; 
const int pin_d4 = 4; 
const int pin_d5 = 5; 
const int pin_d6 = 6; 
const int pin_d7 = 7; 
const int pin_BL = 10; 

LiquidCrystal lcd( pin_RS,  pin_EN,  pin_d4,  pin_d5,  pin_d6,  pin_d7);

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

DallasTemperature sensors(&oneWire); // Pass oneWire reference to DallasTemperature library

int keypress = 0;
int deviceCount = 0;
int temptank = 0;
int temppool = 0;
int tempsolar = 0;
int tanksetpoint = 35;
int poolsetpoint = 25;
int tankdiff = 10;
int pooldiff = 10;

void setup() {
  Wire.begin();
//  DS3231_init(DS3231_INTCN); Removed to make it work on UNO
 
  sensors.begin();// Start up the library
  lcd.begin(16, 2);
  lcd.clear();
  pinMode(2, OUTPUT);
  analogWrite(2, 0);
  Serial.begin(9600);
  
  Serial.print("Locating devices on Bus 2...");// locate devices on the bus
  Serial.print("Found ");
  deviceCount = sensors.getDeviceCount();
  Serial.print(deviceCount, DEC);
  Serial.println(" devices.");
  Serial.println("");

for (int i = 2; i <= 4; i++) {
    pinMode(i, INPUT_PULLUP);
    pinMode(i, OUTPUT); // defaults HIGH (relays off)
  }
 
}
void loop() {
  sensors.setResolution(9);
  sensors.requestTemperatures();// Send command to all the sensors for temperature conversion
  
 // for (int i = 0;  i < deviceCount;  i++)  // Display temperature from each sensor
 // {
 //   Serial.print("Sensor ");
 //   Serial.print(i+1);
 //   Serial.print(" : ");
//    tempC = sensors.getTempCByIndex(i);
// Serial.print(tempC);
 //   Serial.write(0xC2);//shows degrees character
  //  Serial.write(0xB0);//shows degrees character
  //  Serial.print("C  |  ");
  //  Serial.print(DallasTemperature::toFahrenheit(tempC));
  //  Serial.write(0xC2);//shows degrees character
  //  Serial.write(0xB0);//shows degrees character
  //  Serial.println("F");
 // }


  //for (int i = 46; i <= 53; i++) {
  //  digitalWrite(i, LOW); // energize relays until all on
  //  delay(100);
  //}
  //for (int i = 46; i <= 53; i++) {
  //  digitalWrite(i, HIGH); // de-energize relays until all off
  //  delay(100);
  //}

int keypress = 0;
keypress = analogRead (0);

if (temptank < tanksetpoint) {
  digitalWrite(4,HIGH); //de-energizes 3 port valve when tank is below setpoint
  digitalWrite(5,HIGH); // turns pool pump off when 3 port valve de-energises
  if (tempsolar-temptank > tankdiff) {
    digitalWrite(3,LOW); //turns solar pump on if solar temp is more than 10C higher than tank temp
  }
  if (tempsolar-temptank < tankdiff) {
    digitalWrite(3,HIGH); //turns solar pump off if solar temp is less than 10C higher than tank temp
  }
}
if (temptank > tanksetpoint && temppool < poolsetpoint) {
  digitalWrite(4,LOW); //energizes 3 port valve when tank reaches setpoint and pool is still below setpoint
  if (tempsolar-temppool > pooldiff) {
    digitalWrite(5,LOW); //turns pool pump on if solar temp is more than 10C higher than pool temp
    digitalWrite(3,LOW); //also turns solar pump on
  }
  if (tempsolar-temppool < pooldiff) {
    digitalWrite(5,HIGH); //turns solar pump off if solar temp is less than 10C higher than pool temp
    digitalWrite(3,HIGH); // also turns solar pump off
  }
}
if (temppool > poolsetpoint) {
  digitalWrite(4,HIGH); //de-energizes 3 port valve when pool is above setpoint
  digitalWrite(5,HIGH); // turns pool pump off when 3 port valve de-energises
  if (tempsolar-temptank > tankdiff) {
    digitalWrite(3,LOW); //turns solar pump on if solar temp is more than 10C higher than tank temp
  }
  if (tempsolar-temptank < tankdiff) {
    digitalWrite(3,HIGH); //turns solar pump off if solar temp is less than 10C higher than tank temp
  }
}

if (temptank > 75){
  digitalWrite(3,LOW); //energizes 3 port valve and turns pool pump on in case tank over heats above 75
  digitalWrite(2,LOW); //also turns solar pump on
}



if (keypress >61 && keypress < 200) {
  tanksetpoint = tanksetpoint +1;
}
if (keypress >201 && keypress < 400) {
  tanksetpoint = tanksetpoint -1;
}
if (keypress >401 && keypress < 600){
  poolsetpoint = poolsetpoint -1;
}
if (keypress <60) {
  poolsetpoint = poolsetpoint +1;
}
if (keypress >601 && keypress < 800) {
  digitalWrite(2, LOW);
}
  
  //Serial.println("");
  delay(10);
  
  temppool = sensors.getTempCByIndex(0);
  tempsolar = sensors.getTempCByIndex(1);
  temptank = sensors.getTempCByIndex(2);
  
  delay(100);

  Serial.print ("Tank ");
  Serial.print(temptank);
  Serial.print ("   Pool ");
  Serial.print(temppool);
  Serial.print ("   Solar ");
  Serial.print(tempsolar);
  Serial.println ("");
  
  lcd.setCursor(0,0);
  lcd.print("T:");
  lcd.print(temptank);
  lcd.print(" P:");
  lcd.print(temppool);
  lcd.print(" S:");
  lcd.print(tempsolar);
  lcd.print("  ");
  lcd.setCursor(0,1);
  lcd.print("Tank ");
  lcd.print(tanksetpoint);
  lcd.print(" Pool ");
  lcd.print(poolsetpoint);

}

I know it's not the best bit of code but i'm new to this and still learning by following YouTube videos and online guides. Any ideas whats going on?

The compiler does not know or care about what is connected. It only looks at the source code to see if it follows the rules for the language.

So, start with the code that compiles correctly. Then try the code that produces errors. What has changed and what do the errors mean.

If you want help here you will need to give the exact code you compiled and the exact error messages given.

Once the code compiles cleanly you then need to figure out what it actually does. Putting lots of print statements in your code usually helps to figure out what is happening.

#define ONE_WIRE_BUS 2

Whats this?

pinMode(2, OUTPUT);
  analogWrite(2, 0);

And this?

for (int i = 2; i <= 4; i++) {
    pinMode(i, INPUT_PULLUP);
    pinMode(i, OUTPUT); // defaults HIGH (relays off)
  }

And this?

digitalWrite(2,LOW); //also turns solar pump on

My problem is the code complied fine a couple of weeks ago and I uploaded it to a Mega and it runs perfectly. I've now opened up the saved file and changed the board to an UNO in the settings and when i compile it gets errors. If i remove the lines with errors it will run on the UNO but i get -127 for the temperature readings.

You must have changed some part of the code since that code does not compile for the Uno or the Mega as-is.

Did you remove a library that previously had defined 'struct ts'?