Displaying Temperature on LCD Using STS-21(I2C)
by Dcube Tech Ventures in Circuits > Arduino
815 Views, 1 Favorites, 0 Comments
Displaying Temperature on LCD Using STS-21(I2C)
Hello,
Good Greetings..!! I (Somanshu Choudhary) on the behalf of Dcube tech ventures going to measure temperature using Arduino nano and displaying it on 16 X 2 LCD it is one of the applications of I2C protocol to read analog data of temperature Sensor STS-21.
Overview
- Temperature Sensor STS-21
- DATASHEET LINK : https://www.sensirion.com/experts-for-smart-sensor...
What You Need / Links
- Arduino Nano
- I²C Shield for Arduino Nano
- USB Cable Type A to Micro Type B 6 Feet Long LINK
- I²C Cable LINK
- 12 or 14-Bit Resolution Digital Output I²C Interface.
- 16 X 2 LINK : http://www.amazon.in/16x2-Alphanumeric-Display-JHD...
- Ribbon Wire LINK : http://www.amazon.in/Multi-Colored-Strand-Ribbon-C...
-
New Soldering Iron - 25W , Solder Wire LINK : http://www.amazon.in/New-Soldering-Iron-Solder-buy...
-
Wire Stripper & Cutter KG163 LINK : http://www.amazon.in/KitsGuru-Wire-Stripper-Cutter...
Circuit Diagram
Programming
#include
#include LiquidCrystal lcd(6, 7, 5, 4, 3, 2);
void setup()
{
// set up the LCD's number of columns and rows
lcd.begin(16, 2);
// I2C address of the STS21
#define TMP_ADDR 0x4A
// Join I2c Bus as master
Wire.begin();
// Start serial communication
Serial.begin(9600);
// Begin transmission
Wire.beginTransmission(TMP_ADDR);
// Select no hold master
Wire.write(0xF3);
// End transmission and release I2C bus
Wire.endTransmission();
}
void loop()
{
// Begin transmission
Wire.beginTransmission(TMP_ADDR);
// Select Data Registers
Wire.write(TMP_ADDR);
// End transmission and release I2C bus
delay(500);
// Request 2 bytes , Msb first
Wire.requestFrom(TMP_ADDR, 2 );
// Read the two bytes
while(Wire.available())
{
int msb = Wire.read();
int lsb = Wire.read();
Wire.endTransmission();
// Data conversion in raw values
int rawtmp = msb << 8 |lsb;
int value = rawtmp & 0xFFFC;
double ans = -46.85 + (175.72 * (value / 65536.0));
// Print output
Serial.print("celsius value : ");
Serial.println(ans);
lcd.setCursor(0, 0);
lcd.print("celsius value : ");
lcd.setCursor(0,1);
lcd.print(ans,10);
delay(1000);
} }
For further quires Feel free to visit our site: