Hello all,
I am struggling with reading data via analogue inputs of Arduino Uno connected with a basic temperature sensor.
Board Model: XC-4410 Duinotech Uno R3
Temperature Sensor: MCP9700 TO92
Sketch:
int tempPin = A2;
int tempReading;
void setup() {
analogReference(EXTERNAL);
Serial.begin(9600);
}
void loop() {
tempReading = analogRead(tempPin);
Serial.println(tempReading);
float voltage = (tempReading) * (3300 / 1024);
float temperatureC = ((voltage - 500) / 10);
Serial.println(temperatureC);
delay(2500);
}
Connections:
Board powered via USB (however, I have tried using a 12VDC power supply but same issue)
Sensor: VDD to 3.3V, VOUT to Analog Pin 2 and GND to ground
PROBLEM:
The problem is that no matter what analog pin I use and even if I disconnect the temperature sensor completely, the serial output reads 1023 as voltage output from Pin A2. Fluctuating the temperature has no affect on the readings. However, when the temperature sensor is connected, I used a multi-meter and it shows that as temperature changes, the voltage changes accordingly. So this tells me that temperature sensor is working but serial output is not.
What I have already tried:
- The board is not shorted and is working fine (checked all analogue connections including AREF with multi-meter's continuity test)
- Tried 12VDC power supply along with USB connection to read the serial output (but no luck)
- Tried removing and inputting the analogue command analogReference(EXTERNAL); (but no luck)
- Tried using a different Arduino board like DUE and EtherMega (but no luck)
- Tried copying and pasting example code from GITHUB, Arduino Forums and other websites (but no luck)
- Tried ALL the analog pins from A0 to A5 (but same result)
Questions I have:
- Is the program correct for Arduino Uno?
- Do I need any type of resistor to make it work?
- What I am doing wrong?
All help is much appreciated guys and gals. By the way my experience and status with electronics and Arduino is "noob". I am a mechanical engineer trying to learn.
Cheers,
Muhammad