Error Combining Sketches + Vishay Thermistor question

I'm trying to combine to working sketches and I'm getting an error message when compiling the error message is " getTemperature " is not declared in this sketch,

How do I fix this please ?

Also I have 2 different types of temperature probes used in a project and I would like both to be used with arduino one is a simple Dallas one wire which works fine the other is a Vishay 10K thermistor NTCLE203E3103FB0 which I've been advised wont work well with arduino due to it being none linear,

I s there a way to use this probe accurately with arduino ?

Thanks Pete

We need to see the code before we could possibly help.
Please use the code tags <CODE>

Just click on the icon and follow the instructions.

All thermistors are non-linear but are still quite usable with any Arduino

Sorry I should have attached the 2 sketches
sketch_Stienhart_MutipleProbes.ino (1.3 KB)
sketch_Johny_5.ino (18.6 KB)

Show the combined sketch that did not work

this is it

sketch_Johnny5_Test.ino (19.7 KB)

The sketch_Johny_5.ino is all screwed up and does not compile.
So it could not be a working sketch.
Please post the working sketch.

try this one
sketch_Johny_5.ino (18.6 KB)

Does it compile witout errors?

the one I have open live now does, the one I've uploaded should be the same one

No, I had to remove an extra "}" to make it compile.

Ahh ok sorry about that, can you see how they dont combine ?

I combined the two and it compiles withot errors.
I don't know what the Johny_5 program does so I'm not sure if the combined program does what you want.

// Pins used 2, 7, 12, 14, 15, 16 22, 24 26 28, 29, 36, 40,


#include "OneWire.h"
#include "DallasTemperature.h"
// Define to which pin of the Arduino the 1-Wire bus is connected:
#define ONE_WIRE_BUS 9
#include <math.h>

// Steinhart-Hart parameters
#define THERMISTORNOMINAL 10000
#define TEMPERATURENOMINAL 25
#define BCOEFFICIENT 3950
#define SERIESRESISTOR 10000

// Analog pins for the thermistors
const int THERMISTOR_PIN_1 = A0;
const int THERMISTOR_PIN_2 = A1;
const int THERMISTOR_PIN_3 = A2;
const int THERMISTOR_PIN_4 = A3;



// Create a new instance of the oneWire class to communicate with any OneWire device:
OneWire oneWire(ONE_WIRE_BUS);

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



int ledpin = 13; // initialize pin 13
int inpin = 7; // initialize pin 7
int val;// define val for Worm Barrel overflow sensor

const int PumpPin = 29;                    // for Worm Barrel pump

const int     WBMotor1Pin  = 22;    // For Worm Barrel In put water valve
const int     WBMotor2Pin  = 23;
const int     WBEnablePin  = 24;

const byte WBSensorInterrupt = 0;  // 1 = pin 2; 0 = pin 3  // For Worm Barrel hall sensor
const byte WBSensorPin       = 2;

volatile byte WBPulseCount;
float WBCalibrationFactor = 4.5;

float         WBFlowRate;
unsigned int  WBFlowMilliLitres;
float         WBTotalMilliLitresA;
unsigned long WBTotalMilliLitresB;
unsigned long WBOldTime;

float WBTargetTemperature = 20 ;  // For Obstention temperature
float WBActualTemperature;


const int ChillStillHead = 40;  // Input from BSC460 for Still Head
const int ChillThumper1 = 41;   // Input from BSC460 For Inline Thumper 1
const int ChillThumper2 = 42;  // Input from BSC460 for Inline Thumper 2


const int     Rectification1Motor1Pin  = 30;   // For Inline Thumper 1
const int     Rectification1Motor2Pin  = 31;
const int     Rectification1EnablePin  = 32;


const byte Rectification1SensorInterrupt = 1;  // 1 = pin 2; 0 = pin 3
const byte Rectification1SensorPin       = 5;  // For Inline Thumper 1 hall sensor

float         Rectification1FlowRate;
unsigned int  Rectification1FlowMilliLitres;
float         Rectification1TotalMilliLitresA;
unsigned long Rectification1TotalMilliLitresB;
unsigned long Rectification1OldTime;

volatile byte Rectification1PulseCount;
float Rectification1CalibrationFactor = 4.5;



const int     Rectification2Motor1Pin  = 16;    // For Inline Thumper 2
const int     Rectification2Motor2Pin  = 14;
const int     Rectification2EnablePin  = 15;


const byte Rectification2SensorInterrupt = 3;  // 1 = pin 2; 0 = pin 3
const byte Rectification2SensorPin       = 6; // For Inline Thumper 2 hall sensor

float         Rectification2FlowRate;
unsigned int  Rectification2FlowMilliLitres;
float         Rectification2TotalMilliLitresA;
unsigned long Rectification2TotalMilliLitresB;
unsigned long Rectification2OldTime;

volatile byte Rectification2PulseCount;
float Rectification2CalibrationFactor = 4.5;


const int     StillHeadMotor1Pin  = 19;
const int     StillHeadMotor2Pin  = 18;
const int     StillHeadEnablePin  = 17;


const byte StillHeadSensorInterrupt = 1;  // 1 = pin 2; 0 = pin 3
const byte StillHeadSensorPin       = 4;

float         StillHeadFlowRate;
unsigned int  StillHeadFlowMilliLitres;
float         StillHeadTotalMilliLitresA;
unsigned long StillHeadTotalMilliLitresB;
unsigned long StillHeadOldTime;

volatile byte StillHeadPulseCount;
float StillHeadCalibrationFactor = 4.5;

float getTemperature(int pin) {
  int rawADC = analogRead(pin);
  float resistance = SERIESRESISTOR / ((1023.0 / rawADC) - 1.0);

  float steinhart;
  steinhart = resistance / THERMISTORNOMINAL;
  steinhart = log(steinhart);
  steinhart /= BCOEFFICIENT;
  steinhart += 1.0 / (TEMPERATURENOMINAL + 273.15);
  steinhart = 1.0 / steinhart;
  steinhart -= 273.15;

  return steinhart;
}



void setup()
{
  Serial.begin(9600);
  sensors.begin();

  pinMode ( PumpPin, OUTPUT);
  digitalWrite ( PumpPin,  HIGH) ;


  pinMode          (WBMotor1Pin, OUTPUT);
  pinMode          (WBMotor2Pin, OUTPUT);
  pinMode          (WBEnablePin, OUTPUT);


  pinMode          (Rectification1Motor1Pin, OUTPUT);
  pinMode          (Rectification1Motor1Pin, OUTPUT);
  pinMode          (Rectification1EnablePin , OUTPUT);


  pinMode          (Rectification2Motor1Pin, OUTPUT);
  pinMode          (Rectification2Motor1Pin, OUTPUT);
  pinMode          (Rectification2EnablePin , OUTPUT);


  pinMode          (StillHeadMotor1Pin, OUTPUT);
  pinMode          (StillHeadMotor1Pin, OUTPUT);
  pinMode          (StillHeadEnablePin , OUTPUT);



  pinMode(ledpin, OUTPUT); // set LED pin as “output”
  pinMode(inpin, INPUT); // set button pin as “input”


  pinMode (ChillThumper1, INPUT);
  pinMode (ChillThumper2, INPUT);
  pinMode (ChillStillHead, INPUT);


  digitalWrite (ChillThumper1, LOW);
  digitalWrite (ChillThumper2, LOW);
  digitalWrite (ChillStillHead, LOW);


}



void loop()

