LCDshowNum error

Hi

I am trying to make temperature sensors with Max and Min as well at Current in Celcius to display on LCD's using one arduino.
I can get it so that I can have 2 LCD's display with one probe hooked up, the 1st LCD displays all the data from the probe, I modified the code to suite more than one probe and display the infor or each on its own LCD.

I am using 2 x I2C LCD and 2 DS18B20 probes.

I am getting this message: 'LCDshowNum' was not declared in this scope

Any help is much appreciated I have tried everything I can think of.

#include <Wire.h>
#include <LiquidCrystal_I2C.h>

#include <OneWire.h>
#include <DallasTemperature.h>

/*Define for DS18S20 data pins
*  This data pins is to connect 4.7K Om resister and to 5V
*/
#define ONE_WIRE_BUS D4 

//Define for LCD display pins
#define SCL_CLOCK_PIN D1
#define SDA_DATA_PIN D2

//Initialize OneWire library for temperature sensor
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);

// set the LCD address
LiquidCrystal_I2C lcd1(0x27,16,2);  
LiquidCrystal_I2C lcd2(0x3F,16,2); 


float HighestTemp1 = 0.0;
float CurrentTemp1 = 0.0;
float LowestTemp1 = 0.0;
float HighestTemp2 = 0.0;
float CurrentTemp2 = 0.0;
float LowestTemp2 = 0.0;

// Set probe address
DeviceAddress Probe01 = { 0x28, 0xFF, 0x27, 0xC9, 0xC1, 0x17, 0x04, 0x50 };
DeviceAddress Probe02 = { 0x28, 0xFF, 0x41, 0x00, 0xC2, 0x17, 0x04, 0x93 };

void setup()
{
  // start temperature sensor
  sensors.begin();
  sensors.requestTemperatures(); //get temperature
  
  // Start the LCD
    lcd1.init();
  lcd2.init();
  //lcd display screen backlight
  lcd1.backlight();  
  lcd2.backlight(); 
  //clear lcd display
  lcd1.clear(); 
  lcd1.home(); 
  lcd2.clear();
  lcd2.home();
  
  //Set lowest, highest temperatues 
  CurrentTemp1  = sensors.getTempCByIndex(0);
  HighestTemp1 = CurrentTemp1;
  LowestTemp1 = CurrentTemp1;
  CurrentTemp2  = sensors.getTempCByIndex(0);
  HighestTemp2 = CurrentTemp2;
  LowestTemp2 = CurrentTemp2;

// LCD display information
  lcd1.setCursor(0,0);
  lcd1.print(F("Current: "));
  LCDshowNum(9,0,CurrentTemp1);  

  lcd1.setCursor(0,1);
  lcd1.print(F("Ma: "));
  LCDshowNum(3,1,HighestTemp1);    
     
  lcd1.setCursor(9,1);
  lcd1.print(F("Mi: "));
  LCDshowNum(12,1,LowestTemp1);
       
  lcd2.setCursor(0,0);
  lcd2.print(F("Current: "));
  LCDshowNum(9,0,CurrentTemp2);  

  lcd2.setCursor(0,1);
  lcd2.print(F("Ma: "));
  LCDshowNum(3,1,HighestTemp2);    
     
  lcd2.setCursor(9,1);
  lcd2.print(F("Mi: "));
  LCDshowNum(12,1,LowestTemp2); 
}


