-
Notifications
You must be signed in to change notification settings - Fork 1
/
CurrentSensor.cpp
39 lines (29 loc) · 894 Bytes
/
CurrentSensor.cpp
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
/* Copyright (C) 2015 Willi Menapace <[email protected]>, Simone Lorengo <[email protected]> - All Rights Reserved
* Unauthorized copying of this file, via any medium is strictly prohibited
* Proprietary and confidential
* Written by Simone Lorengo <[email protected]>
*/
#include "GlobalDefines.h"
#ifdef ONBOARD
#include "CurrentSensor.h"
#include "EmonLib.h"
SensorType CurrentSensor::getType() {
return type;
}
long CurrentSensor::readValue() {
long ampRms = ((sensor.calcIrms(1480) - offset) * 1000);
return ampRms;
}
long CurrentSensor::getRaw() {
return analogRead(sensorPin);
}
void CurrentSensor::setOffset(long calibOffset){
offset = calibOffset;
}
CurrentSensor::CurrentSensor(int sensorAnalogPin) {
type = CURRENT;
sensorPin = sensorAnalogPin;
sensor.current(sensorPin, 11.8);
offset = 0;
}
#endif //ONBOARD