{
  float temp1 = getTemperature(THERMISTOR_PIN_1);
  float temp2 = getTemperature(THERMISTOR_PIN_2);
  float temp3 = getTemperature(THERMISTOR_PIN_3);
  float temp4 = getTemperature(THERMISTOR_PIN_4);

  Serial.print("Still Body: ");
  Serial.print(temp1);
  Serial.println(" *C");

  Serial.print("Still Head: ");
  Serial.print(temp2);
  Serial.println(" *C");

  Serial.print("THumper 1: ");
  Serial.print(temp3);
  Serial.println(" *C");

  Serial.print("Thumper 2: ");
  Serial.print(temp4);
  Serial.println(" *C");

  // delay(1000);


  // Send the command for all devices on the bus to perform a temperature conversion:
  sensors.requestTemperatures();

  // Fetch the temperature in degrees Celsius for device index:
  float tempC = sensors.getTempCByIndex(0); // the index 0 refers to the first device
  // Fetch the temperature in degrees Fahrenheit for device index:
  float tempF = sensors.getTempFByIndex(0);


  WBActualTemperature = tempC ;


  val = digitalRead(inpin); // read the level value of pin 7 and assign if to val
  delay(100);


  if (val == LOW) //  if yes, turn on the LED
  { digitalWrite(ledpin, LOW);
    digitalWrite(WBEnablePin, HIGH);
    digitalWrite(WBMotor1Pin, LOW);
    digitalWrite(WBMotor2Pin, HIGH);



  }

  else
    //digitalWrite(WBEnablePin, HIGH);
    //      digitalWrite(WBMotor1Pin, HIGH);
    //      digitalWrite(WBMotor2Pin, LOW);
  { digitalWrite(ledpin, HIGH);

    {
      if (WBActualTemperature <= WBTargetTemperature ) WBValveOpenControl();

      if (WBActualTemperature >= WBTargetTemperature ) WBValveCloseControl();

      if (WBActualTemperature <= 16) digitalWrite (PumpPin,  LOW);
      else digitalWrite ( PumpPin , HIGH);

    }



  }


  if (ChillThumper1 == HIGH)
  { Rectification1ValveOpenControl(); // Input to chill thumper 1 from BSC460
  }
  else

    Rectification1ValveCloseControl();


  if (ChillThumper2 == HIGH)
  { Rectification2ValveOpenControl(); // Input to chill thumper 1 from BSC460
  }
  else

    Rectification2ValveCloseControl();



  if (ChillStillHead == HIGH)
  { StillHeadValveOpenControl(); // Input to chill thumper 1 from BSC460
  }
  else

    StillHeadValveCloseControl();




  if ((millis() - WBOldTime) > 1000) {
    detachInterrupt(WBSensorInterrupt);

    WBFlowRate = ((1000.0 / (millis() - WBOldTime)) * WBPulseCount) / WBCalibrationFactor;

    WBOldTime = millis();

    WBFlowMilliLitres = (WBFlowRate / 60) * 1000;

    // Add the millilitres passed in this second to the cumulative total
    WBTotalMilliLitresA += WBFlowMilliLitres;
    WBTotalMilliLitresB += WBFlowMilliLitres;

    unsigned int WBFrac;

    WBFrac = (WBFlowRate - int(WBFlowRate)) * 10;
    // Reset the pulse counter so we can start incrementing again
    WBPulseCount = 0;

    // Enable the interrupt again now that we've finished sending output
    attachInterrupt(WBSensorInterrupt, WBPulseCounter, FALLING);

  }




  if ((millis() - Rectification1OldTime) > 1000)  {
    detachInterrupt(Rectification1SensorInterrupt);

    Rectification1FlowRate = ((1000.0 / (millis() - Rectification1OldTime)) * Rectification1PulseCount) / Rectification1CalibrationFactor;


    Rectification1OldTime = millis();

    Rectification1FlowMilliLitres = (Rectification1FlowRate / 60) * 1000;

    // Add the millilitres passed in this second to the cumulative total
    Rectification1TotalMilliLitresA += Rectification1FlowMilliLitres;
    Rectification1TotalMilliLitresB += Rectification1FlowMilliLitres;

    unsigned int Rectification1Frac;

    Rectification1Frac = (Rectification1FlowRate - int(Rectification1FlowRate)) * 10;
    // Reset the pulse counter so we can start incrementing again
    Rectification1PulseCount = 0;

    // Enable the interrupt again now that we've finished sending output
    attachInterrupt(Rectification1SensorInterrupt, Rectification1PulseCounter, FALLING);

  }







  if ((millis() - Rectification2OldTime) > 1000)  {
    detachInterrupt(Rectification2SensorInterrupt);

    Rectification2FlowRate = ((1000.0 / (millis() - Rectification2OldTime)) * Rectification2PulseCount) / Rectification2CalibrationFactor;


    Rectification2OldTime = millis();

    Rectification2FlowMilliLitres = (Rectification2FlowRate / 60) * 1000;

    // Add the millilitres passed in this second to the cumulative total
    Rectification2TotalMilliLitresA += Rectification2FlowMilliLitres;
    Rectification2TotalMilliLitresB += Rectification2FlowMilliLitres;

    unsigned int Rectification2Frac;

    Rectification2Frac = (Rectification2FlowRate - int(Rectification2FlowRate)) * 10;
    // Reset the pulse counter so we can start incrementing again
    Rectification2PulseCount = 0;

    // Enable the interrupt again now that we've finished sending output
    attachInterrupt(Rectification2SensorInterrupt, Rectification2PulseCounter, FALLING);



  }


  if ((millis() - StillHeadOldTime) > 1000)  {
    detachInterrupt(StillHeadSensorInterrupt);

    StillHeadFlowRate = ((1000.0 / (millis() - StillHeadOldTime)) * StillHeadPulseCount) / StillHeadCalibrationFactor;


    StillHeadOldTime = millis();

    StillHeadFlowMilliLitres = (StillHeadFlowRate / 60) * 1000;

    // Add the millilitres passed in this second to the cumulative total
    StillHeadTotalMilliLitresA += StillHeadFlowMilliLitres;
    StillHeadTotalMilliLitresB += StillHeadFlowMilliLitres;

    unsigned int StillHeadFrac;

    StillHeadFrac = (StillHeadFlowRate - int(StillHeadFlowRate)) * 10;
    // Reset the pulse counter so we can start incrementing again
    StillHeadPulseCount = 0;

    // Enable the interrupt again now that we've finished sending output
    attachInterrupt(StillHeadSensorInterrupt, StillHeadPulseCounter, FALLING);

  }

  {

    Serial.println();
    Serial.print( "Worm Barrel L ") ;
    Serial.print (WBTotalMilliLitresA);
    Serial.print ("  Still Head L ");
    Serial.print (StillHeadTotalMilliLitresA);
    Serial.print ("  Thumper 1 L ");
    Serial.print (Rectification1TotalMilliLitresA);
    Serial.print ("  Thumper 2 L ");
    Serial.print (Rectification2TotalMilliLitresA);
    Serial.print("  Obstention Temperature: ");
    Serial.print(tempC);
    Serial.print(" \xC2\xB0"); // shows degree symbol
    Serial.print("C  |  ");
    Serial.println();


  }



}





