TMP36 returns a value of 90 C. while the Real Temperature is 30 C


#1
  • Device & model Arduino Uno with W5100 ethernet shield

  • What dashboard are you using? Web

I am trying to set a simple temperature sensor, following exactly the instructions of the tutorial, but, any try, return the same problem…the dashboard sensor is marking a temperature of 90 C degrees while the real one is 30 ( measured on the head of the TMP36 sensor with a laser thermometre…
when I put one finger on the sensor, the temperature on the dash is rising, and when I remove the finger the temperature return to the original 90 C degrees… it looks like it is an issue of parametres…where do I have to change some number?..

many thanks for your help

Code:

    #define CAYENNE_PRINT Serial   // Comment this out to disable prints and save space
    #include <CayenneTemperature.h>

    // If you're not using the Ethernet W5100 shield, change this to match your connection type. See Communications examples.
    #include <CayenneEthernet.h>

    // Cayenne authentication token. This should be obtained from the Cayenne Dashboard.
    char token[] = "gmm9dtoz0j";

    // Virtual Pin of the TMP36 widget.
    #define VIRTUAL_PIN V1

    // Analog pin the TMP36 is connected to.
    const int tmpPin = 0;

    // Voltage to the TMP36. For 3v3 Arduinos use 3.3.
    const float voltage = 5.0; 

    TMP36 tmpSensor(tmpPin, voltage);

    void setup()
    {
    	Serial.begin(9600);
    	Cayenne.begin(token);
    }

    void loop()
    {
    	Cayenne.run();
    }

    // This function is called when the Cayenne widget requests data for the Virtual Pin.
    CAYENNE_OUT(VIRTUAL_PIN)
    {
    	// This command writes the temperature in Celsius to the Virtual Pin.
    	Cayenne.celsiusWrite(VIRTUAL_PIN, tmpSensor.getCelsius());
    	// To send the temperature in Fahrenheit or Kelvin use the corresponding code below.
    	//Cayenne.fahrenheitWrite(VIRTUAL_PIN, tmpSensor.getFahrenheit());
    	//Cayenne.kelvinWrite(VIRTUAL_PIN, tmpSensor.getKelvin());
    }

#2

It seems that you are not converting your measurements.
Can you try this:

void setup()
{
  Serial.begin(9600);
  Cayenne.begin(token);
}
 
void loop()             
{
 //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 * 5.0;
 voltage /= 1024.0; 
 
 // print out the voltage
 Serial.print(voltage); Serial.println(" volts");
 
 // now print out the temperature in Celsius
 float temperatureC = (voltage - 0.5) * 100 ;  //converting from 10 mv per degree wit 500 mV offset
                                               //to degrees ((voltage - 500mV) times 100)