Introduction: Simple Arduino Formaldehyde Sensor

Have you ever been smoking an eCigarette and wondered "Just how bad is this for me?" Well now you can find out how bad it really is, by measuring the amount of formaldehyde your setup produces. Formaldehyde (HCHO) is produced when the extreme heat of the coils in the eCigarette touches the glycerol (VG) and propylene glycol (PG), causing them to break down into harmful chemicals like HCHO.

Now you can find out just how much formaldehyde is produced by your favorite smoking method.

Though this tutorial does not involve working with formaldehyde and you've already been inhaling it the whole time with your various smoking devices, I'd just like to say:

DISCLAIMER: I AM NOT RESPONSIBLE FOR ANY DAMAGE TO YOUR HEALTH AS A RESULT OF USING THIS PRODUCT. FORMALDEHYDE IS CARCINOGENIC AND SHOULD NOT BE USED IN ANY WAY RELATED TO CONSUMPTION, INHALATION OR OTHERWISE. USE AT YOUR OWN RISK.

Step 1: Collect Parts

For this project you will need these items at minimum:

x1 Arduino board (Mega or Uno both work)

x1 Base shield

x1 Seeed HCHO Sensor

x1 computer w/ Arduino IDE

x1 USB B cable (or whichever cable the Arduino requires)

all available at www.seeedstudio.com

It would be recommended to add a screen so that the computer is no longer necessary after uploading the code, but I will not cover adding this yet.

Step 2: Assemble Hardware

1. Plug Base shield into Arduino

2. Use the included cable from the HCHO Sensor to plug the sensor into port A0 of the Base Shield

Step 3: (Optional) Make a Tube for Regulated Puffs

If you are using this sensor to test the formaldehyde levels in eCigarettes like I am, it would be wise to construct a tube through which to blow on the sensor at a constant distance. It would be helpful to use a tube with closed ends and thin, workable plastic. This is especially recommended if you are trying to compare devices or smoking methods, e.g. eCigarette vs. cigarette

1. Cut the tube to about an inch and a half long

2. Cut a small hole along the side of the tube near the bottom to allow air/vapor/smoke to escape

3. Cut a small hole on the bottom of the tube that will fit over sensor, as close the edge of the tube as possible (you may have to scrape the inside/outside of the tube to get it to fit over the sensor and between the other parts)

4. CAREFULLY AND GENTLY work the tube over the sensor, the small hole over the circular metal part (the actual sensor)

Step 4: Code

The sensor has the capacity to detect formaldehyde, benzene, toluene and other volatile organic compounds but I only derived the formula for formaldehyde (No formulas given, you have to look at the picture on the sensor's information page for other chemicals)

1. Plug the assembled Arduino into computer and load up Arduino IDE

2. Upload this code to the board:

// Grove HCHO Sensor

void setup() {

Serial.begin(9600); // Begin serial output

}

void loop() {

float Vi = 0.1;

float Vc = 4.95; // Constant voltage from pin

int sensorValue = analogRead(A0); // Read analog pin for voltage info in 10 bits

float Vf = sensorValue * 4.95 / 1023; // Voltage through pin when in presence of VOCs (formaldehyde)

Serial.print("Vi: ");

Serial.println(sensorValue * 4.95 / 1023);

Serial.print("Formaldehyde Concentration: ");

Serial.print(concentrationPPMform(Vf, Vi));

Serial.print("ppm\n"); // Print concentration data

delay(500); // Delay 0.5 seconds

}

float concentrationPPMform(float V, float Vstart) // Formaldehde concentration formula

{

float con = 212.32619543773774 * exp( -( 7.653015806367451 * (4.95 - V) * Vstart ) / ( V * (4.95 - Vstart) ) );

return con;

}

Step 5: Calibrate

1. Before testing, open up the Serial Window and view the output called "Vi" (in the presence of only air and no formaldehyde, this value is around 0.1V or 0.2V for me)

2. Calibrate by changing the value of Vi at the beginning of the loop in the code to the value seen in the Serial Window (use the lowest value you see)

Step 6: Test It Out

Time to see how bad smoking an eCigarette (or any other kind of smoking) really is for you

1. Connect Arduino and open the Serial Window

(If you are testing a smoking device)

2. Inhale normally from device, but try to keep most of the smoke in your mouth to minimize absorption

3. Exhale slowly into tube, letting all smoke pass through it

4. Go back through Serial Window (turn off autoscroll) and look for the highest value outputted

5. That's how bad it is for you! (My eCigarette mod blew about 180ppm formaldehyde at 4.2V on exhale, as bad as a rolled and unfiltered cigarette)

(If you simply want to check ambient air quality)

2. Do not use tube

3. Make sure to calibrate in an open air setting

4. Bring to testing area

5. Allow to sit about 5 minutes, then check the Serial Window for the value

Step 7: Resources & Product Links