SHT25 Temperature Sensor – Arduino NANO.

In this project, I will be sensing temperature of the room in Degree Celsius, Kelvin and Fahrenheit every second.

I will be using an i2c serial temperature sensor module for this project.

jhhkkhkj.JPG

Along with an Arduino NANO.

fhghjhg

In my previous projects I have demonstrated various ways of temperature sensing using thermistor and also using LM-35.
Using an i2c serial sensor is most accurate way of sensing temperature among these.
Here is the datasheet of an SHT25 Temperature sensor.

 

http://www.mcs.anl.gov/research/projects/waggle/downloads/datasheets/chemsense/sht25.pdf

 

Code :-

#include<Wire.h>

// SHT25 I2C address is 0x40(64)
#define Addr 0x40

void setup()
{
// Initialise I2C communication as MASTER
Wire.begin();
// Initialise serial communication, set baud rate = 9600
Serial.begin(9600);
delay(300);
}

void loop()
{
unsigned int data[2];
// Start I2C transmission
Wire.beginTransmission(Addr);
// Send humidity measurement command, NO HOLD master
Wire.write(0xF5);
// Stop I2C transmission
Wire.endTransmission();
delay(500);

// Request 2 bytes of data
Wire.requestFrom(Addr, 2);

// Read 2 bytes of data
// humidity msb, humidity lsb
if(Wire.available() == 2)
{
data[0] = Wire.read();
data[1] = Wire.read();

// Convert the data
float humidity = (((data[0] * 256.0 + data[1]) * 125.0) / 65536.0) – 6;

// Output data to Serial Monitor
Serial.print(“Relative Humidity :”);
Serial.print(humidity);
Serial.println(” %RH”);
}

// Start I2C transmission
Wire.beginTransmission(Addr);
// Send temperature measurement command, NO HOLD master
Wire.write(0xF3);
// Stop I2C transmission
Wire.endTransmission();
delay(500);

// Request 2 bytes of data
Wire.requestFrom(Addr, 2);

// Read 2 bytes of data
// temp msb, temp lsb
if(Wire.available() == 2)
{
data[0] = Wire.read();
data[1] = Wire.read();

// Convert the data
float cTemp = (((data[0] * 256.0 + data[1]) * 175.72) / 65536.0) – 46.85;
float fTemp = (cTemp * 1.8) + 32;

// Output data to Serial Monitor
Serial.print(“Temperature in Celsius :”);
Serial.print(cTemp);
Serial.println(” C”);
Serial.print(“Temperature in Fahrenheit :”);
Serial.print(fTemp);
Serial.println(” F”);
}
delay(1000);
}

 

After uploading the code, Press ctrl+shift+M and open up the serial monitor.
to get the accurate temperature values.
nbnbnbnbn.JPG

Similarly we can use other sensors such as accelerometer, gyroscope, photo-sensor etc. For their Code, comment below this article. I’ll mail it to you.

Thankyou!

Advertisements

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