2 NTC Senors and 2 Digital Potentiometers

Hello Folks,

I wanted some Ideas how and where to begin/continue with my Project.

First of all, what i want to do is the following:

Measure 2 NTC Sensors and Simulate 2 NTC Sensors.
I want the Arduino to measure the "real" temperature and depending on how high/low the temperature is , i want it so simulate a "fake" temperature, once the "real" temperature passes a limit i want it to simulate the "real" temperature. And this 2 times.

The NTC Sensors i have to use:
The 2 NTC Sensors have different measuring ranges, one from 76k - 42 Ohm and 96k - 32 Ohm. The original measuring device uses 5V to measure.

I am already able to measure the resistance of one NTC sensor, but currently im thinking about how to measure 2 of them at the same time? Does someone have a hint here to help me ?

SOLUTION FOR 2 NTC SENSORS CLICK HERE

Im using an Ardunio micro.

Thanks for the help.

I am already able to measure the resistance of one NTC sensor

Can I suggest that you post the code to do this for advice to be given as to how to use two sensors. How are the sensors connected to the Arduino ?

UKHeliBob:
Can I suggest that you post the code to do this for advice to be given as to how to use two sensors. How are the sensors connected to the Arduino ?

Sure , im using the following Code to measure so far.

// Resistance measurement

//              _____
//            -|_R1__|- VCC
//AnalogPin  -' _____
//           '-|_R2__|- GND

// R2 = Resistance to measure

float SourceVoltage=5.0;
int AnalogPin=5;
int R1=1500.0; //Value of the known resistance
long measurementvalue;
float VoltageR2; 
float Resistance;

void setup()
{
  Serial.begin(9600);
  Serial.println("measure resistance");
  Serial.println();
}

void loop()
{
  measurementvalue=0;
  for(int i=0;i<5;i++){
    measurementvalue+=analogRead(AnalogPin);
  }
  measurementvalue=trunc(measurementvalue/5);
  
  //Calculate Voltage
  VoltageR2=(SourceVoltage/1023.0)*measurementvalue;
  Serial.print("Voltage for R2 is : ");
  Serial.print(VoltageR2);
  Serial.println(" Volt!");
  //Berechnung: (R2 = R1 * (U2/U1))
  Widerstand=R1*(VoltageR2/(SourceVoltage-VoltageR2));
  Serial.print("DThe Resistance has ");
  Serial.print(Resistance,2);
  Serial.println(" Ohm.");
  Serial.println();
  delay(1000);
}

this is my setup, Widerstand = Resistance.

So what is the problem in using 2 sensors ?
At its crudest you could simply copy the code for one sensor and simply read a second analogue input.

Hmm well if its as easy as is sounds from your wondering, maybe you can check how i would do it .

Would that be right?

float SourceVoltage=5.0;
int AnalogPin1=4;
int AnalogPin2=3;
int R1=4700.0; //Value of the known resistance
long measurementvalue1;
long measurementvalue2;
float VoltageR1;
float VoltageR2; 
float Resistance1;
float Resistance2;

void setup()
{
  Serial.begin(9600);
  Serial.println("measure resistance");
  Serial.println();
}

void loop()
{
  measurementvalue=0;
  for(int i=0;i<5;i++){
  measurementvalue1+=analogRead(AnalogPin1);
  measurementvalue2+=analogRead(AnalogPin2);
  }

  measurementvalue1=trunc(measurementvalue1/5);
  measurementvalue2=trunc(measurementvalue2/5);
  
  //Calculate Voltage
  VoltageR1=(SourceVoltage/1023.0)*measurementvalue1;
  Serial.print("Voltage for R1 is : ");
  Serial.print(VoltageR1);
  Serial.println(" Volt!");
  
  //Calculate Voltage
  VoltageR2=(SourceVoltage/1023.0)*measurementvalue2;
  Serial.print("Voltage for R2 is : ");
  Serial.print(VoltageR2);
  Serial.println(" Volt!");


  Widerstand=R1*(VoltageR1/(SourceVoltage-VoltageR1));
  Serial.print("The Resistance1 has ");
  Serial.print(Resistance1,2);
  Serial.println(" Ohm.");
  Serial.println();
  delay(1000);

  Widerstand=R1*(VoltageR2/(SourceVoltage-VoltageR2));
  Serial.print("The Resistance2 has ");
  Serial.print(Resistance2,2);
  Serial.println(" Ohm.");
  Serial.println();
  delay(1000);
}

The code you posted won't compile because of undeclared variables but the idea looks OK. I note that you calculate Widerstand but never use its value in the program and, in any case, it is not declared so causes an error.

One thing that is wrong is that you never reset the values of measurementvalue1 and measurementvalue2 to zero so they will get larger and larger. You reset the value of measurementvalue but have forgotten to change the program to take account of the 2 variables that you have now instead of the single one.

Once this version is working you can improve it by using the same code to do the reading and calculations without repeating it.

Thanks, yeah the code i posted was originally in german , and i translated into English and as you found, i made some mistakes :smiley:

Is the wiring OK ? Im mostly not sure if that is correct as i think it is.

The original Fritzing wiring diagram only has a connection to A5 but your 2 sensor code uses A4 and A3. Presumably you have amended the wiring. Personally I find schematics easier to follow than Fritzing graphics even if they are hand drawn and photographed.

Yeah the Graphic wiring looked shitty when i used A5 and A4, but in the schematics i took A5 and A4. Well then ill try it this evening home and report if everything worked fine :slight_smile: Thanks for your help so far

Hi,
I think the attached file will have what you need to read two NTC resistors.

Tom.... :slight_smile:

So its done, first part at least, im able to measure the 2 Sensors by using the following code and the attached build.

So now ill look into the digital Potentiometer :slight_smile: Thanks for your helps so far guys :slight_smile:

float Voltage=5.0;
int AnalogPin1=5;
int AnalogPin2=4;
int ConstantRes=2000.0; //Value of the know Resistor
long Value1;
long Value2;
float VoltR1; 
float VoltR2; 
float Resistor1;
float Resistor2;

void setup()
{
  Serial.begin(9600);
  Serial.println("Widerstand ausmessen");
  Serial.println();
}

void loop()
{
  //Measure 5 times and calulate middle value
  Value1=0;
  Value2=0;
  for(int i=0;i<5;i++){
    Value1+=analogRead(AnalogPin1);
    Value2+=analogRead(AnalogPin2);
  }
  Value1=trunc(Value1/5);
  Value2=trunc(Value2/5);
  
  //Calculate Voltage
  VoltR1=(Voltage/1023.0)*Value1;
  Serial.print("Spannung ueber R1 betraegt ");
  Serial.print(VoltR1,2);
  Serial.println(" Volt!");
  //Calculation: (R2 = R1 * (U2/U1))
  Resistor1=ConstantRes*(VoltR1/(Voltage-VoltR1));
  Serial.print("Der Widerstand hat ");
  Serial.print(Resistor1,2);
  Serial.println(" Ohm.");
  Serial.println();
  delay(1000);  
  //Calculate Voltage
  VoltR2=(Voltage/1023.0)*Value2;
  Serial.print("Spannung ueber R2 betraegt ");
  Serial.print(VoltR2,2);
  Serial.println(" Volt!");
  //Calculation: (R2 = R1 * (U2/U1))
  Resistor2=ConstantRes*(VoltR2/(Voltage-VoltR2));
  Serial.print("Der Widerstand hat ");
  Serial.print(Resistor2,2);
  Serial.println(" Ohm.");
  Serial.println();
  delay(1000);
}