Internet of Things Temperature sensor

My first IoT project is a room temperature sensor publishing data to cloud.

Google DS18B20 + Raspberry Pi and you fill find many posts about it. I followed one of them

Purchasing the hardware and electronics part was a big difficult in India. The parts are cheap, but finding the correct ones on internet or local shops was a bit challenging for me.

Once I procured all the hardware, the only change in the above circuit diagram is to use 5V rather than 3.3V. With 3.3V, sensor was getting detected, but there was no reading from it.

Data is read by Python function

def read(precision):
inputfile = open("/sys/bus/w1/devices/28-031464907dff/w1_slave")
text =
tempdata = text.split("\n")[1].split(" ")[9]
temp = float(tempdata[2:])
temp = temp / 1000
temp = int(round(temp,precision))
return temp

To upload use API provided by

import urllib2
def publishtoInternet(temp):
url = "<public_key>?private_key=<your_key>&temp=" + temp
result = urllib2.urlopen(url).read()
print result

And that’s it! This is an always on temperature sensor. You can not only publish it to internet, you can also use the reading to take decisions like controlling other IoT things.


Leave a Reply

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

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

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s