void WBPulseCounter() {

  // Increment the pulse counter
  WBPulseCount++;
}

void Rectification1PulseCounter() {

  // Increment the pulse counter
  Rectification1PulseCount++;
}

void Rectification2PulseCounter() {

  // Increment the pulse counter
  Rectification2PulseCount++;
}

void StillHeadPulseCounter() {

  // Increment the pulse counter
  StillHeadPulseCount++;
}




void openWBValve() {
  digitalWrite(WBEnablePin, HIGH);
  digitalWrite(WBMotor1Pin, LOW);
  digitalWrite(WBMotor2Pin, HIGH);
}

void closeWBValve() {
  digitalWrite(WBEnablePin, HIGH);
  digitalWrite(WBMotor1Pin, HIGH);
  digitalWrite(WBMotor2Pin, LOW);
}

void WBValveOpenControl() { // MLTFill Open valve control for sparge
  long interval = 100;
  long shortInterval = 50;
  unsigned long currentMillis = millis();
  long previousMillis = 0;
  unsigned long SIcurrentMillis = millis();
  long SIpreviousMillis = 0;
  if (currentMillis - previousMillis > interval) {
    digitalWrite(WBEnablePin, HIGH);
    digitalWrite(WBMotor1Pin, LOW);
    digitalWrite(WBMotor2Pin, HIGH);
    ////////////// A delay may be required here as the valve ages
    previousMillis = currentMillis;
  }

  if (SIcurrentMillis - SIpreviousMillis > shortInterval) {
    digitalWrite(WBEnablePin, HIGH);
    digitalWrite(WBMotor1Pin, LOW);
    digitalWrite(WBMotor2Pin, LOW);
    SIpreviousMillis = SIcurrentMillis;
  }
}

