-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUltrasonic_Anemometer.h
84 lines (54 loc) · 1.29 KB
/
Ultrasonic_Anemometer.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
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
74
75
76
77
78
79
80
81
82
83
84
#pragma once
#include "Arduino.h"
class UltrasonicAnemometer {
public:
UltrasonicAnemometer( int triggerPin, int echoPin, float distanceCM, unsigned long updateInterval = 100 );
void
begin( void ) ,
update( void ) , // Refresh all variables;
setUpdateInterval( unsigned long interval ),
setTemperatureC( float temp ) ,
setHumidity( float humidity ) ,
setPressure( float pressure ) ;
float
sensorSpacing( void ) const ,
speedOfSound( void ) const ,
windSpeed( void ) ;
int
pingTravelTime( void ) const ;
bool
ready( void ) const;
private:
typedef struct {
float
tempC ,
pressure ,
humidity ;
bool
updateFlag ;
} correction_data_t ;
/**************************VARIABLES********************************/
float
_speedOfSound ,
_windSpeed , // m/s
_pingSpeed ; // m/s
float const
_sensorDistanceCM ;
int const
_triggerPin,
_echoPin ;
unsigned long
_updateInterval,
_lastUpdateTime ;
correction_data_t
_ambient ;
bool
_newDataFlag;
/**************************METHODS********************************/
void
_setSpeedOfSound( void ),
_setPingSpeed( unsigned long pingTime ),
_setWindSpeed( void ) ;
unsigned long
_ping( void ) ;
};