edit

Grove - Formaldehyde Sensor

Grove Formaldehyde Sensor can detect formaldehyde around 0~1000 ppb with low cross-sensitivity to alcohol and high stability of 6 years lifetime. Built-in RHT sensor ensures it maintains fine performance under different temperatures and humidity and it transmits data through UART and I2C ports.

Features

  • Low cross-sensitivity to alcohol
  • Standard formaldehyde measurement range: 0 ~ 1000 ppb
  • Long-term stability and 6 years’ service lifetime
  • Patented electrochemical cell with anti-dry technology
  • I2C/UART interface with lifetime-calibrated output
  • Maintain performance under different temperatures and humidity: compensated via Sensirion RHT sensor

Specification

Parameter Value/Range
Supply voltage range 3.3V or 5V
Measurement range 0 to 1,000 ppb
Response time <2 min
Limit of detection <20 ppb
Interface I2C / UART
Formaldehyde accuracy ±20 ppb or ±20% of measured value, whichever is larger

Platforms Supported

Arduino Raspberry Pi

Caution

The platforms mentioned above as supported is/are an indication of the module's software or theoritical compatibility. We only provide software library or code examples for Arduino platform in most cases. It is not possible to provide software library / demo code for all possible MCU platforms. Hence, users have to write their own software library.

Getting Started

Note

If this is the first time you work with Arduino, we highly recommend you to see Getting Started with Arduino before the start.

Play With Arduino

Hardware

  • Step 1. Prepare the below stuffs:
Seeeduino V4.2 Base Shield Grove-Formaldehyde Sensor
enter image description here enter image description here enter image description here
Get One Now Get One Now Get One Now
  • Step 2. Set the button on the Grove-Formaldehyde Sensor to the "1" position.

  • Step 3. Plug Grove - Base Shield into Seeeduino and set Grove-Formaldehyde Sensor to I²C port of Grove-Base Shield
  • Step 4. Connect Seeeduino to PC via a USB cable.

Note

If you don't have Grove Base Shield, it still can be directly connected Grove-Formaldehyde Sensor to Seeeduino as below.

Seeeduino Grove-Loudness Sensor
5V Red
GND Black
SDA White
SCL Yellow

Software

#include <Arduino.h>
#include <SensirionI2CSfa3x.h>
#include <Wire.h>

SensirionI2CSfa3x sfa3x;

void setup() {

    Serial.begin(115200);
    while (!Serial) {
        delay(100);
    }

    Wire.begin();

    uint16_t error;
    char errorMessage[256];

    sfa3x.begin(Wire);

    // Start Measurement
    error = sfa3x.startContinuousMeasurement();
    if (error) {
        Serial.print("Error trying to execute startContinuousMeasurement(): ");
        errorToString(error, errorMessage, 256);
        Serial.println(errorMessage);
    }
}

void loop() {
    uint16_t error;
    char errorMessage[256];

    delay(1000);
    int16_t hcho;
    int16_t humidity;
    int16_t temperature;
    error = sfa3x.readMeasuredValues(hcho, humidity, temperature);
    if (error) {
        Serial.print("Error trying to execute readMeasuredValues(): ");
        errorToString(error, errorMessage, 256);
        Serial.println(errorMessage);
    } else {
        Serial.print("Hcho:");
        Serial.print(hcho / 5.0);
        Serial.print("\t");
        Serial.print("Humidity:");
        Serial.print(humidity / 100.0);
        Serial.print("\t");
        Serial.print("Temperature:");
        Serial.println(temperature / 200.0);
    }
}
  • Step 4. In this program, Seeeduino can monitor the formaldehyde gas concentration, air humidity and temperature data in real-time. By opening the 'Serial Monitor', the results should be like:

Play With Raspberry Pi

Hardware

  • Step 1. Prepare the below stuffs:
Raspberry pi Grove Base Hat for Raspberry Pi Grove-Formaldehyde Sensor
enter image description here enter image description here enter image description here
Get One Now Get One Now Get One Now
  • Step 2. Plug the Grove Base Hat for Raspberry Pi into Raspberry Pi.
  • Step 3. Connect Grove-Dust Sensor to I²C port of Grove Base Hat for Raspberry Pi.
  • Step 4. Connect the Raspberry Pi to PC through a USB cable.

Software

  • Step 1. Follow Setting Software to configure the development environment of Resberry Pi.
  • Step 2. Download the Grove-Formaldehyde Sensor Library and unzip it to the Raspberry Pi.

  • Step 3. Navigate to the demos' directory. The following command can monitor the concentration of formaldehyde, humidity and temperature.

cd ~/embedded-sfa3x-main/i2c
make
./sfa3x_i2c_example_usage

Tip

In this wiki we use the path ~/embedded-sfa3x-main/i2c instead of /home/pi/Desktop/embedded-sfa3x-main/i2c, you need to make sure Step 2 and Step 3 use the same path.

Here is the sfa3x_i2c_example_usage.c code.

#include <stdio.h>  // printf

#include "sensirion_common.h"
#include "sensirion_i2c_hal.h"
#include "sfa3x_i2c.h"

/**
 * TO USE CONSOLE OUTPUT (PRINTF) IF NOT PRESENT ON YOUR PLATFORM
 */
//#define printf(...)

int main(void) {
    int16_t error = 0;

    sensirion_i2c_hal_init();

    error = sfa3x_device_reset();
    if (error) {
        printf("Error resetting device: %i\n", error);
        return -1;
    }

    uint8_t device_marking[42];
    error = sfa3x_get_device_marking(&device_marking[0], sizeof(device_marking));
    if (error) {
        printf("Error getting device marking: %i\n", error);
        return -1;
    }
    printf("Device marking: %s\n", device_marking);

    // Start Measurement
    error = sfa3x_start_continuous_measurement();
    if (error) {
        printf("Error executing sfa3x_start_continuous_measurement(): %i\n",
               error);
    }

    for (;;) {
        // Read Measurement

        int16_t hcho;
        int16_t humidity;
        int16_t temperature;

        sensirion_i2c_hal_sleep_usec(500000);

        error = sfa3x_read_measured_values(&hcho, &humidity, &temperature);

        if (error) {
            printf("Error executing sfa3x_read_measured_values(): %i\n", error);
        } else {
            printf("Measurement:\n");
            printf("  Formaldehyde concentration: %.1f\n", hcho / 5.0f);
            printf("  Relative humidity: %.2f\n", humidity / 100.0f);
            printf("  Temperature: %.2f\n", temperature / 200.0f);
        }
    }

    error = sfa3x_stop_measurement();
    if (error) {
        printf("Error executing sfa3x_stop_measurement(): %i\n", error);
    }

    return 0;
}

Success

If everything goes well, the following results can be displayed like:

pi@raspberrypi:~/Downloads/embedded-sfa3x-main/i2c $ ./sfa3x_i2c_example_usage
Device marking: 211117825F073B80
Measurement:
  Formaldehyde concentration: 0.0
  Relative humidity: 70.19
  Temperature: 27.41
You can quit this program by simply press Ctrl+C.