Arduino remote thermometer

As part of our course at Haaga-helia (held by Tero Karvinen – http://terokarvinen.com/2012/aikataulu-prototyypin-rakentaminen-bus4tn007-1) this is my final project. Our project actually as this was done with my classmate Niko. So what we did is a “remote” thermometer. Niko has a LM35 thermometer on his arduino which is connected to his computer. The arduino sends the temperature to the serial port, from where a python program uploads it to the net. My python program retreives the information and sends it to the arduino through the serial port. Depending on the temperature the arduino will move the “indicator” to the corresponding position.

What we used:

2x Arduino uno
a LM35 thermometer
a micro servo
5-6 jumper wires

a cardboard box
a dvd
a knife
tape

I used an Asus eee pc 901 (os: Ubuntu 12.04). Python came as default installation and the arduino ide is easy to install by opening the terminal and using the following commands:


sudo apt-get update
sudo apt-get install arduino

We started off by Connecting 2 arduinos to different computers in order to test our respective programs: transferring and receiving. You can find Niko’s code in his blog at http://nikokiuru.com/2012/05/oma-prototyyppi-hellemittari/. The blog is written in finnish so you might want to use an online translator.

and here is my code starting from the python code fetching the data from the internet:

import urllib2 # Connecting to the internet
import serial # serial port (usb)
import time

ser = None

ser = serial.Serial("/dev/ttyACM0")
print("Serial port " + ser.portstr + " opened.")

response = urllib2.urlopen('http://kiekkoliiga.net/~niko/lampomittari/') # get info
html=response.read() # save info
html=float(html)#convert string to float (also known as double)

if html>=30:
	ser.write("5")
	print("Receiving: %s" % html)
	print("Sending: 5")

elif html>=20:
	ser.write("3")
	print("Receiving: %s" % html)
	print("Sending: 3")	

elif html<20:
	ser.write("1")
	print("Receiving: %s" % html)
	print("Sending: 1")

And the actual arduino code:


#include <Servo.h>
char variable;
Servo servo;



void setup()

{

  Serial.begin(9600);

  //pinMode(13, OUTPUT); Test with a led. Now replaced with the servo.write -statements
  servo.attach(13);

}



void loop()

{

  if(Serial.available() > 0)

  {

    variable = Serial.read();

    if(variable == '1')

    {
      servo.write(0);
    }

    if(variable == '2')

    {
      servo.write(45);
    }

    if(variable == '3')

    {
      servo.write(90);
    }

    if(variable == '4')

    {
      servo.write(135);
    }
    
    if(variable == '5')
    {
      servo.write(170);
    }

  }


  delay(20);

}

After the programs worked to our liking we decided to use a dvd disk as the indicator by taping it on the servo. As the case we decided to use a cardboard box.

We cut a hole on the box so that the dvd only shows a part at a time and drew some helpful pictures on the dvd.

To keep the servo in place we sliced a hole on both sides of the box to add a layer and taped the servo on it.

And a video of it working. In the video we change the values directly to the website instead of using the actual program in order to demonstrate the changes on the thermometer.



And more pictures of the project below:

Advertisements

One thought on “Arduino remote thermometer

  1. Pingback: Oma prototyyppi, Hellemittari! » nikokiuru.com

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s