- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Hi,
I've tried the new humidity/temperature sensor http://www.isweek.com/product/htu21d-digital-temperature-and-humidity-sensor-htu21d_1.html HTU21D from isweek and really like this little breakout board.
It is a much better replacement for the slow und sometimes unreliable DHTxx sensors. Because of the I2C interface wiring and programming is very easy.
Here is my adapted version of the humidity sketch (you need the HTU21D library from isweek):
# include
# include
# include
# define CHILD_ID_HUM 0
# define CHILD_ID_TEMP 1
unsigned long SLEEP_TIME = 60000; // Sleep time between reads (in milliseconds)
MySensor gw;
//Create an instance of the object
HTU21D myHumidity;
boolean metric = true;
MyMessage msgHum(CHILD_ID_HUM, V_HUM);
MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP);
void setup()
{
gw.begin();
// Send the Sketch Version Information to the Gateway
gw.sendSketchInfo("Humidity", "2.0");
// Register all sensors to gw (they will be created as child devices)
gw.present(CHILD_ID_HUM, S_HUM);
gw.present(CHILD_ID_TEMP, S_TEMP);
metric = gw.getConfig().isMetric;
myHumidity.begin();
}
void loop()
{
float temperature = myHumidity.readTemperature();
if (!metric) {
temperature = (temperature * 1.8) + 32.0;
}
gw.send(msgTemp.set(temperature, 1));
float humidity = myHumidity.readHumidity();
gw.send(msgHum.set(humidity, 1));
gw.sleep(SLEEP_TIME); //sleep a bit
}
Link Copied
0 Replies

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page