A4 and A5 pins broken ?

Hello everybody ! :)

I need for a project to have a temperature sensor. But my analog pins from A0 to A3 are already used (I have 4 flex sensors connected to them). So I just wired my temperature sensor (TMP36) to the A4 pin. Here is my (very basic) code (which displays the temperature in Celsius) :

const int temperaturePin = A4;

void setup()
{
Serial.begin(9600);
}


void loop()
{
  float voltage;
  float degres;
  voltage = analogRead(temperaturePin) * 0.004882814; //converts the 0 to 1023 value to a 0 to 5 value
  degres = (voltage - 0.5) * 100.0;
  Serial.print("degres Celsius : ");
  Serial.println(degres);
  delay(1000);
}

But when I open my monitor, here is what I got :

degres Celsius : 295.21
degres Celsius : 295.21
degres Celsius : 295.21
degres Celsius : 295.21
degres Celsius : 295.21
degres Celsius : 295.70
degres Celsius : 295.21
degres Celsius : 295.21
degres Celsius : 295.21
degres Celsius : 295.21
degres Celsius : 295.21
degres Celsius : 295.21
degres Celsius : 295.21
degres Celsius : 294.73
degres Celsius : 295.21
degres Celsius : 295.21
degres Celsius : 295.21
degres Celsius : 295.21
degres Celsius : 295.70
degres Celsius : 295.21
degres Celsius : 295.21
degres Celsius : 295.21
degres Celsius : 295.70
degres Celsius : 295.21
degres Celsius : 295.21
degres Celsius : 295.70

So I tried to wire it to the A5 pin instead, and I got the [u]exact[/u] same results (obviously on my code I changed the first line and wrote A5 instead of A4). So I disconnected one of my flex sensor and tried to wire my temperature sensor one the A0 pin and I got good things on my monitor :

degres Celsius : 20.31
degres Celsius : 19.82
degres Celsius : 19.82
degres Celsius : 20.31
degres Celsius : 20.31
degres Celsius : 19.82
degres Celsius : 19.82
degres Celsius : 20.31
degres Celsius : 19.82
degres Celsius : 19.82
degres Celsius : 20.31
degres Celsius : 19.82
degres Celsius : 20.31
degres Celsius : 20.31
degres Celsius : 19.82

I tried also on my A1, A2 and A3 pins and I got the same results.

Can we conclude that my A4 and A5 pins are broken or did I miss something ?

And, I know the the circuit isn't wrong (because it's working correctly and displaying good numbers when wired to the A0 - A3 pins) but here is how I connected my TMP36 :

|500x352

Thanks for your help ! :)

do you have somerhing wired to SDA/SCL pins?

is your board a common Uno?

Hello Juraj and thanks for your answer :)

Juraj: do you have somerhing wired to SDA/SCL pins?

Yes I have a level converter connected to those 2 pins (and an accelerometer connected to this level converter, in order to do some level shifting). Does it change something ?

Juraj: is your board a common Uno?

It's a Uno R3 but not from Arduino (I bought a beginner kit on Amazon, the brand is named "Quimat"), but the pins are the same.

Thanks for your answer :)

Yes I have a level converter connected to those 2 pins (and an accelerometer connected to this level converter, in order to do some level shifting). Does it change something ?

A4 and A5 are also SDA and SCL

PaulJardin: Hello Juraj and thanks for your answer :)

Yes I have a level converter connected to those 2 pins (and an accelerometer connected to this level converter, in order to do some level shifting). Does it change something ?

It's a Uno R3 but not from Arduino (I bought a beginner kit on Amazon, the brand is named "Quimat"), but the pins are the same.

Thanks for your answer :)

then A4 and A5 are occupied because SDA and SDL are the same pins on Uno. you measure I2C pull-up

Thanks Juraj and AWOL for your answers. :)

But is there a way to use the SCL and SDA pins for my level converter but also use the A4 and A5 pins as analog pins for something else like temperature sensors for example ?

PaulJardin: Thanks Juraj and AWOL for your answers. :)

But is there a way to use the SCL and SDA pins for my level converter but also use the A4 and A5 pins as analog pins for something else like temperature sensors for example ?

no. if you use I2C you can't use A4 and A5 as analog pins. I2C is alternative function of this pins

Ok thanks Juraj.

That was unexpected. So I guess that I must use another Arduino Uno for my project.

Thanks for your answer :)

So I guess that I must use another Arduino Uno for my project.

Why do assume you need a different board? Troubleshoot the board you have, determine if the analog inputs work. Assumptions just compound mistakes. Did you measure the tmp36 output with a voltmeter?

You can easily test the Uno analog inputs with a potentiometer. Have a look here: https://www.arduino.cc/en/Tutorial/ReadAnalogVoltage

The tmp36 is actually a poor sensor used as shown due to very poor resolution. A approach is to use the Uno’s internal 1.1 volt analog reference which significantly increases the analog resolution, giving a reasonable result with such low output sensor.

Or, just forget about the tnp36 and go with the DS18B20 type one wire digital sensors which are usually a better choice.

PaulJardin: Hello everybody ! :)

I need for a project to have a temperature sensor. ....

So, does it need a temperature sensor that is separate from the Uno board? Or will the ATmega328P's internal temperature sensor work fine for you?

You could use an analogue multiplexer to squeeze all your analogue signals into just one analogue input of your Arduino.

Or use a nano or pro mini, they have A6 and A7 broken out as well.

You could also get an external adc breakout board.