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 ?
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);
}
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.
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 Thanks for your help so far