Project tutorial
Sensing the temperature (S1.1)

Sensing the temperature (S1.1) © GPL3+

In this hands on lab you will build a simple circuit to calculate the temperature.

  • 8 views
  • 0 comments
  • 0 respects

Components and supplies

Apps and online services

About this project

Introduction:

In this hands on lab, you will build a temperature sensing device using the Arduino MKR1000.

This is the first in a series of hands on labs in the SMART Cities Program and introduces the basic concept of sensing the temperature.

Putting it together:

There are five parts to this tutorial:

  • Installing the Arduino IDE
  • Assembling the circuit
  • Loading and running the Sketch
  • Viewing the results

Part 1 - Installing the Arduino IDE

A quick tutorial for installing the plugin can be found Here

Part 2 - Assembling the circuit

Using the below wiring diagram as a reference assemble your device

Note:

  • The temperature sensor (TMP36) is connected to pin A0
  • When inserting the Temperature sensor make sure that the flat side is facing towards you.

Part 3 - Loading and running the Sketch

Now that you have a completed circuit you can load and run the sketch.

Verify and upload your code

Part 4 - Viewing the results

Having completed the programming of your device, now lets see the results by opening the serial monitor.

The Final Result

On completion the device will display the temperature in the Serial Monitor.

Code

Base CodeArduino
// Temperature Sensor
int sensorPin = A0;   // Sets A0 as the input pin for the sensor
int sensorValue = 0;  // initialise a variable to store the value coming from the sensor
int Dres = 1024;      // set max 10-bit digital value
int VCC = 3300;       // set VCC voltage milliVolts
int offset = 500;        // set tolerance of 500 milliVolts
int scaling = 100;         // set the voltage scaling at 10mM / deg C
float temperature = 0.0; // set the initial temperature as 0
float voltage = 0.0;     // set the initial voltage to 0

void setup() {
  Serial.begin(9600);
  // Set 10bit read resolution
  analogReadResolution(10);
}

void loop() {

  // read the value from the sensor:
  sensorValue = analogRead(sensorPin);
  Serial.print("sensorValue = ");
  Serial.print(sensorValue);

  // Calculate the voltage
  voltage = sensorValue * (VCC/Dres); // milliVolts
  Serial.print(" voltage = ");
  Serial.print(voltage);
  Serial.print(" VCC = ");
  Serial.print(VCC);

  // Calculate the temperature
  temperature = (voltage - offset ) / scaling;
  Serial.print(" temperature(C) = ");
  Serial.println(temperature);

  delay(1000);
}

Schematics

Circuit
Temp fritz bb wrqiwuemyf

Comments

Add projectSign up / Login