Introduction: Arduino Nano - STS21 Temperature Sensor Tutorial

STS21 Digital Temperature Sensor offers superior performance and a space saving footprint. It provides calibrated, linearized signals in digital, I2C format. Fabrication of this sensor is based on CMOSens technology, which attributes to the superior performance and reliability of STS21. The resolution of STS21 can be changed by command, low battery can be detected and a checksum helps to improve communication reliability. Here is its demonstration of interfacing it with Arduino nano.

Step 1: What You Need..!!

Picture of What You Need..!!

1. Arduino Nano

2. STS21

LINK : https://www.controleverything.com/content/Temperature?sku=STS21_I2CS

3. I²C Cable

LINK : https://www.controleverything.com/content/I2C-Cables?sku=I2CAFF3

4. I²C Shield for Arduino Nano

LINK : https://www.controleverything.com/content/I2C-Master?sku=ANI2C

Step 2: Connection:

Picture of Connection:

Take an I2C shield for Arduino Nano and gently push it over the pins of Nano.

Then connect the one end of I2C cable to STS21 sensor and the other end to the I2C shield.

Connections are shown in the picture above.

Step 3: Code:

Picture of Code:

The arduino code for STS21 can be downloaded from our github repository-ControlEverythingCommunity

Here is the link for the same :

https://github.com/ControlEverythingCommunity/STS2...

The datasheet of STS21 can be found here:

https://s3.amazonaws.com/controleverything.media/c...

We include library Wire.h to facilitate the I2c communication of the sensor with the Arduino board.

You can also copy the code from here, it is given as follows:

// Distributed with a free-will license.

// Use it any way you want, profit or free, provided it fits in the licenses of its associated works.

// STS21

// This code is designed to work with the STS21_I2CS I2C Mini Module available from ControlEverything.com.

// https://www.controleverything.com/content/Tempera...

#include<Wire.h>

// STS21 I2C address is 0x4A(74)

#define addr 0x4A

void setup()

{

// Initialise I2C communication as MASTER

Wire.begin();

// Start serial communication, set baud rate = 9600

Serial.begin(9600);

delay(300);

}

void loop()

{

unsigned int data[2];

// Start I2C Transmission

Wire.beginTransmission(addr);

// Select no hold master

Wire.write(0xF3);

// End I2C Transmission

Wire.endTransmission();

delay(300);

// Request 2 bytes of data

Wire.requestFrom(addr, 2);

// Read 2 bytes of data

if (Wire.available() == 2)

{

data[0] = Wire.read();

data[1] = Wire.read();

}

// Convert the data

int rawtmp = data[0] * 256 + data[1];

int value = rawtmp & 0xFFFC;

double cTemp = -46.85 + (175.72 * (value / 65536.0));

double 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(300);

}

Step 4: Applications:

STS21 Digital Temperature Sensor can be employed in systems which require high accuracy temperature monitoring. It can be incorporated in various computer equipments, medical equipments and industrial control systems with the requisite of temperature measurement with proficient accuracy.

Comments

About This Instructable

580views

4favorites

More by Dcube Tech Ventures:Home Automation with Raspberry Pi using Relay boardMotion Control with Raspberry Pi and LIS3DHTR, 3-Axis Accelerometer, using Python3-Axis Accelerometer, ADXL345 with Raspberry Pi using Python
Add instructable to: