Home MBed LM75 temperature sensor and MBed 1768 example

LM75 temperature sensor and MBed 1768 example

by shedboy71

In this particular example we connect an LM75 temperature sensor to an MBed 1768

The LM75 temperature sensor includes a delta-sigma analog-to-digital converter, and a digital overtemperature detector. The host can query the LM75 through its I²C interface to read temperature at any time. The open-drain overtemperature output (OS) sinks current when the programmable temperature limit is exceeded. The OS output operates in either of two modes, comparator or interrupt.

The host controls the temperature at which the alarm is asserted (TOS) and the hysteresis temperature below which the alarm condition is not valid (THYST). Also, the LM75’s TOS and THYST registers can be read by the host. The address of the LM75 is set with three pins to allow multiple devices to work on the same bus.

Power-up is in comparator mode, with defaults of TOS = +80°C and THYST = +75°C. The 3.0V to 5.5V supply voltage range, low supply current, and I²C interface make the LM75 ideal for many applications in thermal management and protection.

Features
SO (SOP) and µMAX® (µSOP) Packages
I²C Bus Interface
Separate Open-Drain OS Output Operates as Interrupt or Comparator/Thermostat Input
Register Readback Capability
Power-Up Defaults Permit Stand-Alone Operation as a Thermostat
3.0V to 5.5V Supply Voltage
Low Operating Supply Current 250µA (typ), 1mA (max)
4µA (typ) Shutdown Mode Minimizes Power Consumption
Up to Eight LM75s Can Be Connected to a Single Bus

 

Table of Contents

Layout

mbed and lm75

mbed and lm75

Code

I used the following example for the MBed compiler – https://os.mbed.com/components/LM75B-Temperature-Sensor/

[codesyntax lang=”cpp”]

#include "mbed.h"
#include "LM75B.h"

//Create an LM75B object at the default address (ADDRESS_0)
LM75B sensor(p28, p27);

int main()
{
    //Try to open the LM75B
    if (sensor.open()) 
    {
        printf("Device detected!\n");

        while (1) 
        {
            //Print the current temperature
            printf("Temp = %.3f\r\n", (float)sensor);
            //Sleep for 0.5 seconds
            wait(0.5);
        }
    } 
    else 
    {
        error("Device not detected!\n");
    }
}

[/codesyntax]

Testing

using a terminal program such as TeraTerm and you should see something like this

Temp = 30.000
Temp = 29.750
Temp = 29.750
Temp = 29.625
Temp = 29.750
Temp = 29.875
Temp = 30.000
Temp = 30.125
Temp = 30.250
Temp = 30.000
Temp = 29.750
Temp = 29.750
Temp = 29.625

 

Links

LM75 CJMCU-75 temperature sensor high speed I2C interface high precision development board module

You may also like