void loop()
{ 
  sensors.requestTemperatures(); //get temperature

  //Get Current
  CurrentTemp1 = sensors.getTempCByIndex(0);
  LCDshowNum(9,0,CurrentTemp1);    
  CurrentTemp2 = sensors.getTempCByIndex(0);
  LCD2showNum(9,0,CurrentTemp1);   
  
  //Check if Hightest
  if(CurrentTemp1 > HighestTemp1){
     HighestTemp1 = CurrentTemp1;
     LCDshowNum(3,1,HighestTemp1); 
  if(CurrentTemp2 > HighestTemp2){
     HighestTemp2 = CurrentTemp2;
     LCDshowNum(3,1,HighestTemp2); 
     
  //Chekc if Lowest
  if(CurrentTemp1 < LowestTemp1){
    LowestTemp1 = CurrentTemp1;
    LCDshowNum(12,1,LowestTemp1);
 if(CurrentTemp2 < LowestTemp2){
    LowestTemp2 = CurrentTemp2;
    LCDshowNum(12,1,LowestTemp2);
  }

  delay(1);
}

/*
* LCDshowNum
* LCD display location: x, y
* Float n: temperature to display
*/
void LCDshowNum(int x, int y, float n){
  lcd1.setCursor(x,y);
  lcd1.print(n);
  lcd2.setCursor(x,y);
  lcd2.print(n);
}

If you Auto Format your code then all functions should start on the left margin.

Your LCDshowNum() function doesn't

It looks like you are missing some closing braces in the code.

A suggestion for you. Always put each opening and closing brace on its own line with nothing else. That way the code blocks stand out much better.

I found that the brackets were a bit haywire and that fixed the problem ha ha thank you.

Now it works but both LCD's are displaying the same probe any ideas where I went wrong?

Please post the code as it is now

 CurrentTemp1 = sensors.getTempCByIndex(0);
  LCDshowNum(9, 0, CurrentTemp1);
  CurrentTemp2 = sensors.getTempCByIndex(0);
  LCD2showNum(9, 0, CurrentTemp1);

This looks like you are reading the same sensor twice then compounding the error by displaying the same variable on each LCD

Copy/Paste/forget to change details maybe ?

#include <Wire.h>
#include <LiquidCrystal_I2C.h>

#include <OneWire.h>
#include <DallasTemperature.h>

/*Define for DS18S20 data pins
*  This data pins is to connect 4.7K Om resister and to 5V
*/
#define ONE_WIRE_BUS D4 

//Define for LCD display pins
#define SCL_CLOCK_PIN D1
#define SDA_DATA_PIN D2

//Initialize OneWire library for temperature sensor
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);

// set the LCD address
LiquidCrystal_I2C lcd1(0x27,16,2);  
LiquidCrystal_I2C lcd2(0x3F,16,2); 


float HighestTemp1 = 0.0;
float CurrentTemp1 = 0.0;
float LowestTemp1 = 0.0;
float HighestTemp2 = 0.0;
float CurrentTemp2 = 0.0;
float LowestTemp2 = 0.0;

// Set probe address
DeviceAddress Probe01 = { 0x28, 0xFF, 0x27, 0xC9, 0xC1, 0x17, 0x04, 0x50 };
DeviceAddress Probe02 = { 0x28, 0xFF, 0x41, 0x00, 0xC2, 0x17, 0x04, 0x93 };

void setup()
{
  // start temperature sensor
  sensors.begin();
  sensors.requestTemperatures(); //get temperature
  
  // Start the LCD
  lcd1.init();
  lcd2.init();
  //lcd display screen backlight
  lcd1.backlight();  
  lcd2.backlight(); 
  //clear lcd display
  lcd1.clear(); 
  lcd1.home(); 
  lcd2.clear();
  lcd2.home();
  
  //Set lowest, highest temperatues 
  CurrentTemp1  = sensors.getTempCByIndex(0);
  HighestTemp1 = CurrentTemp1;
  LowestTemp1 = CurrentTemp1;
  CurrentTemp2  = sensors.getTempCByIndex(0);
  HighestTemp2 = CurrentTemp2;
  LowestTemp2 = CurrentTemp2;

// LCD display information
  lcd1.setCursor(0,0);
  lcd1.print(F("Current: "));
  LCDshowNum(9,0,CurrentTemp1);  

  lcd1.setCursor(0,1);
  lcd1.print(F("Ma: "));
  LCDshowNum(3,1,HighestTemp1);    
     
  lcd1.setCursor(9,1);
  lcd1.print(F("Mi: "));
  LCDshowNum(12,1,LowestTemp1);
       
  lcd2.setCursor(0,0);
  lcd2.print(F("Current: "));
  LCDshowNum(9,0,CurrentTemp2);  

  lcd2.setCursor(0,1);
  lcd2.print(F("Ma: "));
  LCDshowNum(3,1,HighestTemp2);    
     
  lcd2.setCursor(9,1);
  lcd2.print(F("Mi: "));
  LCDshowNum(12,1,LowestTemp2); 
}


void loop()
{ 
  sensors.requestTemperatures(); //get temperature

  //Get Current
  CurrentTemp1 = sensors.getTempCByIndex(0);
  LCDshowNum(9,0,CurrentTemp1);    
  CurrentTemp2 = sensors.getTempCByIndex(0);
  LCDshowNum(9,0,CurrentTemp1);   
  
  //Check if Hightest
  if(CurrentTemp1 > HighestTemp1)
     HighestTemp1 = CurrentTemp1;
     LCDshowNum(3,1,HighestTemp1); 
  if(CurrentTemp2 > HighestTemp2)
     HighestTemp2 = CurrentTemp2;
     LCDshowNum(3,1,HighestTemp2); 
     
  //Chekc if Lowest
  if(CurrentTemp1 < LowestTemp1)
    LowestTemp1 = CurrentTemp1;
    LCDshowNum(12,1,LowestTemp1);
 if(CurrentTemp2 < LowestTemp2)
    LowestTemp2 = CurrentTemp2;
    LCDshowNum(12,1,LowestTemp2);
  
  
  delay(1);
}

/*
* LCDshowNum
* LCD display location: x, y
* Float n: temperature to display
*/
void LCDshowNum(int x, int y, float n){
  lcd1.setCursor(x,y);
  lcd1.print(n);
  lcd2.setCursor(x,y);
  lcd2.print(n);
}

I thought I have not set each CurrentTemp to its respective probe, but I have been trying for a while now and can't figure it out ha ha

UKHeliBob:

 CurrentTemp1 = sensors.getTempCByIndex(0);

LCDshowNum(9, 0, CurrentTemp1);
 CurrentTemp2 = sensors.getTempCByIndex(0);
 LCD2showNum(9, 0, CurrentTemp1);



This looks like you are reading the same sensor twice then compounding the error by displaying the same variable on each LCD

Copy/Paste/forget to change details maybe ?

Sorry I am fairly new to the Arduino scene, what bit do you think i forgot to change?

  CurrentTemp1 = sensors.getTempCByIndex(0);

  CurrentTemp2 = sensors.getTempCByIndex(0);

Is the same data being read twice. I don't know the answer.

  LCDshowNum(9, 0, CurrentTemp1);

  LCD2showNum(9, 0, CurrentTemp1);

This displays the same variable on each LCD

That's what I was thinking but i don't know how to change it so that it reads the probes separately, I have been playing about and will keep going