34 #include <mraa/common.hpp>
35 #include <mraa/uart_ow.hpp>
37 #define DS18B20_DEFAULT_UART 0
90 static const uint8_t DS18B20_FAMILY_CODE = 0x28;
95 CMD_WRITE_SCRATCHPAD = 0x4e,
96 CMD_READ_SCRATCHPAD = 0xbe,
97 CMD_COPY_SCRATCHPAD = 0x48,
98 CMD_RECALL_EEPROM = 0xb8,
99 CMD_READ_POWER_SUPPLY = 0xb4
104 CFG_RESOLUTION_R0 = 0x20,
105 CFG_RESOLUTION_R1 = 0x40,
106 _CFG_RESOLUTION_MASK = 3,
107 _CFG_RESOLUTION_SHIFT = 5
113 RESOLUTION_9BITS = 0,
114 RESOLUTION_10BITS = 1,
115 RESOLUTION_11BITS = 2,
116 RESOLUTION_12BITS = 3
124 DS18B20(
int uart=DS18B20_DEFAULT_UART);
148 void update(
int index=-1);
198 return m_devicesFound;
211 if (index < 0 || index >= m_devicesFound)
213 throw std::out_of_range(std::string(__FUNCTION__) +
214 ": device index out of range");
216 return m_deviceMap[index].id;
232 RESOLUTIONS_T resolution;
235 std::map<int, sensor_info_t> m_deviceMap;
240 float readSingleTemp(
int index);
DS18B20(int uart=DS18B20_DEFAULT_UART)
Definition: ds18b20.cxx:40
Definition: ds18b20.hpp:229
std::string getId(int index)
Definition: ds18b20.hpp:209
float getTemperature(int index, bool fahrenheit=false)
Definition: ds18b20.cxx:230
int devicesFound()
Definition: ds18b20.hpp:196
~DS18B20()
Definition: ds18b20.cxx:55
void setResolution(int index, RESOLUTIONS_T res)
Definition: ds18b20.cxx:244
void recallEEPROM(int index)
Definition: ds18b20.cxx:284
API for the DS18B20 1-Wire Temperature Sensor.
Definition: ds18b20.hpp:85
void copyScratchPad(int index)
Definition: ds18b20.cxx:270
void init()
Definition: ds18b20.cxx:59
void update(int index=-1)
Definition: ds18b20.cxx:135