Board: esp32

I know my wiring is correct because I get data from the sensor, but the data is a bit weird.

At 22 celcius I get 140, even though if I do the voltage calculation (* 0.473372) it still doesn't work.

the number 0.473372... comes from taking the voltage 4.7v / 1024 * 1000 / 10

My code:

 Serial.print("temp: ");
 float temp = (analogRead(A13) * 0.473372781065088);

Any answers?

  • 1
    What is the voltage into the analog input when you get that reading? Explain why you multiply by 0.473. Show your schematics. I think the LM35 needs decoupling capacitors (if I remember correctly). Have you omitted them? Add the info into your question - not in the comments.
    – Transistor
    Mar 19 '19 at 12:23
  • 3
    Your "conversion" from ADC value to temperature looks far too simple. You have to convert the ADC value to volts, then from the voltage you can calculate the temperature. This is a simple excercise, and a quick google search turns up examples (with explanations) for using the LM35 with an ESP32.
    – JRE
    Mar 19 '19 at 12:36
  • 1
    What JRE says: remember that 0 = 0 V but 1023 = VCC (unless you chose a different reference voltage). Mar 19 '19 at 12:38
  • qustion is now updated
    – user216002
    Mar 19 '19 at 12:42
  • 2
    You write an answer detailing what was wrong and how you fixed it (for the benefit of people in the future that have the same problem), wait the prescribed period, then accept it as the right answer.
    – Majenko
    Mar 19 '19 at 14:14

ok, the problem is that i used to the wrong voltage conversion, just use:

RawValue = analogRead("your analog input pin");
Voltage = (RawValue / 2048.0) * 3300;

this should print the tempeture in celcious


enter image description here try this one i have worked with lm35 using this code and circuit. i have done this thing with arduino uno but you can try it with esp32

  • i dont need the sensor to measure minus decrease, so i use a diffrent setup
    – user216002
    Mar 21 '19 at 11:52

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.