Hello everyone!
I have a car outside with a dead cooling fan system - seems ECU related so no chance of getting that fixed easily as it's an old car from 1998! As it's a two speed fan unit, I can't use a bog standard override so I thought I'd use arduino to do it. The engine has a temp sensor in two places (known to be working) and I thought I would sample the voltage from one in order to determine when to activate the low and high speed modes of the fans (using the temp gauge on the dash as a visible reference to set up the values via my netbook).
So, here's what I have so far:
(Yes I have the relay board lol but thats not connected yet).
Arduino is hooked up to a bog standard arduino voltage divider with values of:
R1: 30k
R2: 7.5k (and yes I checked both on the meter to confirm - individually and together).
The problem is that the battery it's hooked up to for testing shows 4.21v on the meter. The meter shows 4.21v on the input to the voltage divider, and it shows 4.19v on the output of the divider... and going into the arduino on the terminal pins.
That can't be right! The output should be a fraction of the input - not the same minus 0.2v! At first I thought it was my code.. but then realised that would not account for the meter picking up a very similar voltage at the output of the divider.
So whats gone wrong here please?
I do also have a digital temp probe hooked up (previous idea was to glue that to the engine lol) but I don't see how that could affect it as thats connected to the DIO pins not any analogue.
The code seems to work fine... (ADC sample value is 969 and the usb supply is 4.46) but I'll post it to keep the critiques happy:
#include <OneWire.h>
#include <DallasTemperature.h>
// Data wire is plugged into pin 2 on the Arduino
#define ONE_WIRE_BUS 5
float Supply = 4.46;
int led = 13;
int vcc = 2;
int gnd = 12;
int analogInput = A1;
float Vout = 0.0;
float Vin = 0.0;
float R1 = 30000.0; //
float R2 = 7500.0; //
int Value = 0;
// Setup a oneWire instance to communicate with any OneWire devices
// (not just Maxim/Dallas temperature ICs)
OneWire oneWire(ONE_WIRE_BUS);
// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);
// the setup routine runs once when you press reset:
void setup() {
// initialize the digital pin as an output.
pinMode(led, OUTPUT);
pinMode(vcc, OUTPUT);
pinMode(gnd, OUTPUT);
// start serial port
Serial.begin(9600);
Serial.println("Dallas Temperature IC Control Library Demo");
// Start up the library
sensors.begin();
digitalWrite(led, HIGH);
digitalWrite(vcc, HIGH);
digitalWrite(gnd, LOW);
pinMode(analogInput, INPUT);
}
// the loop routine runs over and over again forever:
void loop() {
// call sensors.requestTemperatures() to issue a global temperature
// request to all devices on the bus
Serial.print(" Requesting temperatures...");
sensors.requestTemperatures(); // Send the command to get temperatures
Serial.println("DONE");
Serial.print("Temperature for Device 1 is: ");
Serial.println(sensors.getTempCByIndex(0)); // Why "byIndex"?
// You can have more than one IC on the same bus.
// 0 refers to the first IC on the wire
Value = analogRead(analogInput);
Serial.print("ADC Value: "); Serial.println(Value);
Vin = (Value * Supply) / 1024.0;
Serial.print("INPUT Vin = "); Serial.println(Vin, 2);
delay(5000);
}
Sample from the serial link:
Requesting temperatures...DONE
Temperature for Device 1 is: 26.25
ADC Value: 970
INPUT Vin = 4.22
So whats with my voltage divider not working?
Many thanks,
Twixy