Mike, Matt and I had a blast out at the Bay Area Maker Faire in San Mateo last week. It was great to put some faces to names, and talk to fellow hackers in person.
I had a couple folks asking about their Arduino greenhouse projects, and they mentioned it might be useful to have a humidity sensor to make sure the room didn’t get too dry.
So Paul and Chris built the Humidity Sensor, which is really a Humidity and Temperature Sensor, since it provides an integrated temperature reading as well. I’ve uploaded it over at the Liquidware and Modern Device shop pages.
The Humidity (and Temperature) Sensor is a board that carries the SHT21 digital humidity and temperature sensor from Sensirion. It has 4 pins that can mount directly on the Arduino’s analog pins. Two of the four pins are Ground and +5V; the other two are clock and data pins making up the 2-wire serial interface.
It transmits data to the Arduino over an I2C protocol, and comes with built-in 5V tolerance to be powered directly from the analog pins. The Antipasto Arduino IDE has an integrated library that makes the humidity sensor plug-and-play.
Here’s a quick demo that Will and I put together, which maps out the relative humidity and temperature as a bargraph on the TouchShield Slide. Because the Slide doesn’t occupy any of the Arduino Duemilanove’s analog pins, I was able to mount both the Humidity Sensor and the Slide directly onto the Arduino.
I took a video of the Humidity Sensor bargraphs in action:
And the code is below:
//Humidity sensor bar graphs - Arduino Code
#include <Wire.h>
#include <LibHumidity.h>
#include <HardwareSensor.h>
int h;
int t;
LibHumidity humidity = LibHumidity(0);
void setup() {
Sensor.begin(19200);
}
void loop() {
h = (int)humidity.GetHumidity();
t = (int)humidity.GetTemperature();
Sensor.print("humidity", h);
Sensor.print("temp", t);
delay(5);
}
________________________________________________
//Humidity sensor bar graphs - TouchShield Code
#include <HardwareSensor.h>
int newT;
void setup() {
Sensor.begin(19200);
background(0);
line(0, 120, 320, 120);
text("RHumidity:", 0, 50);
text("Fahrenheit:", 0, 140);
}
void loop() {
if (Sensor.available()) {
int h;
int t;
if (!strcmp(Sensor.getName(), "humidity")) {
h = Sensor.read();
fill(0);
text(h, 230, 80);
delay(10);
fill(0);
rect(0, 70, 200, 30);
{
fill(0, 0, 255);
rect(0, 70, h*2, 30);
}
}
if (!strcmp(Sensor.getName(), "temp")) {
t = Sensor.read();
//convert celcius to fahrenheit
newT = (t*1.8 + 32);
fill(0);
text(newT, 230, 170);
delay(10);
fill(0);
rect(0, 160, 200, 30);
{
fill(255, 0, 0);
rect(0, 160, newT*1.6, 30);
}
}
}
}
Will’s posted the PDF cheatsheet over here, and I’ll be starting a greenhouse project next week with a couple of Arduino sensors including this one, so I’d love to hear any advice from any hackers out there with a green thumb :)