This project shows how you can stabilize the humidity inside a box. In this particular case, the box contains a laser, but it is equally applicable to a dry storage box or a humidor.
What you need: the equipment described in the section on the Arduino temperature and humidity sensor and those additional parts:
1) a dry air supply (if you want to have the box above surrounding temperature, you need a humidified air supply)
2) a solenoid valve + power supply
3) a relais loowing you to control the power to the valve via an Arduino 5V control output
Start with the Arduino temperature and humidity sensor project. For this project you don't necessarily need the display, but its nice for reading out without computer.
Test, if everything is working. If yes, load the following file on the Arduino via its IDE:
/*
Code that reads chipcap sensor and displays the rel. humidity and temperature on a 2x16 LCD display
created 2012
by Markus Guehr
*/
const int ledPin = 13; // the pin that the LED is attached to
const int relaisPin=8;
//here come the limits: in this version, the relative humidity will be stabilized by dry air(!) between 25 //and 30%
const float maxHumid=30; //this is the upper limit for the relative humidity, change this if you need
const float minHumid=25; //this is lower limit for the relative humidity, change this if you need
boolean sentinel;
int incomingByte; // a variable to read incoming serial data into
int sensorValue[2]; //this array will hold the readouts
const int maxCounter=10;// how many averages during aquisition
// include the library code:
#include <LiquidCrystal.h>
#include <stdlib.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup() {
// initialize serial communication:
Serial.begin(9600);
// initialize the LED pin as an output:
pinMode(ledPin, OUTPUT);
pinMode(relaisPin, OUTPUT);
analogReference(INTERNAL);
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.print("hello, world!");
sentinel=1;
}
void loop() {
// see if there's incoming serial data:
//if (Serial.available() > 0) {
// read the oldest byte in the serial buffer:
//incomingByte = Serial.read();
// if it's a capital H (ASCII 72), turn on the LED and measure the sensor value:
//if (incomingByte == 'H') {
//initialize the analog variables
int sensorValue[]={0,0};
for (int counter=1; counter<maxCounter+1; counter++){
for (int sensorCounter=0; sensorCounter<2; sensorCounter++){
sensorValue[sensorCounter] = sensorValue[sensorCounter] + analogRead(sensorCounter);
delay(50);
}
}
for (int sensorCounter=0; sensorCounter<2; sensorCounter++){
sensorValue[sensorCounter] = sensorValue[sensorCounter]/maxCounter;
}
for (int sensorCounter=0; sensorCounter<1; sensorCounter++){
Serial.print(sensorValue[sensorCounter]); //format in DEC -
Serial.print("\t");
}
Serial.println(sensorValue[1]); //format in DEC -
float humidity;
float temperature;
humidity=((float)sensorValue[1])/1023*1.1;//that is the voltage - reference is internal which means 1.1 V
humidity=humidity*100;//according to chipcap manual
temperature=((float)sensorValue[0])/1023*1.1;//that is the voltage - reference is internal which means 1.1 V
temperature=temperature*200-50;//according to chipcap manual
Serial.print(humidity); //format in DEC -
Serial.print("\t");
Serial.println(temperature); //format in DEC -
if (humidity >= maxHumid){
digitalWrite(ledPin, HIGH);
digitalWrite(relaisPin, HIGH);
sentinel=1;
}
else{
if (humidity < maxHumid && humidity > minHumid){
if (sentinel==1){
digitalWrite(ledPin, HIGH);
digitalWrite(relaisPin, HIGH);
}
if (sentinel==0){
digitalWrite(ledPin, LOW);
digitalWrite(relaisPin, LOW);
}
}
else{
digitalWrite(ledPin, LOW);
digitalWrite(relaisPin, LOW);
sentinel=0;
}
}
lcd.clear();
lcd.print("Rel.Hum.:");
lcd.print(humidity);
lcd.setCursor(0,1);
lcd.print("Temp.:");
lcd.print(temperature);
lcd.print("deg C");
}
Now comes the hardware part.
I use a commercial solenoid valve for pneumatics, but the one from Adafruit (http://www.adafruit.com/products/996) could also do it. Before you hook it up, just check your pressure rating and see if the valve can deal with it.
A power supply for this valve is recommended on the Adafruit website.
In order to control the valve by the arduino, I use a PowerSwitch Tail II, this is a box that already comes with wall and equipment plug and a relay in between that can be controlled by th eArduino 5V.
Hook up the (+) of the PowerSwitch Tails control input to your Arduino pin 8 and the (-) of the PowerSwitch Tails control input to the ground of the Arduino.
Now the solenoid should open or close depending on the humidity inside the box.
Simple Lab Stuff
Blog about open hardware use for simple data logging in labs. Use arduino, raspberry pi, python...
Wednesday, July 16, 2014
Friday, February 22, 2013
Arduino humidity and temperature sensor with display
This post describes a little sensor - in the particular case humidity and temperature - which is read by the arduino and writes to an LCD display. Its a nice low cost solution for monitoring without computer and the arduino also allows you to hook actuators up.
So one thing you can realize is a dry box; every time the humidity rises, a valve opens the flow of dry air or nitrogen.
Here is a foto of the device. The box contains an arduino for reading the sensor and controlling the LCD panel. In addition a piezo buzzer gives an optional audible alarm:
Lets start with the humidity and temperature sensor:
This is a chipcap from GE in analog mode - it delivers two output voltages that can be converted to relative humidity and temperature readings. The chip comes as a surface mount device, so soldering it on a breadboard is a bit tricky. The description contains a electric diagram for hooking it up.
Next, you need to feed the two analog voltages into your arduino, more precise into two AD converter inputs.
I chose to hook them up to A0 and A1 (lower right input row in the above photgraph). The chipcap also needs to be connected to the 5V and ground of the arduino to power it - see description. Pin 11 of the chipcap needs to be connected to 5V, pin 4 of the chipcap needs to be connected to the 5V via a 0.1 microF capacitance and to the arduino ground without a capacitance. That's it!
Now you need to connect the arduino to the LCD display, which I got from Sparkfun and which is compatible with Hitachi HD44780 driver in order to use the arduino LCD libraries.
Hook up the LCD to arduino according to the wiring diagram below.
The above is copied from the arduino LCD site .
Now that is done, you can upload the following code to your arduino and try the system out:
Arduino code:
/*
Code that reads chipcap sensor and displays the rel. humidity and temperature on a 2x16 LCD display
created 2012
by Markus Guehr
*/
const int ledPin = 13; // the pin that the LED is attached to
int incomingByte; // a variable to read incoming serial data into
int sensorValue[2]; //this array will hold the readouts
const int maxCounter=10;// how many averages during aquisition
// include the library code:
#include <LiquidCrystal.h>
#include <stdlib.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup() {
// initialize serial communication:
Serial.begin(9600);
// initialize the LED pin as an output:
pinMode(ledPin, OUTPUT);
analogReference(INTERNAL);
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.print("hello, world!");
}
void loop() {
// see if there's incoming serial data:
//if (Serial.available() > 0) {
// read the oldest byte in the serial buffer:
//incomingByte = Serial.read();
// if it's a capital H (ASCII 72), turn on the LED and measure the sensor value:
//if (incomingByte == 'H') {
digitalWrite(ledPin, HIGH);
//initialize the analog variables
int sensorValue[]={0,0};
for (int counter=1; counter<maxCounter+1; counter++){
for (int sensorCounter=0; sensorCounter<2; sensorCounter++){
sensorValue[sensorCounter] = sensorValue[sensorCounter] + analogRead(sensorCounter);
delay(50);
}
}
for (int sensorCounter=0; sensorCounter<2; sensorCounter++){
sensorValue[sensorCounter] = sensorValue[sensorCounter]/maxCounter;
}
for (int sensorCounter=0; sensorCounter<1; sensorCounter++){
Serial.print(sensorValue[sensorCounter]); //format in DEC -
Serial.print("\t");
}
Serial.println(sensorValue[1]); //format in DEC -
float humidity;
float temperature;
humidity=((float)sensorValue[1])/1023*1.1;//that is the voltage - reference is internal which means 1.1 V
humidity=humidity*100;//according to chipcap manual
temperature=((float)sensorValue[0])/1023*1.1;//that is the voltage - reference is internal which means 1.1 V
temperature=temperature*200-50;//according to chipcap manual
Serial.print(humidity); //format in DEC -
Serial.print("\t");
Serial.println(temperature); //format in DEC -
if (humidity > 50){
tone(8,100,100);//that is a buzzer connected to pin 8 of the arduino
}
lcd.clear();
lcd.print("Rel.Hum.:");
lcd.print(humidity);
lcd.setCursor(0,1);
lcd.print("Temp.:");
lcd.print(temperature);
lcd.print("deg C");
digitalWrite(ledPin, LOW);//turn LED off!
}
So now you should have the sensor values readable!
Please note - if you hook up a piezo buzzer on digital output 8 of the arduino, an alarm will be audible if you go above a certain threshold.
At this position you could also activate any other thing - like a purge valve.
So one thing you can realize is a dry box; every time the humidity rises, a valve opens the flow of dry air or nitrogen.
Here is a foto of the device. The box contains an arduino for reading the sensor and controlling the LCD panel. In addition a piezo buzzer gives an optional audible alarm:
This is a chipcap from GE in analog mode - it delivers two output voltages that can be converted to relative humidity and temperature readings. The chip comes as a surface mount device, so soldering it on a breadboard is a bit tricky. The description contains a electric diagram for hooking it up.
Next, you need to feed the two analog voltages into your arduino, more precise into two AD converter inputs.
I chose to hook them up to A0 and A1 (lower right input row in the above photgraph). The chipcap also needs to be connected to the 5V and ground of the arduino to power it - see description. Pin 11 of the chipcap needs to be connected to 5V, pin 4 of the chipcap needs to be connected to the 5V via a 0.1 microF capacitance and to the arduino ground without a capacitance. That's it!
Now you need to connect the arduino to the LCD display, which I got from Sparkfun and which is compatible with Hitachi HD44780 driver in order to use the arduino LCD libraries.
Hook up the LCD to arduino according to the wiring diagram below.
The above is copied from the arduino LCD site .
Now that is done, you can upload the following code to your arduino and try the system out:
Arduino code:
/*
Code that reads chipcap sensor and displays the rel. humidity and temperature on a 2x16 LCD display
created 2012
by Markus Guehr
*/
const int ledPin = 13; // the pin that the LED is attached to
int incomingByte; // a variable to read incoming serial data into
int sensorValue[2]; //this array will hold the readouts
const int maxCounter=10;// how many averages during aquisition
// include the library code:
#include <LiquidCrystal.h>
#include <stdlib.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup() {
// initialize serial communication:
Serial.begin(9600);
// initialize the LED pin as an output:
pinMode(ledPin, OUTPUT);
analogReference(INTERNAL);
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.print("hello, world!");
}
void loop() {
// see if there's incoming serial data:
//if (Serial.available() > 0) {
// read the oldest byte in the serial buffer:
//incomingByte = Serial.read();
// if it's a capital H (ASCII 72), turn on the LED and measure the sensor value:
//if (incomingByte == 'H') {
digitalWrite(ledPin, HIGH);
//initialize the analog variables
int sensorValue[]={0,0};
for (int counter=1; counter<maxCounter+1; counter++){
for (int sensorCounter=0; sensorCounter<2; sensorCounter++){
sensorValue[sensorCounter] = sensorValue[sensorCounter] + analogRead(sensorCounter);
delay(50);
}
}
for (int sensorCounter=0; sensorCounter<2; sensorCounter++){
sensorValue[sensorCounter] = sensorValue[sensorCounter]/maxCounter;
}
for (int sensorCounter=0; sensorCounter<1; sensorCounter++){
Serial.print(sensorValue[sensorCounter]); //format in DEC -
Serial.print("\t");
}
Serial.println(sensorValue[1]); //format in DEC -
float humidity;
float temperature;
humidity=((float)sensorValue[1])/1023*1.1;//that is the voltage - reference is internal which means 1.1 V
humidity=humidity*100;//according to chipcap manual
temperature=((float)sensorValue[0])/1023*1.1;//that is the voltage - reference is internal which means 1.1 V
temperature=temperature*200-50;//according to chipcap manual
Serial.print(humidity); //format in DEC -
Serial.print("\t");
Serial.println(temperature); //format in DEC -
if (humidity > 50){
tone(8,100,100);//that is a buzzer connected to pin 8 of the arduino
}
lcd.clear();
lcd.print("Rel.Hum.:");
lcd.print(humidity);
lcd.setCursor(0,1);
lcd.print("Temp.:");
lcd.print(temperature);
lcd.print("deg C");
digitalWrite(ledPin, LOW);//turn LED off!
}
So now you should have the sensor values readable!
Please note - if you hook up a piezo buzzer on digital output 8 of the arduino, an alarm will be audible if you go above a certain threshold.
At this position you could also activate any other thing - like a purge valve.
Subscribe to:
Posts (Atom)