-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTemp.h
48 lines (42 loc) · 1 KB
/
Temp.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#ifndef Temp_h
#define Temp_h
/*
* Led
*
* Library to wrap an 18B20 Temp sensor
*
* Greg Cope <[email protected]>
*
*/
#include <Arduino.h>
#include <OneWire.h>
// https://lowpowerlab.com/forum/moteino/improvedoptimized-ds18b201wire-read/
#define DEBUG(input) {Serial.print(input); Serial.flush();}
#define DEBUGln(input) {Serial.println(input); Serial.flush();}
class Temp
{
public:
Temp(int power, int pin);
//Temp(int power, int pin) : myds(pin);
void init(void);
void startConvert(void);
float read(void);
void on(void);
void off(void);
private:
void getFirstDsAdd(OneWire myds, byte firstadd[]);
void dsSetResolution(OneWire myds, byte addr[8]);
void dsConvertCommand(OneWire myds, byte addr[8]);
int _powerPin;
int _dataPin;
byte _dsAddr[8];
OneWire myds;
unsigned long starttime;
unsigned long elapsedtime;
unsigned int _SignBit;
unsigned int _TReading;
float _celsius;
byte _present;
byte data[12];
};
#endif