Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: LM75B_Sensor LM75B_Sensor_ESP8266_WIFI_module
Fork of LM75B by
LM75B.cpp
- Committer:
- chris
- Date:
- 2012-10-26
- Revision:
- 1:6a70c9303bbe
- Parent:
- 0:1be38995591b
File content as of revision 1:6a70c9303bbe:
#include "LM75B.h"
LM75B::LM75B(PinName sda, PinName scl) : i2c(sda, scl)
{
char cmd[2];
cmd[0] = LM75B_Conf;
cmd[1] = 0x0;
i2c.write( LM75B_ADDR, cmd, 2);
}
LM75B::~LM75B()
{
}
float LM75B::read()
{
char cmd[2];
cmd[0] = LM75B_Temp;
i2c.write( LM75B_ADDR, cmd, 1); // Send command string
i2c.read( LM75B_ADDR, cmd, 2); // Send command string
return ( float((cmd[0]<<8)|cmd[1]) / 256.0 );
}
