Hi. I'm a complete newbee to Arduino....
I've just had my first idea for using the Arduino Uno board I've had here for a year without any purpose - other than learning something new.
Anyway, the project is monitoring 3 temp sensors and 2 pressure sensors - all analog resistive.
After some reading - and getting more confused than educated - I've written some code, compiled it and uploaded it to the Uno. I get no error messages and the expected output format and structure is OK.
BUT the values of the sensors are not as I imagined and don't change when I vary their temperature.
All bar 1 sensor shows seemingly random values. The one that doesn't returns 0 (a pressure sensor that does indeed not have a pressure) the other sensors appear to show the random value whether connected or not.
Anyone have any ideas or interest in having a look at the simple code I wrote - I assume it would be amusing to an expert....
Here is my connection scheme:
and here is my code attempt:
/* Reading analoge temperature and pressure sensors
The board used is an Arduino Uno
The board has 6 analoge input pins
analog Pin 0 (A0)
analog Pin 1 (A1)
analog Pin 2 (A2)
analog Pin 3 (A3)
analog Pin 4 (A4)
analog Pin 5 (A5)
I connected one wire of the sensors to Arduino 5 volt output pin, the other to one of the A0-4 pins.
All sensors are proportional resistive type, approx 5Ohm at 0 deg and 150Ohm at 100 deg
so the voltage at the analog inputs are a proportion of 5V
To start with I want to see the integer number of each sensor until I have calibrated them.
Later I will use something like
OiltempC = analogRead(OilTempSensorValue); // taking the temp pin reading and setting it equal to tempC variable
float OiltempC = (5.0*OiltempC*200.0)/1023.0; // to convert the analog input to a temperature in degrees Celcius, if that turn out to be correct
Serial.print("Oil Temperature: "); // Label
Serial.println(OiltempC); // to output the converted temperature to USB
*/
int OilTempSensorPin = A0; // engine oil temp sensor pin
int OilTempSensorValue = 0; // variable to store the value coming from the sensor
int GearTempSensorPin = A1; //gearbox temperature sensor pin
int GearTempSensorValue = 0; // variable to store the value
int DiffTempSensorPin = A2; //differential temperature sensor pin
int DiffTempSensorValue = 0; // variable to store the value
int OilPressureSensorPin = A3; //engine oil pressure sensor pin
int OilPressureSensorValue = 0; // variable to store the value
int TurboPressureSensorPin = A4; //turbo pressure sensor pin
int TurboPressureSensorValue = 0; // variable to store the value
void setup() {
Serial.begin(115200);
}
void loop() {
// read the value from the oil temperature sensor:
OilTempSensorValue = analogRead(OilTempSensorPin);
Serial.print("Oil Temperature: ");
Serial.println(OilTempSensorValue); //Print the value of pin A0
// read the value from the GearTemp sensor:
GearTempSensorValue = analogRead(GearTempSensorPin);
Serial.print("Gearbox Temperature: ");
Serial.println(GearTempSensorValue); //Print the value of pin A1
// read the value from the differential temperature sensor:
DiffTempSensorValue = analogRead(DiffTempSensorPin);
Serial.print("Diff Temperature: ");
Serial.println(DiffTempSensorValue); //Print the value of pin A2
// read the value from the oil pressure sensor:
OilPressureSensorValue = analogRead(OilPressureSensorPin);
Serial.print("Oil Pressure: ");
Serial.println(OilPressureSensorValue); //Print the value of pin A3
// read the value from the turbo pressure sensor:
TurboPressureSensorValue = analogRead(TurboPressureSensorPin);
Serial.print("Turbo Pressure: ");
Serial.println(TurboPressureSensorValue); //Print the value of pin A4
Serial.println("");
delay(2000);
}
Any insights and help greatly appreciated!
Cheers,
Joe