Martha MigliacioAlex Wong
Published © GPL3+

Using the Pmod TMP2 with Arduino Uno

Application notes for Pmod TMP2 and Arduino Uno. In this app, the ambient temperature is displayed on the serial monitor and serial LCD.

EasyProtip1 hour238
Using the Pmod TMP2 with Arduino Uno

Things used in this project

Hardware components

Pmod TMP2
Digilent Pmod TMP2
×1
Pmod CLS
Digilent Pmod CLS
×1
Arduino UNO & Genuino UNO
Arduino UNO & Genuino UNO
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

Pmod TMP2, Pmod CLS, and Arduino Uno Fritzing file

Fritzing file displaying the connection of the Pmod TMP2 and Pmod CLS to the Arduino Uno.

Pmod TMP2, Pmod CLS, and Arduino Uno Fritzing Image

Fritzing image displaying the connection between the Pmod TMP2, Pmod CLS, and Arduino Uno.
Pmodtmp2arduinouno bb qtzp4kcbe8

Code

Pmod TMP2 and Arduino Uno Code

Arduino
Using this code will display the ambient temperature from the Pmod TMP2 on the serial monitor as well as the Pmod CLS.
/************************************************************************
*
* Test of Pmod TMP2
*
*************************************************************************
* Description: Pmod_TMP2
* The ambient temperature is displayed on the serial monitor and
* On a serial LCD display .
*
*
* Material
* 1. Arduino Uno
* 2. Pmod TMP2 
* 3. Pmod CLS 
*
************************************************************************/

#include <Wire.h> // call library
#define ADT7420_Adresse 0x4B // I2C adress of the Pmod TMP2

//Déclaration d'un port série
#include <SoftwareSerial.h>
SoftwareSerial lcd(2,3); // RX, TX

int MSB;
int LSB;
int valeur;
float temperature;

void setup()
{
 Serial.begin(9600); // initialization of serial communication
 Wire.begin(); // initialization of I2C communication
 Init_ADT7420(); // initialisztion of Pmod AD2 module
 lcd.begin(9600); // initialization of serial communicationde l'afficheur
 lcd.write("\x1b[j"); // Erase display
 lcd.write("\x1b[0h"); // cursor positioning 2nd row 1st column
}

void loop()
{
 Wire.beginTransmission(ADT7420_Adresse); // Launch of the measure
  Wire.endTransmission();
 delay(10);
 Wire.requestFrom(ADT7420_Adresse, 2); // Recovery of the two bytes MSB and LSB
 if(Wire.available() <=2)
 {
  MSB = Wire.read();
  LSB = Wire.read();
 }
 valeur=(MSB<<8)|LSB ;
 if (((valeur>>15)&1)==0) // If the temperature is positive
 {
  temperature=valeur/128.0;
 }
 else // If the temperature is negative
 {
  temperature=(valeur-65535)/128.0;
 }
 Serial.print("MSB="); // display in serial monitor
 Serial.println(MSB);
 Serial.print("LSB=");
 Serial.println(LSB);
 Serial.print("Valeur=");
 Serial.println(valeur);
 Serial.print("Temperature=");
 Serial.println(temperature);
 lcd.write("\x1b[j"); // Erase display
 lcd.print("Temperature:"); // Write on display
 lcd.write("\x1b[1;0H"); // cursor positioning 2nd row 1st column
 lcd.print(temperature);
 lcd.print((char)223);
 lcd.print("c");
 delay(1000);
}

// Initialization of Pmod TMP2 module
void Init_ADT7420(void)
{
// Configuring the ADT7420 in 16 bit mode
 Wire.beginTransmission(ADT7420_Adresse);
 Wire.write(0x03);
 Wire.write(0x80);
 Wire.endTransmission();
}

Credits

Martha Migliacio

Martha Migliacio

5 projects • 2 followers
Contact
Alex Wong

Alex Wong

5 projects • 6 followers
I work in Digilent and like creating projects
Contact
Thanks to Lextronics.

Comments

Add projectSign up / Login