Things used in this project

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.
pmodtmp2arduinouno_luHogcnxsg.fzz
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 CodeArduino
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

01aa44817a11ceb1a3050ebac4b68bbc
Martha Migliacio
1 project • 0 followers
Contact
Thanks to Lextronics.

Replications

Did you replicate this project? Share it!

I made one

Love this project? Think it could be improved? Tell us what you think!

Give feedback

Comments

Add projectSign up / Login