modify the write function for temperature update
If you use update temperature, you modify the repeat condition when write function use
- read16() -> m_I2C.write(m_Addr, ®, 1); //stop condition
- read16() -> m_I2C.write(m_Addr, ®, 1,1); //repeat condition
Fork of
LM75B
by Neil Thiessen
« Back to documentation index
LM75B Class Reference
LM75B class.
More...
#include <LM75B.h >
Public Types
enum Address {
ADDRESS_0 = (0x48 << 1),
ADDRESS_1 = (0x49 << 1),
ADDRESS_2 = (0x4A << 1),
ADDRESS_3 = (0x4B << 1),
ADDRESS_4 = (0x4C << 1),
ADDRESS_5 = (0x4D << 1),
ADDRESS_6 = (0x4E << 1),
ADDRESS_7 = (0x4F << 1)
}
Represents the different I2C address possibilities for the LM75B .
More...
enum PowerMode { POWER_NORMAL ,
POWER_SHUTDOWN
}
Represents the power mode of the LM75B .
More...
enum OSMode { OS_COMPARATOR ,
OS_INTERRUPT
}
Represents OS pin mode of the LM75B .
More...
enum OSPolarity { OS_ACTIVE_LOW ,
OS_ACTIVE_HIGH
}
Represents OS pin polarity of the LM75B .
More...
enum OSFaultQueue { OS_FAULT_QUEUE_1 ,
OS_FAULT_QUEUE_2 ,
OS_FAULT_QUEUE_4 ,
OS_FAULT_QUEUE_6
}
Represents OS pin fault queue length of the LM75B .
More...
Public Member Functions
LM75B (PinName sda, PinName scl, Address addr, int hz)
Create an LM75B object connected to the specified I2C pins with the specified I2C slave address.
bool open (void)
Probe for the LM75B and reset it to default configuration if present.
LM75B::PowerMode powerMode (void)
Get the current power mode of the LM75B .
void powerMode (PowerMode mode)
Set the power mode of the LM75B .
LM75B::OSMode osMode (void)
Get the current OS pin mode of the LM75B .
void osMode (OSMode mode)
Set the OS pin mode of the LM75B .
LM75B::OSPolarity osPolarity (void)
Get the current OS pin polarity of the LM75B .
void osPolarity (OSPolarity polarity)
Set the OS pin polarity of the LM75B .
LM75B::OSFaultQueue osFaultQueue (void)
Get the current OS pin fault queue length of the LM75B .
void osFaultQueue (OSFaultQueue queue)
Set the OS pin fault queue length of the LM75B .
float alertTemp (void)
Get the current alert temperature threshold of the LM75B .
void alertTemp (float temp)
Set the alert temperature threshold of the LM75B .
float alertHyst (void)
Get the current alert temperature hysteresis threshold of the LM75B .
void alertHyst (float temp)
Set the alert temperature hysteresis threshold of the LM75B .
float temp (void)
Get the current temperature measurement of the LM75B .
operator float ()
A shorthand for temp()
Detailed Description
LM75B class.
Used for controlling an LM75B temperature sensor connected via I2C.
Example:
#include "mbed.h"
#include "LM75B.h"
LM75B sensor(p28, p27);
int main()
{
if (sensor.open()) {
printf("Device detected!\n" );
while (1) {
printf("Temp = %.3f\n" , (float )sensor);
wait(0.5);
}
} else {
error("Device not detected!\n" );
}
}
Definition at line 52 of file LM75B.h .
Member Enumeration Documentation
Represents the different I2C address possibilities for the LM75B .
Enumerator:
ADDRESS_0
A[2:0] pins = 000.
ADDRESS_1
A[2:0] pins = 001.
ADDRESS_2
A[2:0] pins = 010.
ADDRESS_3
A[2:0] pins = 011.
ADDRESS_4
A[2:0] pins = 100.
ADDRESS_5
A[2:0] pins = 101.
ADDRESS_6
A[2:0] pins = 110.
ADDRESS_7
A[2:0] pins = 111.
Definition at line 57 of file LM75B.h .
Represents OS pin fault queue length of the LM75B .
Enumerator:
OS_FAULT_QUEUE_1
OS is asserted after 1 fault.
OS_FAULT_QUEUE_2
OS is asserted after 2 consecutive faults.
OS_FAULT_QUEUE_4
OS is asserted after 4 consecutive faults.
OS_FAULT_QUEUE_6
OS is asserted after 6 consecutive faults.
Definition at line 91 of file LM75B.h .
Represents OS pin mode of the LM75B .
Enumerator:
OS_COMPARATOR
OS is asserted when the temperature reaches the alert threshold, and de-asserted when the temperature drops below the alert hysteresis threshold.
OS_INTERRUPT
OS is asserted when the temperature reaches the alert threshold, or drops below the alert hysteresis threshold, and only de-asserted when a register has been read.
Definition at line 77 of file LM75B.h .
Represents OS pin polarity of the LM75B .
Enumerator:
OS_ACTIVE_LOW
OS is a logic low when asserted, and a logic high when de-asserted.
OS_ACTIVE_HIGH
OS is a logic high when asserted, and a logic low when de-asserted.
Definition at line 84 of file LM75B.h .
Represents the power mode of the LM75B .
Enumerator:
POWER_NORMAL
Chip is enabled and samples every 100ms.
POWER_SHUTDOWN
Chip is in low-power shutdown mode.
Definition at line 70 of file LM75B.h .
Constructor & Destructor Documentation
Create an LM75B object connected to the specified I2C pins with the specified I2C slave address.
Parameters:
sda The I2C data pin.
scl The I2C clock pin.
addr The I2C slave address (defaults to ADDRESS_0).
Definition at line 19 of file LM75B.cpp .
Member Function Documentation
Get the current alert temperature hysteresis threshold of the LM75B .
Returns: The current alert temperature hysteresis threshold in °C.
Definition at line 173 of file LM75B.cpp .
void alertHyst
(
float
temp )
Set the alert temperature hysteresis threshold of the LM75B .
Parameters:
temp The new alert temperature hysteresis threshold in °C.
Definition at line 179 of file LM75B.cpp .
void alertTemp
(
float
temp )
Set the alert temperature threshold of the LM75B .
Parameters:
temp The new alert temperature threshold in °C.
Definition at line 167 of file LM75B.cpp .
Get the current alert temperature threshold of the LM75B .
Returns: The current alert temperature threshold in °C.
Definition at line 161 of file LM75B.cpp .
Probe for the LM75B and reset it to default configuration if present.
Returns: 'true' if the device exists on the bus, 'false' if the device doesn't exist on the bus.
Definition at line 27 of file LM75B.cpp .
A shorthand for temp()
Returns: The current temperature measurement in °C.
Definition at line 198 of file LM75B.h .
Set the OS pin fault queue length of the LM75B .
Parameters:
queue The new OS pin fault queue length as an OSFaultQueue enum.
Definition at line 141 of file LM75B.cpp .
Get the current OS pin fault queue length of the LM75B .
Returns: The current OS pin fault queue length as an OSFaultQueue enum.
Definition at line 125 of file LM75B.cpp .
Get the current OS pin mode of the LM75B .
Returns: The current OS pin mode as an OSMode enum.
Definition at line 71 of file LM75B.cpp .
Set the OS pin mode of the LM75B .
Parameters:
mode The new OS pin mode as an OSMode enum.
Definition at line 83 of file LM75B.cpp .
Get the current OS pin polarity of the LM75B .
Returns: The current OS pin polarity as an OSPolarity enum.
Definition at line 98 of file LM75B.cpp .
Set the OS pin polarity of the LM75B .
Parameters:
polarity The new OS pin polarity as an OSPolarity enum.
Definition at line 110 of file LM75B.cpp .
Set the power mode of the LM75B .
Parameters:
mode The new power mode as a PowerMode enum.
Definition at line 56 of file LM75B.cpp .
Get the current power mode of the LM75B .
Returns: The current power mode as a PowerMode enum.
Definition at line 44 of file LM75B.cpp .
Get the current temperature measurement of the LM75B .
Returns: The current temperature measurement in °C.
Definition at line 185 of file LM75B.cpp .