TMP36 clone vs genuine

This falls under the “For whatever it’s worth” category (see pic).

Used the code (second one) from…

One, far more accurate than the other for my room temp, neither very precise.


For the Uno…
With 3.3volt Aref, TMP36, and a temp of ~70F, you’re using about 20% of the A/D.
That’s about 200 A/D values.
Yet you expect the readout to display e.g. 68.46F (6,846 values).
No experience with the Due (12-bit A/D). It should return ~850values, so still not enough to display with 2 decimal places.

The way Adafruit wants you to connect Aref to the 3.3volt pin is potentially dangerous for the Aref pin if the wrong code is loaded. See the warning on the Aref page in the reference section.

If you are happy with a max temp readout of ~130F, try my code.
Remove the link between 3.3volt and Aref. This code doesn’t use 3.3volt Aref. It uses the more stable internal 1.1volt bandgap Aref. Play with the decimal place printout if you like.
You must calibrate, because the 1.1volt Aref is different on every board.
Not sure if the code will run ok on the Due.

// TMP36 temp sensor output connected to analogue input A0
// power pin connected to 3.3volt

unsigned int total; // A/D readings
float tempC; // Celcius
float tempF; // Fahrenheit
float FF = 0.001632; // fudge factor for temp calibration | change last one or two digits and re-uplooad 

void setup() {
  analogReference(INTERNAL); // use the internal ~1.1volt bandgap reference | change to (INTERNAL1V1) for a Mega

void loop() {
  // read the sensor
  for (int x = 0; x < 64; x++) { // 64(max) analogue readings for averaging
    total = total + analogRead(A0); // add each value
  // temp conversion
  tempC = total * FF - 50.0;
  tempF = tempC * 1.8 + 32; // Celcius to Fahrenheit

  Serial.print("The temperature is  ");
  Serial.print(tempC, 1); // one decimal place
  Serial.print(" Celcius  ");
  Serial.print(tempF, 0); // no decimal places
  Serial.println(" Fahrenheit");

  total = 0; // reset total
  delay(1000); // slows readings

Thanks for the tip!