How to read data from Temperature Sensor TMP37

Hi there, I am trying to use Cayenne with my temperature sensor. Similar to TMP36 but it is TMP37, i cant seem to run my program to dashboard as it is not of the same sensor so am i suppose to change something on my code or customize my widget? Thanks in advance.

Hi,
The sensor is not the problem. The TMP37 is the same as the TMP36 except:
“The TMP37 is intended for applications over the range of 5°C to 100°C and provides an output scale factor of 20 mV/°C.”

In fact with not sensor attached, you should still see “data” as the output is analogue.

Check code and wifi/ethernet connection

1 Like

@p_heelan I tried using the codes but I can’t seem to make Cayenne read my data. May i know why?

It would be helpful if you post your code and then we can go from there :slight_smile:

-B

hi there @bestes,

here’s my 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>
#include <CayenneWiFi.h>

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

char ssid[] = "SSID" ;
char password[] = "PASSWORD" ;

// 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; 

//must i change TMP36 to TMP37?
TMP36 tmpSensor(tmpPin, voltage);

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

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());
} 

may I know am i suppose to change the TMP36? I am very new to this, I hope you can guide me along. Thanks in advance!

Hi @nurhazirh ,

We actually have a guide specifically for connecting a TMP36 sensor to an Arduino! You can read about it here:

http://www.cayenne-mydevices.com/docs/#getting-started-arduino-sensors

Hope this helps!

-B