2016-01-22 15:42:31 -08:00
|
|
|
/*
|
|
|
|
* Author: Henry Bruce <henry.bruce@intel.com>
|
|
|
|
* Copyright (c) 2015 Intel Corporation.
|
|
|
|
*
|
2019-07-30 19:41:32 -07:00
|
|
|
* This program and the accompanying materials are made available under the
|
|
|
|
* terms of the The MIT License which is available at
|
|
|
|
* https://opensource.org/licenses/MIT.
|
2016-01-22 15:42:31 -08:00
|
|
|
*
|
2019-07-30 19:41:32 -07:00
|
|
|
* SPDX-License-Identifier: MIT
|
2016-01-22 15:42:31 -08:00
|
|
|
*/
|
|
|
|
|
2017-08-30 15:00:29 -07:00
|
|
|
#include <exception>
|
2016-01-22 15:42:31 -08:00
|
|
|
#include <iostream>
|
2017-08-30 15:00:29 -07:00
|
|
|
|
2016-04-25 14:27:51 -07:00
|
|
|
#include "si7005.hpp"
|
2017-08-30 15:00:29 -07:00
|
|
|
#include "upm_utilities.h"
|
2016-01-22 15:42:31 -08:00
|
|
|
|
|
|
|
#define EDISON_I2C_BUS 1
|
|
|
|
#define EDISON_GPIO_SI7005_CS 20
|
|
|
|
|
2017-04-05 15:43:02 -07:00
|
|
|
//! [Interesting]
|
2017-08-30 15:00:29 -07:00
|
|
|
int
|
|
|
|
main()
|
2016-01-22 15:42:31 -08:00
|
|
|
{
|
2017-08-30 15:00:29 -07:00
|
|
|
try {
|
|
|
|
upm::SI7005 sensor(EDISON_I2C_BUS, EDISON_GPIO_SI7005_CS);
|
|
|
|
while (true) {
|
|
|
|
int temperature = sensor.getTemperatureCelsius();
|
|
|
|
int humidity = sensor.getHumidityRelative();
|
|
|
|
std::cout << "Temperature = " << temperature << "C" << std::endl;
|
|
|
|
std::cout << "Humidity = " << humidity << "%" << std::endl;
|
|
|
|
upm_delay(1);
|
|
|
|
}
|
|
|
|
} catch (std::exception& e) {
|
|
|
|
std::cerr << e.what() << std::endl;
|
|
|
|
}
|
|
|
|
return 0;
|
2016-01-22 15:42:31 -08:00
|
|
|
}
|
|
|
|
//! [Interesting]
|