Lesson 3: Displaying TMP36 Temperature Sensor Reading


Written by Jonathan Sim

You can find this lesson and more in the Arduino IDE (File -> Examples -> Andee). If you are unable to find them, you will need to install the Andee Library for Arduino IDE.

Works on iOS and Android
In this lesson, I'll show you how to connect the TMP36 temperature sensor to the Annikken Andee and how to code it to display the current temperature reading.

Here's a peek at what the user interface will look like when you're done:



Wiring Instructions


Vcc Pin - Connect it to both +3.3V source and AREF Pin of your Arduino

Vout Pin - Connect it to your analog input pin (A0 to A5)

GND Pin - Connect it to GND

You may notice that some websites have omitted the AREF connection. I strongly recommend using AREF as it will increase the accuracy of your readings.

Top of the Code

Always include these libraries. Annikken Andee needs them to work with the Arduino!

#include <SPI.h>
#include <Andee.h>

// We'll create two display boxes to display temperature in different units
AndeeHelper tempDisplayC; // Temp in deg C
AndeeHelper tempDisplayF; // Temp in deg F

// We'll use Analog Input Pin A0 to read our analog input.
// Change the pin number if you are using another pin.
const int tempInputPin = A0;

// To store the temperature reading
float degC;
float degF;


The setup() function is meant to tell Arduino what to do only when it starts up.

void setup()
  Andee.begin();  // Setup communication between Annikken Andee and Arduino
  Andee.clear();  // Clear the screen of any previous displays
  analogReference(EXTERNAL); // Tell Arduino that we're using an external analog reference
  // This will help give you a better temperature reading.
  setInitialData(); // Define object types and their appearance


This is the function meant to define the types and the appearance of all the objects on your smartphone

void setInitialData()
  // Only one display box this time
  tempDisplayC.setId(0);  // Each object must have a unique ID number
  tempDisplayC.setType(DATA_OUT);  // This defines your object as a display box
  tempDisplayC.setLocation(0, 0, FULL); // Sets the location and size of your object
  tempDisplayC.setData(""); // We'll update it with new analog data later.
  tempDisplayC.setUnit("deg C");
  tempDisplayF.setId(1);  // Each object must have a unique ID number
  tempDisplayF.setType(DATA_OUT);  // This defines your object as a display box
  tempDisplayF.setLocation(1, 0, FULL); // Sets the location and size of your object
  tempDisplayF.setData(""); // We'll update it with new analog data later.
  tempDisplayF.setUnit("deg F");  


Arduino will run instructions here repeatedly until you power it off.

void loop()
  // Read value from analog pin and store it in an int variable
  int reading = analogRead(tempInputPin); 
  degC = ( (reading * 3.3 / 1024.0) - 0.5 ) * 100; // Multiplying by 3.3V 
  degF = ( degC * 9.0 / 5.0 ) + 32.0;
  // Update displays with new reading. The additional ,1 at the end of setData() 
  // will instruct Andee to display values up to 1 decimal place.
  tempDisplayC.setData(degC, 1);  
  tempDisplayF.setData(degF, 1); 
  // A short delay is necessary to give Andee time to communicate with the smartphone
comments powered by Disqus