2021-01-29 06:31:58 -05:00
|
|
|
#pragma once
|
|
|
|
//
|
|
|
|
// FILE: DS18B20_INT.h
|
|
|
|
// AUTHOR: Rob.Tillaart@gmail.com
|
2022-11-02 10:15:02 -04:00
|
|
|
// VERSION: 0.2.1
|
2021-01-29 06:31:58 -05:00
|
|
|
// DATE: 2017-07-25
|
|
|
|
// PUPROSE: Minimalistic library for DS18B20 temperature sensor
|
|
|
|
// uses only integer math (no float to minimize footprint)
|
|
|
|
// URL: https://github.com/RobTillaart/DS18B20_INT
|
2022-06-24 11:29:55 -04:00
|
|
|
// https://github.com/RobTillaart/DS18B20_RT
|
2021-01-29 06:31:58 -05:00
|
|
|
|
|
|
|
//
|
2022-11-02 10:15:02 -04:00
|
|
|
// BOTTOM VIEW
|
2021-01-29 06:31:58 -05:00
|
|
|
//
|
2022-11-02 10:15:02 -04:00
|
|
|
// PIN MEANING
|
|
|
|
// /---+
|
|
|
|
// / o | 1 GND
|
|
|
|
// | o | 2 DATA
|
|
|
|
// \ o | 3 VCC
|
|
|
|
// \---+
|
2021-01-29 06:31:58 -05:00
|
|
|
//
|
|
|
|
|
2021-06-16 04:41:09 -04:00
|
|
|
|
2022-11-02 10:15:02 -04:00
|
|
|
#define DS18B20_INT_LIB_VERSION (F("0.2.1"))
|
2021-06-16 04:41:09 -04:00
|
|
|
|
2021-01-29 06:31:58 -05:00
|
|
|
#include "Arduino.h"
|
|
|
|
#include "OneWire.h"
|
|
|
|
|
|
|
|
// Error Code
|
2021-12-17 05:26:25 -05:00
|
|
|
#define DEVICE_DISCONNECTED -127
|
2021-01-29 06:31:58 -05:00
|
|
|
|
|
|
|
typedef uint8_t DeviceAddress[8];
|
|
|
|
|
|
|
|
|
|
|
|
class DS18B20_INT
|
|
|
|
{
|
|
|
|
public:
|
2021-12-17 05:26:25 -05:00
|
|
|
explicit DS18B20_INT(OneWire * ow);
|
2021-06-16 04:41:09 -04:00
|
|
|
bool begin(uint8_t retries = 3);
|
|
|
|
void requestTemperatures(void);
|
|
|
|
int16_t getTempC(void);
|
|
|
|
bool isConversionComplete(void);
|
|
|
|
bool getAddress(uint8_t* buf);
|
2021-01-29 06:31:58 -05:00
|
|
|
|
2022-06-24 11:29:55 -04:00
|
|
|
void setResolution(uint8_t bits = 9);
|
|
|
|
uint8_t getResolution();
|
|
|
|
int16_t getTempCentiC(void);
|
|
|
|
|
|
|
|
|
2021-01-29 06:31:58 -05:00
|
|
|
private:
|
2021-06-16 04:41:09 -04:00
|
|
|
DeviceAddress _deviceAddress;
|
2021-12-17 05:26:25 -05:00
|
|
|
OneWire* _oneWire;
|
|
|
|
bool _addressFound;
|
2022-06-24 11:29:55 -04:00
|
|
|
|
|
|
|
uint8_t _resolution;
|
|
|
|
int16_t _readRaw();
|
2021-01-29 06:31:58 -05:00
|
|
|
};
|
|
|
|
|
2021-12-17 05:26:25 -05:00
|
|
|
|
2021-01-29 06:31:58 -05:00
|
|
|
// -- END OF FILE --
|
2021-12-17 05:26:25 -05:00
|
|
|
|