-
Notifications
You must be signed in to change notification settings - Fork 0
/
ACS712.h
40 lines (33 loc) · 926 Bytes
/
ACS712.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
/**
Powered by Smart Technology Benin
@autor: AMOUSSOU Z. Kenneth
@date: 11/09/2018
@version: 1.0
*/
#ifndef H_ACS712
#define H_ACS712
#if ARDUINO < 100
#include <WProgram.h>
#else
#include <Arduino.h>
#endif
#define ACS712_5 185 // mV/A
#define ACS712_20 100 // mV/A
#define ACS712_30 66 // mV/A
#define A 0
#define mA 1
class ACS712{
public:
ACS712(uint8_t input, uint8_t sensitivty);
int16_t raw(); // read raw data form the sensor
float readDC(uint8_t unit);
float readRMS(uint8_t unit); // measure the RMS value of an Alternatif current
float calibrate(); // Make first calibration of the sensor
float getOffset(); // read the sensor offset after calibration done
void begin(); // auto-calibration
private:
uint8_t _input;
float _offset;
uint8_t _sensitivity;
};
#endif