-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path05_getTempHumid_HTS221.cpp
More file actions
52 lines (43 loc) · 1.3 KB
/
05_getTempHumid_HTS221.cpp
File metadata and controls
52 lines (43 loc) · 1.3 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
/* File: 05_getTempHumid_HTS221.cpp
* Author: Philippe Latu
* Source: https://github.com/platu/libsensehat-cpp
*
* This example program collects measures from the HTS221 Humidity sensor.
* This sensor provides temperature measurement in degrees Celsius and relative
* humidity measurement.
*
* Function prototypes:
*
* double senseGetTemperatureFromHumidity();
* ^- temperature
*
* double senseGetHumidity();
* ^- humidity
*
* The program simply calls the two functions
*/
#include <iostream>
#include <iomanip>
#include <console_io.h>
#include <sensehat.h>
using namespace std;
int main() {
double Temp, Humid;
if (senseInit()) {
cout << "-------------------------------" << endl
<< "Sense Hat initialization Ok." << endl;
senseClear();
Temp = senseGetTemperatureFromHumidity();
cout << fixed << setprecision(2) << "Temp (from humid) = " << Temp
<< "°C" << endl;
Humid = senseGetHumidity();
cout << fixed << setprecision(0) << "Humidity = " << Humid << "% rH"
<< endl;
cout << endl << "Waiting for keypress." << endl;
getch();
senseShutdown();
cout << "-------------------------------" << endl
<< "Sense Hat shut down." << endl;
}
return EXIT_SUCCESS;
}