I have moved the MCU of the Arduino to a breadboard using these steps https://www.arduino.cc/en/Main/Standalone then interfaced it with an LM35 temperature sensor to the ADC0. But I can't get proper values from the LM35. I think it's because of the Aref or AVcc. Both are just connected to +5? Here is my code:

float tempC;
float reading;

void setup()

void loop()
    reading = analogRead(0);
    tempC = (reading * 0.4882815) + 5;

I get hex values and sometime high values. What to do with Aref and AVcc?

EDIT: I get values like these € Œ

  • Hex values? Can you copy and paste some of them into your question please? – Nick Gammon Feb 16 '16 at 3:41
  • I get values like € Œ – SG Villarias Feb 16 '16 at 4:01
  • 1
    Well, that isn't hex, that's mumbo-jumbo. I suspect you are not operating at the correct clock rate. Do you have a crystal on your breadboard? If so what frequency is it? If not, how do you have the fuses configured? – Nick Gammon Feb 16 '16 at 5:05
  • Yes I have a crystal. It says 22.000C16 at the top. I thought I bought a 16MHz oscillator. Now I'm doubting. So you think it's the crystal oscillator's fault? – SG Villarias Feb 16 '16 at 5:43
  • 1
    Well, if it worked on the Arduino board, but not on your breadboard. Make a simple test, like flashing an LED every ten seconds. Time how quickly it flashes on your breadboard. – Nick Gammon Feb 16 '16 at 6:34

Check the baud rate of your serial monitor matches what you have set in your setup() function. In the above code that is 9600. If the baud rate is incorrect you typically get rubbish output in the serial monitor.

Serial Monitor set at 9600 baud

You may also want to change the Serial.print(tempC) to


To get some decimal places.

As for the circuit ~

Ricardo Sequeria's example Arduio & LM35

  • You don't need ARef connected.
  • The LM35 VCC should be connected to Arduino 5V
  • The LM35 GND to Arduino Gnd (any of them)
  • Finally LM35 signal (Vout) to Arduino A0.
  • Thanks for answering but my baud rate is correct and adding ",2" did not help :( – SG Villarias Feb 16 '16 at 4:56
  • Hanging ARef didn't change anything. The next three steps I did already. Nothing changed – SG Villarias Feb 16 '16 at 5:42
  • @user5434720 - Your circuit looks like the diagram right? – Kingsley Feb 16 '16 at 5:49
  • No sir since I moved the MCU to a breadboard. I'm not using the Arduino board anymore – SG Villarias Feb 16 '16 at 6:53

clearly it's not flashing every second.

Is it flashing about every .73 seconds? That would be the period you'd expect if you have a 22.000MHz crystal: period = (16/22 * 1.00 sec). (If so, that is a rather high over-clock rate for the chip but suggests just how hardy they really are.)

I haven't bought any 16 MHz crystal. What will I do?

Buy a 16MHz crystal. That's the right fix. But you might (if I guessed correctly that you have a 22MHz crystal) - might - get away with trying a baud rate of (16/22) times your present baud rate, de-rating it to compensate for the clock rate. Be as precise as you can. You'll need to reprogram the chip with your Arduino board because the chip's bootloader expects a 16MHz clock.

Or, if it's not 22MHz, you could time a number of blinks (50 or 100), calculate the clock rate error, and re-calculate a baud rate the way I did above. Use a lower baud rate to start with; it is likely to be less affected by small timing errors.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.