-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLM35.h
More file actions
73 lines (58 loc) · 1.68 KB
/
LM35.h
File metadata and controls
73 lines (58 loc) · 1.68 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/*
* LM35.h - LM35 sensor library for microcontrollers version 1.0
*
* author Danilo Queiroz Barbosa
* member of electronicdrops.com
* daniloqb@electronicdrops.com
*
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
*
* This library intended to facilitate the use of LM35 temperature sensor with microcontrollers
*
*
*/
#ifndef LM35_H
#define LM35_H
#include "Arduino.h"
#define LM35_RESOLUTION 16
#define LM35_ADC_REF 1024
#define LM35_VOL_REF 5.0
#define LM35_MAX_TEMPERATURE 150
#define LM35_MIN_TEMPERATURE -55
class LM35{
private:
float m_temperature;
float m_milivolts;
int m_sensor_pin;
int m_resolution{LM35_RESOLUTION};
int m_adc_reference{LM35_ADC_REF};
float m_voltage_reference{LM35_VOL_REF};
float m_temp_alarm_high{LM35_MAX_TEMPERATURE};
float m_temp_alarm_low{LM35_MIN_TEMPERATURE};
boolean m_alarm_high;
boolean m_alarm_low;
float getMilivolts();
void checkAlarm();
public:
~LM35();
LM35(int t_pin);
LM35(int t_pin, int t_resolution, int t_adc, float t_voltage);
float getTemperature();
float getTemperature(char scale);
void setPin(int t_pin);
boolean setResolution(int t_resolution);
void setAdcReference(int t_adc);
void setVoltageReference(float t_voltage);
boolean setHighLimitAlarm(float t_temp);
boolean setLowLimitAlarm(float t_temp);
boolean getHighAlarm();
boolean getLowAlarm();
void update();
void begin();
};
#endif