Help with Arduino Program

I have tmp36 temperature sensor. I can get it to work fine in Adrion but everything I tried in esphome doesn’t work. I have d1 mini with tmp36 sensor.
Here is the code that works in Adrino.
I just want gauge in my dashboard. I have bme280 working fine.
Screenshot (38)
Any help would be great.
Sorry in advance first post.

<sub>//TMP36 Pin Variables

int sensorPin = 0; //the analog pin the TMP36's Vout (sense) pin is connected to

                        //the resolution is 10 mV / degree centigrade with a

                        //500 mV offset to allow for negative temperatures

/*

 * setup() - this function runs once when you turn your Arduino on

 * We initialize the serial connection with the computer

 */

void setup()

{

  Serial.begin(9600);  //Start the serial connection with the computer

                       //to view the result open the serial monitor

}

 

void loop()           // run over and over again

{

 //getting the voltage reading from the temperature sensor

 int reading = analogRead(sensorPin);  

 // converting that reading to voltage, for 3.3v arduino use 3.3

 float voltage = reading * 3.0;

 voltage /= 1024.0;

 // print out the voltage

 Serial.print(voltage); Serial.println(" volts");

 // now print out the temperature

 float temperatureC = (voltage - 0.5) * 100 ;//converting from 10 mv per degree wit 500 mV offset

 //to degrees ((voltage - 500mV) times 100)

 Serial.print(temperatureC); Serial.println(" degrees C");

 // now convert to Fahrenheit

 float temperatureF = (temperatureC * 9.0 / 5.0) + 32.0;

 Serial.print(temperatureF); Serial.println(" degrees F");

 delay(10000); //waiting a second

}`Preformatted text`</sub>

is the sensor with a adc to serial converter or is it the sensor itself just adc for then use A0?

like this,


sensor:

  • platform: adc
    pin: A0
    name: “TemperatureC”
    update_interval: 60s

else if it is serial then have a look here please.

I will try it when I get home.
Thank you for the response, I haven’t been on here in while I kinda of gave up on these sensors.
I will let you know how it works out Thank you again.