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.
Dependencies: MAX44000 PWM_Tone_Library nexpaq_mdk
Fork of LED_Demo by
TMP102.cpp
00001 #include "TMP102.h" 00002 00003 #define TEMP_REG_ADDR 0x00 00004 00005 TMP102::TMP102(PinName sda, PinName scl, int addr) : m_i2c(sda, scl), m_addr(addr) { 00006 m_i2c.frequency(400000); 00007 } 00008 TMP102::~TMP102 () { } 00009 00010 float TMP102::read() { 00011 const char tempRegAddr = TEMP_REG_ADDR; 00012 00013 m_i2c.write(m_addr, &tempRegAddr, 1); 00014 00015 char reg[2] = {0,0}; 00016 m_i2c.read(m_addr, reg, 2); 00017 00018 unsigned short res = (reg[0] << 4) | (reg[1] >> 4); 00019 00020 float temp = (float) ((float)res * 0.0625); 00021 00022 return temp; 00023 }
Generated on Tue Jul 12 2022 12:28:56 by
