12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
-
-
- #include <unistd.h>
- #include <iostream>
- #include <signal.h>
-
- #include "htu21d.h"
-
- volatile int doWork = 0;
-
- upm::HTU21D *sensor = NULL;
-
- void
- sig_handler(int signo)
- {
- if (signo == SIGINT) {
- printf("\nCtrl-C received.\n");
- doWork = 1;
- }
- }
-
- int
- main(int argc, char **argv)
- {
-
- signal(SIGINT, sig_handler);
-
-
- float humidity = 0.0;
- float temperature = 0.0;
- float compRH = 0.0;
-
- sensor = new upm::HTU21D(0, HTU21D_I2C_ADDRESS);
-
- sensor->testSensor();
-
- while (!doWork) {
- compRH = sensor->getCompRH(true);
- humidity = sensor->getHumidity(false);
- temperature = sensor->getTemperature(false);
-
- std::cout << "humidity value = " <<
- humidity <<
- ", temperature value = " <<
- temperature <<
- ", compensated RH value = " <<
- compRH << std::endl;
- usleep (500000);
- }
-
-
- std::cout << "exiting application" << std::endl;
-
- delete sensor;
-
- return 0;
- }
|