th02: fix non-working driver

There were a few issues with this driver, corrected in this update.

1) i2c transactions were not working - I replaced the i2c
implementation with the MRAA i2c class implementation.

2) status check was inverted - fixed.

3) fixed up #defines in header file to avoid naming collisions (ADDR,
etc).

4) Added capability to supply bus and i2c address to ctor, setting
defaults of 0, and TH02_ADDR respectively.

NOTE: For proper operation on Edison using the arduino breakout
board, the voltage needs to be set to 3.3V rather than 5v.  On G2, 5v
works fine.

Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
This commit is contained in:
Jon Trulson
2015-05-26 13:59:30 -06:00
committed by Mihai Tudor Panu
parent d36499eac8
commit b633ecf97f
3 changed files with 49 additions and 105 deletions

View File

@ -50,7 +50,7 @@ main(int argc, char **argv)
while (!doWork) {
temperature = sensor->getTemperature ();
// humidity = sensor->getHumidity ();
humidity = sensor->getHumidity ();
std::cout << "Temperature = " << temperature << ", Humidity = " << humidity << std::endl;
usleep (500000);
}