help modifying sketch for different sensor

I am working on a sketch that uses a temp sensor along with an ESP-12 NodeMCU board. The sketch works fine, sending data to Ubidots, but the sensor data is incorrect. The sketch uses the DallasTemperature.h library but I am using a TMP36 sensor on pin A0 (TMP36.h library). I want to either modify the current sketch or locate another project that will work with my hardware and send accurate data to Ubidots.

Any guidance is appreciated

Current sketch:

/****************************************
 * Include Libraries
 ****************************************/
#include "UbidotsESPMQTT.h"
#include <OneWire.h>
#include <DallasTemperature.h>
/****************************************
 * Define Constants
 ****************************************/
#define TOKEN "xxxx" // Your Ubidots TOKEN
#define WIFINAME "xx" //Your SSID
#define WIFIPASS "xxx" // Your Wifi Pass
#define MQTTCLIENTNAME "xxxx" // Your MQTT Client Name, it must be unique so we recommend to choose a random ASCCI name
#define Pin A0

float temp;
OneWire ourWire(Pin);
DallasTemperature sensors(&ourWire);

Ubidots client(TOKEN, MQTTCLIENTNAME);
/****************************************
 * Auxiliar Functions
 ****************************************/
void callback(char* topic, byte* payload, unsigned int length) {
  Serial.print("Message arrived [");
  Serial.print(topic);
  Serial.print("] ");
  for (int i=0;i<length;i++) {
    Serial.print((char)payload[i]);
  }
  Serial.println();
}
/****************************************
 * Main Functions
 ****************************************/
void setup() {
  // put your setup code here, to run once:
  Serial.begin(115200);
  client.wifiConnection(WIFINAME, WIFIPASS);
  sensors.begin();
  client.begin(callback);
  }
void loop() {
  // put your main code here, to run repeatedly:
  if(!client.connected()){
      client.reconnect();
      }
  
  sensors.requestTemperatures();       //Prepare the sensor for reading
  
  temp = sensors.getTempCByIndex(0);
  
  Serial.print(sensors.getTempCByIndex(0)); //Read and print the temperature in Celsius
  client.add("temperature", temp); //Insert your variable Labels and the value to be sent
  delay(1000);
  Serial.println("Grados Centigrade");
  client.ubidotsPublish("control");
  
  client.loop();
  }

Hi,

Your code is for DS18B20 type electronic temperature sensor..

You need to get that type sensor or learn how to modify your code for the TMP36.

Yes, my post is asking for assistance in modifying the code to work with the TMP36 sensor

try this link

Arduino TMP36

I always appreciate such helpful advice on forums. Why didn't I think of that?

good grief!