O Watch Sensor Kit includes a sensor board with a humidity sensor named SI7020 that provide the value for relative humidity. This sensor also measures the temperature (so you have two temperature sensors in the O Watch!).
But before we start, find out more about humidity and relative humidity.
To use this sensor we will use the SI7020 library written by Marcus Sorensen. Click here to download the zipped library. Unzip and move the unzipped folder in to your ‘Arduino->libraries’ folder.
The code below shows you how to use this sensor library to read humidity and temperature values.
/*
* This is a demo of the SI7021 Humidity Sensor
* This demo is made for the O Watch kit - http://theowatch.com
*
* This demo is based on the SI7021 library example
* and uses by Marcus Sorensen <marcus@electron14.com>
* https://github.com/mlsorensen/SI7021/blob/master/SI7021.h
* licensed under the GNU GPL v2
*
*/
#include <TinyScreen.h>
#include <SI7021.h> //include the sensor library
SI7021 sensor; //declare the sensor
TinyScreen display = TinyScreen(TinyScreenPlus);
void setup(void) {
Wire.begin();
sensor.begin();
display.begin();
display.setFlip(1);
display.on();
display.setFont(liberationSans_10ptFontInfo);
}
void loop()
{
//get the temperature using the library function
//temperature is an integer in hundredths
int tempHundredths = sensor.getCelsiusHundredths();
float temperature = tempHundredths / 100.0;
//get humidity from the libdary function
// humidity is an integer representing percent
int humidityvalue = sensor.getHumidityPercent();
display.setCursor(5,5);
display.print("Sensor Demo");
//print humidity valye
display.setCursor(5,25);
display.print("Humidity: ");
display.print(humidityvalue);
display.print("% ");
//print temperature value
display.setCursor(5,40);
display.print("Temp: ");
display.print((temperature*9/5+32-13)); //printing value converted to Fahrenheit
display.print(" F ");
delay(2000);
}
Blow in to the O Watch like you would fog a window to see the humidity value change.
Now you can measure the humidity levels inside your home anytime!
Comments
Please log in or sign up to comment.