Monitor Temperature
Arduino

Preliminary Discussion

A common function of network management is to monitor the environment in the network equipment rooms. Things to watch are temperature, humidity, smoke, entry into the room, and so on. This can be done by purchasing devices that incorporate various sensors and notification methods. In this lab we will see how these devices do what they do as well as learn how to create such a device.

Setup

The following equipment is needed for this lab:

Video camera that can stream video to a computer for display by a projector

The following parts are needed for this lab:

Arduino Uno Board

USB A B Cable

TMP36 Temperature Sensor

Green LED

Yellow LED

Red LED

Three 220 Ohm Resisters

Solderless Breadboard

Eight Jumper Wires

Arduino Case

This program is required:

Arduino IDE

Here is the layout of the parts:

and the schematic view

The active components used for this lab perform the following functions:

The Arduino Uno board reads the input from the sensor and then outputs it. In this example we see it in two forms of output, it lights the LEDs and it displays alphanumeric information on the screen.

The temperature sensor reports a voltage level that changes as the temperature around it changes. We will use that voltage level to indicate the temperature. According to its datasheet the TMP36 sensor is a low voltage, precision centigrade scale temperature sensor. It provides a voltage output that is linearly proportional to the Celsius or centigrade temperature. It does not require any external calibration to provide typical accuracies of ±1°C at +25°C and ±2°C, over the −40°C to +125°C temperature range.

The LEDs are used to indicate the temperature level.

The resister between each LED and the electrical flow are used to remove some of the energy before it reaches the LED as too much energy will burn it out. The resister turns part of the energy it receives into heat.

Assemble the Parts

Now that we have all of the pieces of the lab, let’s assemble them. You can see how I do this by watching the camera view projected on the screen. The finished system looks like this:

Let’s apply power to the system by plugging in the USB cable. The B end attaches to the Arduino board and the A end to a powered USB port.

When powered on the green - power light - on the Arduino board will illuminate.

Load the Code

So that the parts can talk to each other and to us, we need to transfer Arduino specific code to the Arduino board. This is done by using a program called IDE that is supplied by Arduino for this purpose.

The code can be entered directly in the IDE program or in Notepad and then copied and pasted into IDE.

Here is the code:

const int sensorPin = A0;

const float baselineTemp = 20.0;

void setup(){

Serial.begin(9600);

for(int pinNumber = 2; pinNumber < 5; pinNumber++){

pinMode(pinNumber, OUTPUT);

digitalWrite(pinNumber, LOW);

}

}

void loop(){

int sensorVal = analogRead(sensorPin);

Serial.print("Sensor Value: ");

Serial.print(sensorVal);

float voltage = (sensorVal/1024.0)*5.0;

Serial.print(", Volts: ");

Serial.print(voltage);

Serial.print(", degrees C: ");

float temperature = (voltage - .5)*100;

Serial.println(temperature);

if(temperature < baselineTemp){

digitalWrite(2, LOW);

digitalWrite(3, LOW);

digitalWrite(4, LOW);

}

else if(temperature >= baselineTemp+2 & temperature < baselineTemp+4){

digitalWrite(2, HIGH);

digitalWrite(3, LOW);

digitalWrite(4, LOW);

}

else if(temperature >= baselineTemp+4 & temperature < baselineTemp+6){

digitalWrite(2, HIGH);

digitalWrite(3, HIGH);

digitalWrite(4, LOW);

}

else if(temperature >= baselineTemp +6){

digitalWrite(2, HIGH);

digitalWrite(3, HIGH);

digitalWrite(4, HIGH);

}

delay(1);

}

This code lights the green LED, then as the temperature goes up, the yellow LED, and the red LED.

The code is copied to the IDE program.

It is verified by clicking this button.

Once verified, it is uploaded to the Arduino board using this button.

Watch the Result

With the code loaded on the Arduino board, the green LED turns on.

If we increase the heat sensed by the temperature sensor the yellow LED will come on.

With enough heat the red LED will turn on

What if we want to display the measured temperature? We can send the numbers out the serial interface of the Arduino board by clicking on this icon.

The output looks like this with the green LED on.

The yellow LED comes on.

The red LED lights.

The data could be sent the same way to a management program that would notify the network administrator that the temperature in the room was exceeding preset limits.

Source

The basic procedure used here is from the Arduino temperature sensor procedure in the book Arduino Projects Book.

12

Copyright 2014 Kenneth M. Chipps Ph.D. www.chipps.com