void WBValveCloseControl() { // MLTFill Close valve control for sparge
  long interval = 100;
  long shortInterval = 50;
  unsigned long currentMillis = millis();
  long previousMillis = 0;
  unsigned long SIcurrentMillis = millis();
  long SIpreviousMillis = 0;
  if (currentMillis - previousMillis > interval) {
    digitalWrite(WBEnablePin, HIGH);
    digitalWrite(WBMotor1Pin, HIGH);
    digitalWrite(WBMotor2Pin, LOW);
    ////////////// A delay may be requireed as the valve ages
    previousMillis = currentMillis;
  }

  if (SIcurrentMillis - SIpreviousMillis > shortInterval) {
    digitalWrite(WBEnablePin, HIGH);
    digitalWrite(WBMotor1Pin, LOW);
    digitalWrite(WBMotor2Pin, LOW);
    SIpreviousMillis = SIcurrentMillis;
  }
}







void openRectification1Valve() {
  digitalWrite(Rectification1EnablePin, HIGH);
  digitalWrite(Rectification1Motor1Pin, LOW);
  digitalWrite(Rectification1Motor2Pin, HIGH);
}

void closeRectification1Valve() {
  digitalWrite(Rectification1EnablePin, HIGH);
  digitalWrite(Rectification1Motor1Pin, HIGH);
  digitalWrite(Rectification1Motor2Pin, LOW);
}


void Rectification1ValveOpenControl() { // Rectification1 Open valve control for sparge
  long interval = 100;
  long shortInterval = 50;
  unsigned long currentMillis = millis();
  long previousMillis = 0;
  unsigned long SIcurrentMillis = millis();
  long SIpreviousMillis = 0;
  if (currentMillis - previousMillis > interval) {
    digitalWrite(Rectification1EnablePin, HIGH);
    digitalWrite(Rectification1Motor1Pin, LOW);
    digitalWrite(Rectification1Motor2Pin, HIGH);
    ////////////// A delay may be required here as the valve ages
    previousMillis = currentMillis;
  }

  if (SIcurrentMillis - SIpreviousMillis > shortInterval) {
    digitalWrite(Rectification1EnablePin, HIGH);
    digitalWrite(Rectification1Motor1Pin, LOW);
    digitalWrite(Rectification1Motor2Pin, LOW);
    SIpreviousMillis = SIcurrentMillis;
  }
}

void Rectification1ValveCloseControl() { // Rectification1 Close valve control for sparge
  long interval = 100;
  long shortInterval = 50;
  unsigned long currentMillis = millis();
  long previousMillis = 0;
  unsigned long SIcurrentMillis = millis();
  long SIpreviousMillis = 0;
  if (currentMillis - previousMillis > interval) {
    digitalWrite(Rectification1EnablePin, HIGH);
    digitalWrite(Rectification1Motor1Pin, HIGH);
    digitalWrite(Rectification1Motor2Pin, LOW);
    ////////////// A delay may be requireed as the valve ages
    previousMillis = currentMillis;
  }

  if (SIcurrentMillis - SIpreviousMillis > shortInterval) {
    digitalWrite(Rectification1EnablePin, HIGH);
    digitalWrite(Rectification1Motor1Pin, LOW);
    digitalWrite(Rectification1Motor2Pin, LOW);
    SIpreviousMillis = SIcurrentMillis;
  }
}






void openRectification2Valve() {
  digitalWrite(Rectification2EnablePin, HIGH);
  digitalWrite(Rectification2Motor1Pin, LOW);
  digitalWrite(Rectification2Motor2Pin, HIGH);
}

void closeRectification2Valve() {
  digitalWrite(Rectification2EnablePin, HIGH);
  digitalWrite(Rectification2Motor1Pin, HIGH);
  digitalWrite(Rectification2Motor2Pin, LOW);
}


