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.
No comments:
Post a Comment