Hello,
as part of my still ongoing CarDuino project, I would like to measure certain thermistor voltages (oil and coolant temperature) on my car, so I can later use that data with the actual CarDuino to calculate those temperatures.
For this purpose, I've built a "rough and ready" voltage meter on a breadboard which I want to connect to my car to get that data. I've got a laptop with OBD software which will show me the actual temperatures, so I will just have to draw a graph with my measured voltages and the corresponding temperatures shown by the OBD software.
Note: My car has OBD I, so I have to measure most gauges out myself and can't simply tap into the on-board electronics via OBDII to get those temperature values. The car's OBD I protocol is Rover/MG specific, so even if I was able to read out the hex values from the OBD, I wouldn't know what they meant, because very little about Rover's OBD I protocol is known.
Anyway, here's the schematic. Note that for the time being, I've hooked this circuit up to a rudimentary 12V switchboard with which I can control two channels with adjustable voltages.
And here's my sketch so far:
#define input1 A3
#define input2 A1
#define led 9
#define refVoltage A0
// defining input variables
int input1Value;
int input2Value;
int aRefValue;
// defining voltage variables
float input1Voltage;
float input2Voltage;
float aRefVoltage;
// Turning analog inputs into voltages
float makeVoltage(int inputValue) {
// calculation formula to turn analog value 0-1023 into voltage
// based on using 22K / 10K voltage dividers
float doMakeVoltage = (float) ((160 * inputValue / 1023) / 10);
return doMakeVoltage;
}
void setup() {
// With external reference,
// no readings on serial at all.
// Therefore, commented out at the moment.
// analogReference(EXTERNAL);
Serial.begin(115200);
pinMode(input1, INPUT);
pinMode(input2, INPUT);
pinMode(led, OUTPUT);
pinMode(refVoltage, INPUT);
}
void loop() {
// Reading analog input and calculating values
// input channel 1
input1Value = analogRead(input1);
input1Voltage = makeVoltage(input1Value);
// input channel 2
input2Value = analogRead(input2);
input2Voltage = makeVoltage(input2Value);
// ... and the car's current operating voltage
aRefValue = analogRead(refVoltage);
aRefVoltage = makeVoltage(refVoltage);
// Blink status LED
digitalWrite(led, HIGH);
delay(100);
digitalWrite(led, LOW);
// Printing out the readings
Serial.println("Input channel\t\tvalue\tvolts\n");
Serial.print("Input 1:\t\t");
Serial.print(input1Value);
Serial.print("\t");
Serial.println(input1Voltage);
Serial.print("Input 2:\t\t");
Serial.print(input2Value);
Serial.print("\t");
Serial.println(input2Voltage);
Serial.print("ext. voltage:\t\t\t");
Serial.println(aRefVoltage);
Serial.print("\n\n\n");
// wait 2 seconds before reading inputs again
delay(2000);
}
The problem is that right now, it's not exactly giving me what I want. I get weird readings on serial, and I also can't show the car's current operating voltage.
What I want the sketch to do is show me the value of the analog reading (0-1023) as well as the calculated voltage that those readings represent.
I'm not sure yet if it's best to measure the voltages against the Arduino's 5 volts, or against the car's current operating voltage using analogReference(EXTERNAL). What I'm really after is the changing resistance of the thermistors, but that can only be measured for my purposes as a change of voltage, can't it... but then the problem is that at a given resistance, I will get different voltages between when the engine is off, and when the engine is on with the alternator running.
Any help is appreciated.
- carguy
EDIT: The first schematic I posted had an error in it with the voltage dividers. I've updated that now.