void Rectification2ValveOpenControl() { // Rectification2 Open valve control for sparge
  long interval = 100;
  long shortInterval = 50;
  unsigned long currentMillis = millis();
  long previousMillis = 0;
  unsigned long SIcurrentMillis = millis();
  long SIpreviousMillis = 0;
  if (currentMillis - previousMillis > interval) {
    digitalWrite(Rectification2EnablePin, HIGH);
    digitalWrite(Rectification2Motor1Pin, LOW);
    digitalWrite(Rectification2Motor2Pin, HIGH);
    ////////////// A delay may be required here as the valve ages
    previousMillis = currentMillis;
  }

  if (SIcurrentMillis - SIpreviousMillis > shortInterval) {
    digitalWrite(Rectification2EnablePin, HIGH);
    digitalWrite(Rectification2Motor1Pin, LOW);
    digitalWrite(Rectification2Motor2Pin, LOW);
    SIpreviousMillis = SIcurrentMillis;
  }
}

void Rectification2ValveCloseControl() { // Rectification2 Close valve control for sparge
  long interval = 100;
  long shortInterval = 50;
  unsigned long currentMillis = millis();
  long previousMillis = 0;
  unsigned long SIcurrentMillis = millis();
  long SIpreviousMillis = 0;
  if (currentMillis - previousMillis > interval) {
    digitalWrite(Rectification2EnablePin, HIGH);
    digitalWrite(Rectification2Motor1Pin, HIGH);
    digitalWrite(Rectification2Motor2Pin, LOW);
    ////////////// A delay may be requireed as the valve ages
    previousMillis = currentMillis;
  }

  if (SIcurrentMillis - SIpreviousMillis > shortInterval) {
    digitalWrite(Rectification2EnablePin, HIGH);
    digitalWrite(Rectification2Motor1Pin, LOW);
    digitalWrite(Rectification2Motor2Pin, LOW);
    SIpreviousMillis = SIcurrentMillis;
  }
}


void openStillHeadValve() {
  digitalWrite(StillHeadEnablePin, HIGH);
  digitalWrite(StillHeadMotor1Pin, LOW);
  digitalWrite(StillHeadMotor2Pin, HIGH);
}

void closeStillHeadValve() {
  digitalWrite(StillHeadEnablePin, HIGH);
  digitalWrite(StillHeadMotor1Pin, HIGH);
  digitalWrite(StillHeadMotor2Pin, LOW);
}


void StillHeadValveOpenControl() { // StillHead Open valve control for sparge
  long interval = 100;
  long shortInterval = 50;
  unsigned long currentMillis = millis();
  long previousMillis = 0;
  unsigned long SIcurrentMillis = millis();
  long SIpreviousMillis = 0;
  if (currentMillis - previousMillis > interval) {
    digitalWrite(StillHeadEnablePin, HIGH);
    digitalWrite(StillHeadMotor1Pin, LOW);
    digitalWrite(StillHeadMotor2Pin, HIGH);
    ////////////// A delay may be required here as the valve ages
    previousMillis = currentMillis;
  }

  if (SIcurrentMillis - SIpreviousMillis > shortInterval) {
    digitalWrite(StillHeadEnablePin, HIGH);
    digitalWrite(StillHeadMotor1Pin, LOW);
    digitalWrite(StillHeadMotor2Pin, LOW);
    SIpreviousMillis = SIcurrentMillis;
  }
}

void StillHeadValveCloseControl() { // StillHead Close valve control for sparge
  long interval = 100;
  long shortInterval = 50;
  unsigned long currentMillis = millis();
  long previousMillis = 0;
  unsigned long SIcurrentMillis = millis();
  long SIpreviousMillis = 0;
  if (currentMillis - previousMillis > interval) {
    digitalWrite(StillHeadEnablePin, HIGH);
    digitalWrite(StillHeadMotor1Pin, HIGH);
    digitalWrite(StillHeadMotor2Pin, LOW);
    ////////////// A delay may be requireed as the valve ages
    previousMillis = currentMillis;
  }

  if (SIcurrentMillis - SIpreviousMillis > shortInterval) {
    digitalWrite(StillHeadEnablePin, HIGH);
    digitalWrite(StillHeadMotor1Pin, LOW);
    digitalWrite(StillHeadMotor2Pin, LOW);
    SIpreviousMillis = SIcurrentMillis;
  }
}


You've put thing in a different order, I wonder if that was all it was, thank you very much though.

Is the sketch I have the best way to use the probes ?

Programming Electronics Academy released a video on combining sketches... to save all those words.