Grove SEN5X All in One
Introduction
Grove-all in one enviromental sensor SEN54/SEN55 is an integrated Grove ambient sensor, assembling 8 types of data signal output, sensing in high accuracy and operating for up to 10 years, borned for HVAC(Heating, Ventilation and Air Conditioning) and air quality long years detecting applications. In this wiki, we will introduce you how to utilize it while using Arduino and Raspberry Pi tools.
Feature
- Conperhensive environmental sensing functionality: Support PM (particulate matter), VOC (Volatile Organic Compounds), RH (Relative Humidity), Temp (temperature) all 5 environmental data signal continuously sensing
- One driver for up to 7/8 data signals: Deliver 4 types of PM and 4 primary ambeit signals through IIC function
- One wire for all data output: Represent Grove family simplified connection for only one Grove cable required between the sensor and the single board
- Superior sensing accuracy: Calibrate full digial signals to output
- Superior operating lifetime: Maintain fine performance up to 10 years
- Three modes available for deploying with the edge: Set up Idle Mode and RHT/Gas-Only Measurement Mode for low cost application where Measurement Mode is for full fcuntion
Hardware Overview
Getting Started
Grove-all in one enviromental sensor SEN54/SEN55 inherit Grove Series fine features as it can be drectly applied through Grove IIC interface.
Equipment Installation
Connect with Grove-all in one enviromental sensor SEN54/SEN55 with Grove cable.
Environmental Preparation
Since we use Arduino and Raspberry Pi here, it is required to run the module on the installed system:
Arduino Library Overview
If this is your first time using Arduino, we highly recommend you to refer to Getting Started with Arduino.
There are two libraries required to install while using the Arduino:
- arduino-i2c-sen5x(Main function of Grove-all in one enviromental sensor SEN54/SEN55)
- arduino-core(Core file / Dependencies)
Function
Before we get started developing a sketch, let's look at the available functions of the library.
Serial.begin(115200)
—— When the upload process has finished, open the Serial Monitor or Serial Plotter via the Tools menu to observe the measurement values. Note that the Baud Rate in the corresponding window has to be set to 115200 baud
Installation
Since you have downloaded the zip Library, open your Arduino IDE, click on Sketch > Include Library > Add .ZIP Library. Choose the zip file you just downloaded,and if the library install correct, you will see Library added to your libraries in the notice window. Which means the library is installed successfully.
Arduino Example
Now that we have our library installed and we understand the basic functions, let's run some examples for our Grove-all in one enviromental sensor SEN54/SEN55 to see how it behaves.
Step 1. Hardware Connection.
Step 2. You need to Install an Arduino Software.
Step 3. Launch the Arduino application.
Demo 1 Sense 4 types of PM and 4 primary ambeit signals
This demo can detect 4 types of PM (particulate matter), VOC (Volatile Organic Compounds), RH (Relative Humidity), Temp (temperature) and then display on the monitor, showing whether the place where the moudle mounted is health.
Materials Required
Seeeduino V4.2 | Base Shield | SEN54/SEN55 |
---|---|---|
Get ONE Now | Get ONE Now | Get ONE Now |
/*
* I2C-Generator: 0.3.0
* Yaml Version: 2.1.3
* Template Version: 0.7.0-112-g190ecaa
*/
/*
* Copyright (c) 2021, Sensirion AG
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* * Neither the name of Sensirion AG nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <Arduino.h>
#include <SensirionI2CSen5x.h>
#include <Wire.h>
// The used commands use up to 48 bytes. On some Arduino's the default buffer
// space is not large enough
#define MAXBUF_REQUIREMENT 48
#if (defined(I2C_BUFFER_LENGTH) && \
(I2C_BUFFER_LENGTH >= MAXBUF_REQUIREMENT)) || \
(defined(BUFFER_LENGTH) && BUFFER_LENGTH >= MAXBUF_REQUIREMENT)
#define USE_PRODUCT_INFO
#endif
SensirionI2CSen5x sen5x;
void printModuleVersions() {
uint16_t error;
char errorMessage[256];
unsigned char productName[32];
uint8_t productNameSize = 32;
error = sen5x.getProductName(productName, productNameSize);
if (error) {
Serial.print("Error trying to execute getProductName(): ");
errorToString(error, errorMessage, 256);
Serial.println(errorMessage);
} else {
Serial.print("ProductName:");
Serial.println((char*)productName);
}
uint8_t firmwareMajor;
uint8_t firmwareMinor;
bool firmwareDebug;
uint8_t hardwareMajor;
uint8_t hardwareMinor;
uint8_t protocolMajor;
uint8_t protocolMinor;
error = sen5x.getVersion(firmwareMajor, firmwareMinor, firmwareDebug,
hardwareMajor, hardwareMinor, protocolMajor,
protocolMinor);
if (error) {
Serial.print("Error trying to execute getVersion(): ");
errorToString(error, errorMessage, 256);
Serial.println(errorMessage);
} else {
Serial.print("Firmware: ");
Serial.print(firmwareMajor);
Serial.print(".");
Serial.print(firmwareMinor);
Serial.print(", ");
Serial.print("Hardware: ");
Serial.print(hardwareMajor);
Serial.print(".");
Serial.println(hardwareMinor);
}
}
void printSerialNumber() {
uint16_t error;
char errorMessage[256];
unsigned char serialNumber[32];
uint8_t serialNumberSize = 32;
error = sen5x.getSerialNumber(serialNumber, serialNumberSize);
if (error) {
Serial.print("Error trying to execute getSerialNumber(): ");
errorToString(error, errorMessage, 256);
Serial.println(errorMessage);
} else {
Serial.print("SerialNumber:");
Serial.println((char*)serialNumber);
}
}
void setup() {
Serial.begin(115200);
while (!Serial) {
delay(100);
}
Wire.begin();
sen5x.begin(Wire);
uint16_t error;
char errorMessage[256];
error = sen5x.deviceReset();
if (error) {
Serial.print("Error trying to execute deviceReset(): ");
errorToString(error, errorMessage, 256);
Serial.println(errorMessage);
}
// Print SEN55 module information if i2c buffers are large enough
#ifdef USE_PRODUCT_INFO
printSerialNumber();
printModuleVersions();
#endif
// set a temperature offset in degrees celsius
// Note: supported by SEN54 and SEN55 sensors
// By default, the temperature and humidity outputs from the sensor
// are compensated for the modules self-heating. If the module is
// designed into a device, the temperature compensation might need
// to be adapted to incorporate the change in thermal coupling and
// self-heating of other device components.
//
// A guide to achieve optimal performance, including references
// to mechanical design-in examples can be found in the app note
// “SEN5x – Temperature Compensation Instruction” at www.sensirion.com.
// Please refer to those application notes for further information
// on the advanced compensation settings used
// in `setTemperatureOffsetParameters`, `setWarmStartParameter` and
// `setRhtAccelerationMode`.
//
// Adjust tempOffset to account for additional temperature offsets
// exceeding the SEN module's self heating.
float tempOffset = 0.0;
error = sen5x.setTemperatureOffsetSimple(tempOffset);
if (error) {
Serial.print("Error trying to execute setTemperatureOffsetSimple(): ");
errorToString(error, errorMessage, 256);
Serial.println(errorMessage);
} else {
Serial.print("Temperature Offset set to ");
Serial.print(tempOffset);
Serial.println(" deg. Celsius (SEN54/SEN55 only");
}
// Start Measurement
error = sen5x.startMeasurement();
if (error) {
Serial.print("Error trying to execute startMeasurement(): ");
errorToString(error, errorMessage, 256);
Serial.println(errorMessage);
}
}
void loop() {
uint16_t error;
char errorMessage[256];
delay(1000);
// Read Measurement
float massConcentrationPm1p0;
float massConcentrationPm2p5;
float massConcentrationPm4p0;
float massConcentrationPm10p0;
float ambientHumidity;
float ambientTemperature;
float vocIndex;
float noxIndex;
error = sen5x.readMeasuredValues(
massConcentrationPm1p0, massConcentrationPm2p5, massConcentrationPm4p0,
massConcentrationPm10p0, ambientHumidity, ambientTemperature, vocIndex,
noxIndex);
if (error) {
Serial.print("Error trying to execute readMeasuredValues(): ");
errorToString(error, errorMessage, 256);
Serial.println(errorMessage);
} else {
Serial.print("MassConcentrationPm1p0:");
Serial.print(massConcentrationPm1p0);
Serial.print("\t");
Serial.print("MassConcentrationPm2p5:");
Serial.print(massConcentrationPm2p5);
Serial.print("\t");
Serial.print("MassConcentrationPm4p0:");
Serial.print(massConcentrationPm4p0);
Serial.print("\t");
Serial.print("MassConcentrationPm10p0:");
Serial.print(massConcentrationPm10p0);
Serial.print("\t");
Serial.print("AmbientHumidity:");
if (isnan(ambientHumidity)) {
Serial.print("n/a");
} else {
Serial.print(ambientHumidity);
}
Serial.print("\t");
Serial.print("AmbientTemperature:");
if (isnan(ambientTemperature)) {
Serial.print("n/a");
} else {
Serial.print(ambientTemperature);
}
Serial.print("\t");
Serial.print("VocIndex:");
if (isnan(vocIndex)) {
Serial.print("n/a");
} else {
Serial.print(vocIndex);
}
Serial.print("\t");
Serial.print("NoxIndex:");
if (isnan(noxIndex)) {
Serial.println("n/a");
} else {
Serial.println(noxIndex);
}
}
}
Result
After uploading the codes, we can open serial monitor as 115200 baud rate and it should show all eight types of signals.
Python Package Overview
If this is your first time using Raspberry Pi, we highly recommend you to refer to Getting Started with Raspberry Pi.
This package supports SEN50, SEN54, SEN55 sensor, enabling you to detect environmental data while using Raspberry Pi.
Function
Raspberry Pi Example
Now that we have our library installed and we understand the basic functions, let's run some examples for our Grove-all in one enviromental sensor SEN54/SEN55 to see how it behaves.
Step 1. Hardware Connection.
Step 2. Install the Raspberry Pi OS on to your Raspberry Pi.
Step 3. Enable the I2C interface in the raspi-config.
Step 4. Download the driver form the Sensirion Github Page like above and extract the .zip
on your Raspberry Pi.
Demo 1 Apply the function example with Raspberry Pi
The demoe will help you sense various environment data in your area.
Materials Required
Get ONE Now | Get ONE Now |
Compile the driver:
Step 1. Open a terminal
Step 2. Navigate to the driver directory. E.g. cd ~/raspberry-pi-i2c-sen5x.
Step 3. Run the make
command to compile the driver.
Step 4. Run ./sen5x_i2c_example_usage
in the same directory you used to compile the driver.
//sen5x_i2c_example_usage.c
/*
* I2C-Generator: 0.3.0
* Yaml Version: 2.1.3
* Template Version: 0.7.0-109-gb259776
*/
/*
* Copyright (c) 2021, Sensirion AG
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* * Neither the name of Sensirion AG nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <math.h> // NAN
#include <stdio.h> // printf
#include "sen5x_i2c.h"
#include "sensirion_common.h"
#include "sensirion_i2c_hal.h"
/*
* TO USE CONSOLE OUTPUT (PRINTF) YOU MAY NEED TO ADAPT THE INCLUDE ABOVE OR
* DEFINE IT ACCORDING TO YOUR PLATFORM:
* #define printf(...)
*/
int main(void) {
int16_t error = 0;
sensirion_i2c_hal_init();
error = sen5x_device_reset();
if (error) {
printf("Error executing sen5x_device_reset(): %i\n", error);
}
unsigned char serial_number[32];
uint8_t serial_number_size = 32;
error = sen5x_get_serial_number(serial_number, serial_number_size);
if (error) {
printf("Error executing sen5x_get_serial_number(): %i\n", error);
} else {
printf("Serial number: %s\n", serial_number);
}
unsigned char product_name[32];
uint8_t product_name_size = 32;
error = sen5x_get_product_name(product_name, product_name_size);
if (error) {
printf("Error executing sen5x_get_product_name(): %i\n", error);
} else {
printf("Product name: %s\n", product_name);
}
uint8_t firmware_major;
uint8_t firmware_minor;
bool firmware_debug;
uint8_t hardware_major;
uint8_t hardware_minor;
uint8_t protocol_major;
uint8_t protocol_minor;
error = sen5x_get_version(&firmware_major, &firmware_minor, &firmware_debug,
&hardware_major, &hardware_minor, &protocol_major,
&protocol_minor);
if (error) {
printf("Error executing sen5x_get_version(): %i\n", error);
} else {
printf("Firmware: %u.%u, Hardware: %u.%u\n", firmware_major,
firmware_minor, hardware_major, hardware_minor);
}
// set a temperature offset in degrees celsius
// Note: supported by SEN54 and SEN55 sensors
// By default, the temperature and humidity outputs from the sensor
// are compensated for the modules self-heating. If the module is
// designed into a device, the temperature compensation might need
// to be adapted to incorporate the change in thermal coupling and
// self-heating of other device components.
//
// A guide to achieve optimal performance, including references
// to mechanical design-in examples can be found in the app note
// “SEN5x – Temperature Compensation Instruction” at www.sensirion.com.
// Please refer to those application notes for further information
// on the advanced compensation settings used in
// `sen5x_set_temperature_offset_parameters`,
// `sen5x_set_warm_start_parameter` and `sen5x_set_rht_acceleration_mode`.
//
// Adjust temp_offset to account for additional temperature offsets
// exceeding the SEN module's self heating.
float temp_offset = 0.0f;
error = sen5x_set_temperature_offset_simple(temp_offset);
if (error) {
printf("Error executing sen5x_set_temperature_offset_simple(): %i\n",
error);
} else {
printf("Temperature Offset set to %.2f °C (SEN54/SEN55 only)\n",
temp_offset);
}
// Start Measurement
error = sen5x_start_measurement();
if (error) {
printf("Error executing sen5x_start_measurement(): %i\n", error);
}
for (int i = 0; i < 600; i++) {
// Read Measurement
sensirion_i2c_hal_sleep_usec(1000000);
float mass_concentration_pm1p0;
float mass_concentration_pm2p5;
float mass_concentration_pm4p0;
float mass_concentration_pm10p0;
float ambient_humidity;
float ambient_temperature;
float voc_index;
float nox_index;
error = sen5x_read_measured_values(
&mass_concentration_pm1p0, &mass_concentration_pm2p5,
&mass_concentration_pm4p0, &mass_concentration_pm10p0,
&ambient_humidity, &ambient_temperature, &voc_index, &nox_index);
if (error) {
printf("Error executing sen5x_read_measured_values(): %i\n", error);
} else {
printf("Mass concentration pm1p0: %.1f µg/m³\n",
mass_concentration_pm1p0);
printf("Mass concentration pm2p5: %.1f µg/m³\n",
mass_concentration_pm2p5);
printf("Mass concentration pm4p0: %.1f µg/m³\n",
mass_concentration_pm4p0);
printf("Mass concentration pm10p0: %.1f µg/m³\n",
mass_concentration_pm10p0);
if (isnan(ambient_humidity)) {
printf("Ambient humidity: n/a\n");
} else {
printf("Ambient humidity: %.1f %%RH\n", ambient_humidity);
}
if (isnan(ambient_temperature)) {
printf("Ambient temperature: n/a\n");
} else {
printf("Ambient temperature: %.1f °C\n", ambient_temperature);
}
if (isnan(voc_index)) {
printf("Voc index: n/a\n");
} else {
printf("Voc index: %.1f\n", voc_index);
}
if (isnan(nox_index)) {
printf("Nox index: n/a\n");
} else {
printf("Nox index: %.1f\n", nox_index);
}
}
}
error = sen5x_stop_measurement();
if (error) {
printf("Error executing sen5x_stop_measurement(): %i\n", error);
}
return 0;
}
Result
The output should be like:
Resource
Tech Support & Product Discussion
Upgradable to Industrial Sensors
With the SenseCAP S2110 controller and S2100 data logger, you can easily turn the Grove into a LoRaWAN® sensor. Seeed not only helps you with prototyping but also offers you the possibility to expand your project with the SenseCAP series of robust industrial sensors.
The IP66 housing, Bluetooth configuration, compatibility with the global LoRaWAN® network, built-in 19 Ah battery, and powerful support from APP make the SenseCAP S210x the best choice for industrial applications. The series includes sensors for soil moisture, air temperature and humidity, light intensity, CO2, EC, and an 8-in-1 weather station. Try the latest SenseCAP S210x for your next successful industrial project.