Home ESP8266 ESP8266 based TMP175 temperature display project

ESP8266 based TMP175 temperature display project

In this project we will create an environmental system with a TMP175  and a Wemos Mini and we will then display the readings on an OLED display

The TMP175 device is a digital temperature sensors ideal for NTC and PTC thermistor replacement. The devices offer a typical accuracy of ±1°C without requiring calibration or external component signal conditioning. IC temperature sensors are highly linear and do not require complex calculations or look-up tables to derive the temperature. The on-chip 12-bit ADC offers resolutions down to 0.0625°C. The device is available in the industry standard LM75 SOIC-8 and MSOP-8 footprint.

The TMP175 feature SMBus, Two-Wire, and I2C interface compatibility. The TMP175 device allows up to 27 devices on one bus. The TMP175 features an SMBus Alert function.

The TMP175 is ideal for extended temperature measurement in a variety of communication, computer, consumer, environmental, industrial, and instrumentation applications.

Features

  • TMP175: 27 Addresses
  • Digital Output: SMBus™, Two-Wire™, and I2C
    Interface Compatibility
  • Resolution: 9 to 12 Bits, User-Selectable
  • Accuracy:
    • ±1°C (Typical) from –40°C to 125°C
    • ±2°C (Maximum) from –40°C to 125°C
  • Low Quiescent Current: 50-µA, 0.1-µA Standby
  • Wide Supply Range: 2.7 V to 5.5 V
  • Small 8-Pin MSOP and 8-Pin SOIC Packages

Requirements

Lets take a look a the shields and boards that are required for this project

 

Image Summary
The Wemos mini – ESP8266 based board, it comes with various headers. This is the beauty of it you can create stackable projects with the board and pin compatible shields
 

This is the TMP175 module I used
A  64×48 OLED screen
This is simply a base, you plug the Wemos Mini into one side and you can plug a shield or shields into the other side

Parts List

I connect the Wemos Mini to the dual base and then put the OLED shield along side this, I then connect the MPL3115A2 sensor to the OLED or the spare base

Name Link
Wemos Mini D1 mini – Mini NodeMcu 4M bytes Lua WIFI Internet of Things development board based ESP8266 by WeMos
Wemos Base Tripler Base V1.0.0 Shield for WeMos D1 Mini
TMP175 1pcs CJMCU-175 TMP175 27 Address Digital Temperature Sensor
Connecting wire Free shipping Dupont line 120pcs 20cm male to male + male to female and female to female jumper wire

Schematic

We use the I2C connection for the sensor

Module Connection Wemos Connection
VCC 3v3
GND Gnd
SDA SDA (D2)
SCL SCL (D1)

 

Code

For the oled you need https://github.com/sparkfun/SparkFun_Micro_OLED_Arduino_Library

[codesyntax lang=”cpp”]

#include <Wire.h> 
#include <SFE_MicroOLED.h> // Include the SFE_MicroOLED library

#define PIN_RESET 255 //
#define DC_JUMPER 0 // I2C Addres: 0 - 0x3C, 1 - 0x3D

MicroOLED oled(PIN_RESET, DC_JUMPER); // Example I2C declaration

byte TempHi;              // Variable hold data high byte
byte TempLo;              // Variable hold data low byte
boolean P_N;              // Bit flag for Positive and Negative
unsigned int Decimal;     // Variable hold decimal value

void Cal_Temp();
/*******************************************************************************
                      Setup
*******************************************************************************/ 
void setup() 
{ 
  Serial.begin(9600);
  Wire.begin();             // join i2c bus (address optional for master) 
  //start the OLED
  oled.begin();
  oled.clear(ALL); // Clear the display's memory (gets rid of artifacts)
  oled.display();
  delay(1000);
} 
 
/*******************************************************************************
                      Main Loop
*******************************************************************************/  
void loop() 
{
  const int I2C_address = 0x37;  // I2C write address 
    
  delay(100);
  Wire.beginTransmission(I2C_address);
  Wire.write(1);             // Setup configuration register
  Wire.write(0x60);          // 12-bit
  Wire.endTransmission(); 
  
  Wire.beginTransmission(I2C_address);
  Wire.write(0);             // Setup Pointer Register to 0
  Wire.endTransmission(); 
  
  while (1)
  {  
    // Read temperature value
    Wire.requestFrom(I2C_address, 2);
    while(Wire.available())          // Checkf for data from slave
    {                                
      TempHi = Wire.read();       // Read temperature high byte
      TempLo = Wire.read();       // Read temperature low byte
    } 
    Cal_Temp ();
    
    // Display temperature
    if (P_N == 0)
      Serial.print("-");
    oled.clear(PAGE);
    oled.setFontType(0); // set font type 0, please see declaration in SFE_MicroOLED.cpp
    oled.setCursor(1, 3);
    oled.print("Temp = ");
    oled.setCursor(1, 12);
    oled.print(TempHi,DEC);
    oled.print(".");
    oled.print(Decimal,DEC);
    oled.print(" c");
    oled.display();
    delay(1000);
  }  
}

void Cal_Temp()
{
  if (TempHi&0x80)          // If bit7 of the TempHi is HIGH then the temperature is negative
    P_N = 0;
  else                      // Else the temperature is positive
    P_N = 1;
  
  TempHi = TempHi & 0x7F;   // Remove sign
  TempLo = TempLo & 0xF0;   // Filter out last nibble
  TempLo = TempLo >>4;      // Shift right 4 times
  Decimal = TempLo;
  Decimal = Decimal * 625;  // Each bit = 0.0625 degree C
    
}

[/codesyntax]

 

Download the example from ESP8266_OLED_and_TMP175

 

Links

https://www.nxp.com/docs/en/data-sheet/MPL3115A2.pdf

 

You may also like