icon

A Fresh Start: Building a Reliable Formaldehyde Sensor with SFA40

0 1592 Easy

When I moved into my new apartment, I did what many people do — I bought a ready-made air quality detector from the market to make sure my new home was safe.
But what I didn’t expect was how unreliable it would be. It constantly reported high formaldehyde levels, even when nothing unusual was happening. Even outdoors, it sometimes triggers an alarm.

One day it would scream “danger,” the next it would show “perfectly clean.” It was confusing and stressful — especially when you just want to feel at ease in your own home.

STEP 1
The Problem with Typical Sensors

After digging deeper, I realized that many consumer-grade formaldehyde sensors are easily affected by other volatile substances — like alcohol, perfume, or even citrus fruit. That means the readings often have nothing to do with formaldehyde at all.
A quick spray of perfume or a freshly peeled orange could trigger a “high formaldehyde” alarm. That’s when I knew: if I wanted reliable data, I needed to build a better sensor myself.

STEP 2
Building with DFRobot Gravity: SFA40 Sensor

DFRobot has released a Gravity-style module for the SFA40 sensor, allowing me to quickly connect it to my UNIHIKER K10. This enables direct reading of formaldehyde concentration on the screen.

HARDWARE LIST
1 UNIHIKER K10
1 PH2.0 4PIN cable
1 Gravity SFA40 HCHO Sensor
STEP 3
Hook it up

Connect the sensors, download the library provided by DFRobot according to the Gravity SFA40 wiki, and upload the sample code below.

For reference, the safe concentration range for formaldehyde under Chinese standards is 56 parts per billion (ppb).

(During the test below, I accidentally type ppm as the unit on the K10 display when it should have been ppb.)

CODE
#include "unihiker_k10.h"
#include "DFRobot_SFA40.h"

DFRobot_SFA40 SFA40 ;
UNIHIKER_K10        k10;
uint8_t             screen_dir=2;

void setup() {
	k10.begin();
	while(SFA40.begin()!=0){delay(1000);}
	SFA40.startMeasurement();
	k10.initScreen(screen_dir);
	k10.creatCanvas();
	delay(1000);
}
void loop() {
	SFA40.readMeasurementData();
	delay(1000);
	k10.canvas->canvasText((String((String("HCHO: ") + String(SFA40.HCHO))) + String(" ppb")), 1, 0x0000FF);
	k10.canvas->canvasText((String((String("Temp: ") + String(SFA40.temperatureC))) + String("℃")), 2, 0x0000FF);
	k10.canvas->canvasText((String((String("Humi: ") + String(SFA40.humidity))) + String("%")), 3, 0x0000FF);
	k10.canvas->updateCanvas();
}
STEP 4
Test with formalin solution

Formalin solution is produced by dissolving formaldehyde in water. I dipped a paper towel in the formalin solution, then placed the SFA40 sensor and the finished formaldehyde sensor inside a transparent container. Then wait for five minutes.
As I had anticipated, both the SFA40 readings and the finished formaldehyde sensor readings went off the charts. The values were extremely high.

STEP 5
Test with Alcohol

I cleaned and ventilated the box to eliminate residual formaldehyde gas molecules inside. Then I moistened a paper towel with alcohol and waited several minutes.
The finished formaldehyde sensor still registered maximum concentration, while the SFA40 formaldehyde concentration remained within normal levels.

STEP 6
Test with perfume

Finally, I repeated the experiment with perfume. To my surprise, the finished formaldehyde sensor still reacted to the perfume. The persistent beeping sound was really annoying…

License
All Rights
Reserved
licensBg
0