2020-09-07 18:18:46 +02:00
|
|
|
/**
|
|
|
|
* @file DS18B20.h
|
|
|
|
* @author your name (you@domain.com)
|
|
|
|
* @brief
|
|
|
|
* @version 0.1
|
|
|
|
* @date 2020-06-09
|
|
|
|
*
|
|
|
|
* @copyright Copyright (c) 2020
|
|
|
|
* Based on the LUA code from the ESP8266
|
|
|
|
* --------------------------------------------------------------------------------
|
|
|
|
* -- DS18B20 one wire module for NODEMCU
|
|
|
|
* -- NODEMCU TEAM
|
|
|
|
* -- LICENCE: http://opensource.org/licenses/MIT
|
|
|
|
* -- Vowstar <vowstar@nodemcu.com>
|
|
|
|
* -- 2015/02/14 sza2 <sza2trash@gmail.com> Fix for negative values
|
|
|
|
* --------------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef DS18B20_H
|
|
|
|
#define DS18B20_H
|
|
|
|
|
|
|
|
#include <OneWire.h>
|
|
|
|
|
2020-11-04 21:57:40 +01:00
|
|
|
class Ds18B20
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
OneWire *mDs;
|
|
|
|
int foundDevices;
|
2020-09-07 18:18:46 +02:00
|
|
|
|
2020-11-04 21:57:40 +01:00
|
|
|
public:
|
|
|
|
Ds18B20(int pin)
|
|
|
|
{
|
|
|
|
this->mDs = new OneWire(pin);
|
|
|
|
}
|
|
|
|
|
|
|
|
~Ds18B20()
|
|
|
|
{
|
|
|
|
delete this->mDs;
|
|
|
|
}
|
|
|
|
/**
|
2020-09-07 18:18:46 +02:00
|
|
|
* @brief read amount sensots
|
|
|
|
* check for available of DS18B20 sensors
|
|
|
|
* @return amount of sensors
|
|
|
|
*/
|
2020-11-04 21:57:40 +01:00
|
|
|
int readDevices(void);
|
2020-09-07 18:18:46 +02:00
|
|
|
|
2020-11-04 21:57:40 +01:00
|
|
|
/**
|
2020-09-07 18:18:46 +02:00
|
|
|
* @brief Read all temperatures in celsius
|
|
|
|
*
|
|
|
|
* @param pTemperatures array of float valuies
|
|
|
|
* @param maxTemperatures size of the given array
|
|
|
|
* @return int amount of read temperature values
|
|
|
|
*/
|
2020-11-04 21:57:40 +01:00
|
|
|
int readAllTemperatures(float *pTemperatures, int maxTemperatures);
|
2020-09-07 18:18:46 +02:00
|
|
|
};
|
|
|
|
#endif
|