Micro:bit and LM75 temperature sensor example

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.

Key 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

 

Parts List

name Link
Micro:bit Micro:bit Development Board
LM75 LM75A Temperature Sensor I2C Interface Temperature Module
connecting wire Free shipping Dupont line 120pcs 20cm male to male + male to female and female to female jumper wire

Layout

LM75 sensor Micro:bit
SDA 20 (SDA)
SCL 19 (SCL)
Vcc 3v
Gnd GND
DS N/C

 

Code

I used this library – https://github.com/thefekete/LM75

#include <Wire.h>
#include <LM75.h>
 
LM75 sensor;  // initialize an LM75 object
// You can also initiate with another address as follows:
//LM75 sensor(LM75_ADDRESS | 0b001);  // if A0->GND, A1->GND and A2->Vcc
 
void setup()
{
  Wire.begin();
  Serial.begin(9600);
}
 
void loop()
{
  // get temperature from sensor
  Serial.print("Current temp: ");
  Serial.print(sensor.temp());
  Serial.println(" C");
 
  // Tos Set-point
  sensor.tos(47.5); // set at 47.5'C
  Serial.print("Tos set at ");
  Serial.print(sensor.tos());
  Serial.println(" C");
 
  // Thyst Set-point
  sensor.thyst(42); // set at 42'C
  Serial.print("Thyst set at ");
  Serial.print(sensor.thyst());
  Serial.println(" C");
 
  // shutdown the sensor and wait a while
  sensor.shutdown(true);
  delay(3000);
  // wake up sensor for next time around
  sensor.shutdown(false);
 
  Serial.println();
}

Output

Open the serial monitor

Current temp: 19.00 C
Tos set at 47.50 C
Thyst set at 42.00 C

Current temp: 18.87 C
Tos set at 256.00 C
Thyst set at 256.00 C

Current temp: 256.00 C
Tos set at 256.00 C
Thyst set at 42.00 C

Links

LM75 temperature sensor high speed I2C interface high precision development board module