Computer/Laptop Temperature Monitor USB With Optional Alarm

by foxxtrotalpha in Circuits > USB

8586 Views, 19 Favorites, 0 Comments

Computer/Laptop Temperature Monitor USB With Optional Alarm

SDC11018 - Copy.JPG

This instructable will show you how to construct your own Laptop/ desktop temperature monitor, with optional alarm that will trigger a piezo buzzer for an audible notification. After completing this project, you can use the device to monitor other temperatures such as indoor/outdoor temperatures.

Parts List

SDC11017.JPG
SDC11018.JPG
- USB Port
- Arduino
- Arduino IDE
- MAXIM DS18s20 1-WIRE Digital thermometer
- Standard 16x2 LCD
- 10k Resistor
- 10k Potentiometer
- Breadboard
- hookup wire/ Jumpers for breadboard
- one wire library from:

pjrc.com/teensy/td_libs_OneWire.html

--Optional:
Piezo buzzer



Overview

In this tutorial, we will be using a Maxim DS18S20 digital thermometer to read the temperature of a laptop/desktop computer. The DS18S20 is a 1-Wire device, which minimum connections only require a data line and ground in parasite mode, or +5V, GND, and data in regular mode. This device is great because it comes in a small TO-92 package and only requires one pin on the Arduino to transmit and receive data. We will be using the One Wire library from PJRC website (link to the download will be in the "Parts" step).  A 10k pullup resistor for the thermometer will be used, the data sheet calls for a 5K, but 10k seems to work fine, and is what I had readily available in my parts bin. Additional DS18S20's can be put in parallel to have multiple readings of different areas.

When completed, this circuit will display the temperature reading in both Fahrenheit and Celsius in a whole number.  If chosen, an audible alarm will sound if the reading reaches a predefined alarm temperature, and will continue to sound while the reading is above the alarm temperature. 

Since this tutorial is about the temperature sensor, I will not be going much into detail about connecting the LCD display.
-Piezo buzzer is optional.


Wiring Up the Connections!

breadboard_temp_sensor.jpg
Connections are as follows:

Arduino [+5v output]   to  Positive power rail on breadboard
Arduino [GND]  to Ground rail on breadboard

DS18s20 [VDD]  to  power rail on breadboard
DS18s20 [GND] to ground rail on breadboard
DS18s20 [DQ]  to digital pin 10 on Arduino
10K&
resistor from  DS18s20 [DQ] pin to +5v power rail on breadboard

With pins on the LCD display facing up, Leftmost pin 1, rightmost pin 16

LCD pin 1 to ground
LCD pin 2 to +5v rail on breadboard
LCD pin 3 to wiper (center) pin on 10k pot
LCD pin 4 to Arduino digital pin 2
LCD pin 5 to ground on breadboard
LCD pin 6 to Arduino digital pin 3
LCD pin 11 to Arduino digital pin 7
LCD pin 12 to Arduino digital pin 6
LCD pin 13 to Arduino digital pin 5
LCD pin 14 to Arduino digital pin 4
LCD pin 15 to +5v rail on breadboard
LCD pin 16 to ground rail on breadbaord

10k pot leftmost pin to ground
10k pot center pin to LCD pin 3 (already mentioned)
10k pot rightmost pin to +5v rail on breadboard

Optional:


Piezo [Positive] to Arduino digital pin 13
Piezo [Negative] to ground







Find Your DS18s20 Unique Address

Serial_read_address.jpg
Now that you have everything wired up, its time to find your DS18s20's unique address. Each one wire device has its own unique address, So it is important to remember this when talking to any 1 wire device as they will only respond after being properly addressed.

Before opening the sketches provided, make sure you have installed the 1 wire library in correct directory for your Arduino to recognize it. For me, its in the following folder:

arduino-0022\arduino-0022\libraries

Once you have installed the library,  its time to read the address from your device. Open up the

Roguelabz_1Wire_Temp_addr_finder sketch.

This sketch is written to show your devices address and nothing more. I wrote it to have the bare minimum to minimize confusion for anyone that would like to see how to the sketch works.

- Upload the sketch to your Arduino, make sure the USB is plugged in

When it is done uploading,  You won't see anything on the LCD display. Thats fine for now.
Open up the serial monitor on the IDE, and it will display your device's address in hex, with the "0x" subscript.
Highlight the entire line that contains the address, and press CTRL + C to copy


( your screen should look similar to this image)

Heart of the Code

Now that you have run the first sketch, and copied your device's adress, we can move on the the main code of this project,
Roguelabz_1Wire_S_temp_display


Open up the sketch, and you will see within the first few lines,  " byte address[8] = {INSERT COPIED ADDRESS HERE}; "

Delete the part that says "insert copied address here" and press CTRL + V to paste your address,  or you can right click and select paste. Be sure that when you paste your address, it does NOT run off to the next line like this:

byte address[8] = {0x10, 0x79, 0xB0, 0x3F, 0x2, 0x8, 0x0, 0x51
}; // Address of our one wire device

Not a big deal if it does . Just simply click right before the } bracket, and press backspace once and it will return to a single line of code

byte address[8] = {0x10, 0x79, 0xB0, 0x3F, 0x2, 0x8, 0x0, 0x51};

Now that you have pasted your address, upload the sketch to your Arduino, when it is done uploading, you should see the temperature displayed in the bottom row of the LCD display, in both Fahrenheit and Celsius.

In addition to the LCD display, you can monitor the temperature via USB by cliking the Serial Monitor in the IDE, and the temperature will also be displayed there. When the Alarm temperature is reached, a  "!Warning!" will be displayed on the serial monitor.

If you would like the audible alarm,  connect the piezo buzzer to pin 13 and ground. Scroll down to the bottom of the code, and find the alarm temperature. I commented on the line where this is located. Simply change the value to one of your desire, and the alarm will be triggered once this temperature has been reached, and will continue to alarm while the temperature is above this limit.  The piezo is optional, but you can also substitute the piezo for an LED for a visual alarm, or have nothing connected for no alarm.


How the Code Works


Now that you have a working temperature display and alarm, you might want to tweak the provided code, or would just like to know how 1 wire works. Its actually very simple.

First specify the pin your devices will be connected to, and name the pin:


OneWire myWire(10)  This makes "mywire" on pin 10

OneWire yourWire(10)
OneWire theirWire(9)

both of these would also be correct

To begin using a 1 wire device,  you must first find its address.

Before making any type of communication with a 1 wire device,  you must first initialize the devices on the bus with a reset pulse.
A reset pulse is requires for each set of instruction to the device.


myWire.reset()   (myWire is substituted with the name you assigned  in the above step. ex. yourWire.reset();

After the initialization reset pulse, you select your specific device with:

yourWire.select(address aray);

- Now that you initialized and selected your device. You can issue a ROM command, followed by a Function command using

yourWire.write();

Don't forget! after each set of instructions, you must reissue the initialization sequence, reset pulse, and address the specific device to be communicated with.

In summary:

1. Initialize
2. Rom Command
3. Function command
4. data exchange( for some function commands)



Put It to Use!


After you have constructed a working circuit on the breadboard, you can put it in a project box, and solder on a length of wire to the thermometer, and place the thermometer in your computer tower, or next to the exhaust vent on your laptop. 

Here is a video of my circuit put to use, monitoring the temperature of my computer. I set the alarm temperature at only 90 degrees Fahrenheit, just to demonstrate the circuit in action. The audio seemed to have lowered during the conversion process of the video.

Downloads