This is how i wired the thermistor and buzzer:


simulate this circuit – Schematic created using CircuitLab

And the code:

#define RT0 10000
#define B 3977
#define R 10000
float RT, VR, ln, TX, T0, VRT;

void setup() {
  T0 = 25 + 273.15;

void loop() {
  VRT = analogRead(A3);
  VRT = (5.00 / 1023.00) * VRT;
  VR = 3.3 - VRT;
  RT = VRT / (VR / R);
  ln = log(RT / RT0);
  TX = (1 / ((ln / B) + (1 / T0)));
  TX = TX - 273.15;

When i connect the buzzer it causes a bit of voltage drop which messes with temperature reading, How can i get a steady temperature reading while having a buzzer in the circuit?

  • Use the output of the LF33CV as your AREF?
    – Majenko
    Aug 26, 2019 at 10:56
  • How much is the voltage dropping? Can you simply use a power source, that can handle the buzzers current, without dropping the voltage? And in your schematics the buzzer is connected permanently, so the voltage drop should be consistent, which means, that you would be able to work around it by measuring the resulting voltage and include that in your calculations
    – chrisl
    Aug 26, 2019 at 10:58
  • @Majenko how? connect the 3.3V to the AREF pin AND thermistor? Aug 26, 2019 at 11:38
  • @chrisl i didn't measure the voltage drop but it should be ~1V, it's an active buzzer. buzzer is controlled with MCU, i just didn't add that to the schematic... Aug 26, 2019 at 11:41
  • 1
    @newbie Yep. and set analogReference(EXTERNAL); -- arduino.cc/reference/en/language/functions/analog-io/…
    – Majenko
    Aug 26, 2019 at 12:56

2 Answers 2


You can use the output of your regulator as the reference voltage for your analog readings. That way, no matter what the voltage you voltage divider for the thermistor uses, the "upper" voltage that the ADC uses is always the same as the thermistor's voltage.

Simply connect the output of the regulator to the AREF pin, and set the ADC to use the external voltage reference:


Now you have the range 0-1023 covering 0-3.3V (or whatever the voltage is the regulator is outputting), and because the output of your voltage divider is just a ratio of that voltage, that ratio will always be a ratio of 1023, regardless of what the voltage happens to be.

You have, in effect, removed the voltage from the equation. All you are left with is the value as a fraction of 1023, which is then directly proportional to the resistance of the thermistor.

  • I did just what said and the reading is steady even with voltage drop, a side question; in this line VR = 3.3 - VRT; voltage is defined 3.3V but i'm getting false reading with that and have to change it to VR = 5 - VRT;. isn't AREF voltage and the voltage on the thermistor/resistor voltage divider 3.3V? why i have to define it 5V to get proper temperature reading? Aug 26, 2019 at 15:57
  • 1
    Because in the line before you have 5v for the voltage. Change that to 3.3v.
    – Majenko
    Aug 26, 2019 at 16:10
  • 1
    Stability doesn't matter for this application. Nor does the voltage. You could use any voltage that is within spec of the ADC and the results will be the same. You only care about an accurate Vref if you are comparing something external to that Vref. You're not. You're just looking at a ratio of two resistors between Vref and GND. The formula for R2 can be reduced to just (A * 10000) / (1023 - A) where A is the value read from the ADC. There's no voltage in there at all. It all cancels out.
    – Majenko
    Aug 27, 2019 at 20:41
  • 1
    @newbie Maybe you should be addressing why you are getting a voltage drop instead of trying to compensate for it.
    – Majenko
    Aug 27, 2019 at 21:31
  • 1
    Yeah. And provide a full detailed schematic.
    – Majenko
    Aug 27, 2019 at 21:54

Take the regulator output to another analog input. Read that just before you read the thermistor. Use that voltage in your voltage divider calculation. The buzzer activity should be the same (ideally, off) during both readings.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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