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: EthernetInterfacePlusHostname NTPClient Onewire RdWebServer SDFileSystem-RTOS mbed-rtos mbed-src
RdDS18B20.h
- Committer:
- Bobty
- Date:
- 2015-10-16
- Revision:
- 23:fd5a5a9f30bc
- Parent:
- 20:7933076df5af
File content as of revision 23:fd5a5a9f30bc:
// Handles OneWire temperature sensors DB18S20
// Can handle multiple devices per pin
// Rob Dobson, 2015
#ifndef RdDS18B20__H
#define RdDS18B20__H
#include "mbed.h"
#include "Onewire.h"
#include "Logger.h"
class DS18B20
{
public:
DS18B20(PinName mbedPin, Logger &logger);
void ReqConvert();
double ReadTemperature(int addrIdx);
void DebugGetAddress(int addrIdx, char* buf);
int SearchToGetAddresses();
int GetNumAddresses()
{
return _numValidAddresses;
}
uint8_t* GetAddress(int addrIdx, uint8_t* addrBufPtr);
char* GetAddressStr(int addrIdx);
double GetLatestTemperature(int addrIdx, time_t& timeOfReading);
static const int ONEWIRE_ADDR_STRLEN = 3 * ONEWIRE_ADDR_BYTES + 1;
static const int MAX_BUS_DEVICES = 8;
static const int INVALID_TEMPERATURE = -1000.0;
private:
int _numValidAddresses;
uint8_t _addrTable[MAX_BUS_DEVICES][ONEWIRE_ADDR_BYTES];
double _temperatureTable[MAX_BUS_DEVICES];
time_t _timeOfReadingTable[MAX_BUS_DEVICES];
Onewire _oneWire;
char _addrStr[ONEWIRE_ADDR_STRLEN];
Logger &_logger;
char* GetChipId(int val);
};
#endif