You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/hardware/06.nicla/boards/nicla-sense-env/tutorials/environmental-monitor-application-note/content.md
+40-83Lines changed: 40 additions & 83 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -91,23 +91,18 @@ The complete example sketch is shown below.
91
91
92
92
```arduino
93
93
/**
94
-
Outdoor Air Quality Monitoring with Arduin
94
+
Outdoor Air Quality Monitoring with Arduino
95
95
Name: outdoor_air_quality_monitor.ino
96
-
Purpose: This sketch reads temperature, humidity, outdoor air quality,
97
-
and particulate matter (PM 2.5 and PM 10) from the Nicla Sense Env
98
-
and a PMS7003 sensor from Plantower connected to the Portenta C33 board.
99
-
The data is reported Arduino IDE's Serial Monitor every 10 seconds.
96
+
Purpose: This sketch reads temperature, humidity, and outdoor air quality
97
+
from the Nicla Sense Env connected to the Portenta C33 board.
98
+
The data is reported to the Arduino IDE's Serial Monitor every 10 seconds.
100
99
101
100
@version 1.0 01/09/24
102
101
@author Arduino Product Experience Team
103
102
*/
104
103
105
-
// Include the necessary libraries for Nicla Sense Env and PMS7003 sensors
104
+
// Include the necessary libraries for Nicla Sense Env sensors
106
105
#include "Arduino_NiclaSenseEnv.h"
107
-
#include "PMS.h"
108
-
109
-
// PMS sensor object for particle matter measurements
110
-
PMS pms(Serial);
111
106
112
107
// Time interval (in milliseconds) for sensor readings of 10 seconds
113
108
static const uint32_t READ_INTERVAL = 10000;
@@ -145,10 +140,6 @@ void setup() {
145
140
// Error message if the Nicla Sense Env is not found
146
141
Serial.println("- ERROR: Nicla Sense Env device not found!");
147
142
}
148
-
149
-
// Initialize PMS7003 sensor in passive mode
150
-
pms.passiveMode();
151
-
pms.wakeUp();
152
143
}
153
144
154
145
/**
@@ -170,42 +161,30 @@ void loop() {
170
161
}
171
162
172
163
/**
173
-
Displays temperature, humidity, air quality, and particulate matter data.
174
-
Reads data from the Nicla Sense Env and PMS7003 sensors and prints it in a single line format.
164
+
Displays temperature, humidity, and air quality data.
165
+
Reads data from the Nicla Sense Env and prints it in a single line format.
175
166
*/
176
167
void displayAllData() {
177
168
// Check if both temperature/humidity and air quality sensors are enabled
178
169
if (tempHumSensor->enabled() && airQualitySensor->enabled()) {
179
170
// Read data from the Nicla Sense Env sensors
180
171
float temperature = tempHumSensor->temperature();
181
172
float humidity = tempHumSensor->humidity();
182
-
int airQualityIndex = airQualitySensor->airQualityIndex();
183
173
float NO2 = airQualitySensor->NO2();
184
174
float O3 = airQualitySensor->O3();
175
+
int airQualityIndex = airQualitySensor->airQualityIndex();
185
176
186
-
// Read data from the PMS7003 sensor
187
-
PMS::DATA data;
188
-
pms.requestRead();
189
-
if (pms.readUntil(data)) {
190
-
// Print all sensor data in a single line, separated by commas
191
-
Serial.print("- Temperature: ");
192
-
Serial.print(temperature, 2);
193
-
Serial.print(" °C, Humidity: ");
194
-
Serial.print(humidity, 2);
195
-
Serial.print(" %, Air Quality Index: ");
196
-
Serial.print(airQualityIndex);
197
-
Serial.print(", NO2: ");
198
-
Serial.print(NO2, 2);
199
-
Serial.print(" ppb, O3: ");
200
-
Serial.print(O3, 2);
201
-
Serial.print(" ppb, PM 2.5: ");
202
-
Serial.print(data.PM_AE_UG_2_5);
203
-
Serial.print(" µg/m³, PM 10: ");
204
-
Serial.println(data.PM_AE_UG_10_0);
205
-
} else {
206
-
// Error message if PMS7003 data is not available
207
-
Serial.println("- ERROR: No data from PMS sensor!");
208
-
}
177
+
// Print all sensor data in a single line, with AQI at the end
178
+
Serial.print("- Temperature: ");
179
+
Serial.print(temperature, 2);
180
+
Serial.print(" °C, Humidity: ");
181
+
Serial.print(humidity, 2);
182
+
Serial.print(" %, NO2: ");
183
+
Serial.print(NO2, 2);
184
+
Serial.print(" ppb, O3: ");
185
+
Serial.print(O3, 2);
186
+
Serial.print(" ppb, Air Quality Index: ");
187
+
Serial.println(airQualityIndex);
209
188
} else {
210
189
// Error message if one or more sensors are disabled
211
190
Serial.println("- ERROR: One or more sensors are disabled!");
@@ -222,15 +201,11 @@ The following sections will help you to understand the main parts of the example
222
201
223
202
### Library Imports
224
203
225
-
The first step is to ensure that all necessary libraries are included to control the Nicla Sense Env board and the PMS7003 sensor. These libraries provide all the functionality to communicate with and extract sensor data.
204
+
The first step is to ensure that all necessary libraries are included to control the Nicla Sense Env board. These libraries provide all the functionality to communicate with and extract sensor data.
226
205
227
206
```arduino
228
-
// Include the necessary libraries for Nicla Sense Env and PMS7003 sensors
207
+
// Include the necessary libraries for Nicla Sense Env sensors
229
208
#include "Arduino_NiclaSenseEnv.h"
230
-
#include "PMS.h"
231
-
232
-
// PMS sensor object for particle matter measurements
233
-
PMS pms(Serial);
234
209
235
210
// Time interval (in milliseconds) for sensor readings of 10 seconds
The Nicla Sense Env library handles data such as temperature, humidity, and outdoor air quality, while the PMS7003 library enables the measurement of airborne particulate matter.
220
+
The Nicla Sense Env library handles data such as temperature, humidity, and outdoor air quality, including also the NO2 and O3 gas concentrations.
246
221
247
222
### Sensors Initialization
248
223
@@ -270,18 +245,13 @@ void setup() {
270
245
// Error message if the Nicla Sense Env is not found
271
246
Serial.println("- ERROR: Nicla Sense Env device not found!");
272
247
}
273
-
274
-
// Initialize PMS7003 sensor in passive mode
275
-
pms.passiveMode();
276
-
pms.wakeUp();
277
248
}
278
249
```
279
250
280
251
In the code snippet shown before:
281
252
282
253
- Serial communication is initialized to allow data transmission.
283
-
- The Nicla Sense Env board is initialized to read temperature, humidity, and outdoor air quality.
284
-
- The PMS7003 sensor is configured in passive mode, which means it will only take readings when specifically requested.
254
+
- The Nicla Sense Env board is initialized to read temperature, humidity and the outdoor air quality index (AQI).
285
255
286
256
### Data Collection
287
257
@@ -318,33 +288,21 @@ void displayAllData() {
318
288
// Read data from the Nicla Sense Env sensors
319
289
float temperature = tempHumSensor->temperature();
320
290
float humidity = tempHumSensor->humidity();
321
-
int airQualityIndex = airQualitySensor->airQualityIndex();
322
291
float NO2 = airQualitySensor->NO2();
323
292
float O3 = airQualitySensor->O3();
293
+
int airQualityIndex = airQualitySensor->airQualityIndex();
324
294
325
-
// Read data from the PMS7003 sensor
326
-
PMS::DATA data;
327
-
pms.requestRead();
328
-
if (pms.readUntil(data)) {
329
-
// Print all sensor data in a single line, separated by commas
330
-
Serial.print("- Temperature: ");
331
-
Serial.print(temperature, 2);
332
-
Serial.print(" °C, Humidity: ");
333
-
Serial.print(humidity, 2);
334
-
Serial.print(" %, Air Quality Index: ");
335
-
Serial.print(airQualityIndex);
336
-
Serial.print(", NO2: ");
337
-
Serial.print(NO2, 2);
338
-
Serial.print(" ppb, O3: ");
339
-
Serial.print(O3, 2);
340
-
Serial.print(" ppb, PM 2.5: ");
341
-
Serial.print(data.PM_AE_UG_2_5);
342
-
Serial.print(" µg/m³, PM 10: ");
343
-
Serial.println(data.PM_AE_UG_10_0);
344
-
} else {
345
-
// Error message if PMS7003 data is not available
346
-
Serial.println("- ERROR: No data from PMS sensor!");
347
-
}
295
+
// Print all sensor data in a single line, with AQI at the end
296
+
Serial.print("- Temperature: ");
297
+
Serial.print(temperature, 2);
298
+
Serial.print(" °C, Humidity: ");
299
+
Serial.print(humidity, 2);
300
+
Serial.print(" %, NO2: ");
301
+
Serial.print(NO2, 2);
302
+
Serial.print(" ppb, O3: ");
303
+
Serial.print(O3, 2);
304
+
Serial.print(" ppb, Air Quality Index: ");
305
+
Serial.println(airQualityIndex);
348
306
} else {
349
307
// Error message if one or more sensors are disabled
350
308
Serial.println("- ERROR: One or more sensors are disabled!");
@@ -355,23 +313,22 @@ void displayAllData() {
355
313
In the code snippet shown before:
356
314
357
315
- The function first checks that the temperature/humidity sensor and the air quality sensor are enabled.
358
-
- The function retrieves temperature, humidity, air quality index, and gas concentrations (NO2 and O3) from the Nicla Sense Env board.
359
-
- The function also fetches PM2.5 and PM10 particulate readings from the PMS7003 sensor.
360
-
- Finally, the data is printed in a single line on the IDE's Serial Monitor.
316
+
- The function retrieves temperature, humidity, gas concentrations (NO2 and O3), and the air quality index (AQI) from the Nicla Sense Env board.
317
+
- Finally, the data is printed in a single line on the IDE's Serial Monitor, with the AQI displayed at the end.
361
318
362
319
### Complete Example Sketch
363
320
364
321
The complete example sketch can be downloaded here.
365
322
366
323
## Conclusions
367
324
368
-
The development of this outdoor air quality monitor demonstrates the effectiveness of using affordable and accessible sensors to measure key environmental parameters in real-time. Integrating the Nicla Sense Env and the PMS7003 sensor with the Portenta C33 allows the system to track temperature, humidity, airborne particulate matter (PM2.5 and PM10), NO2, and O3 levels. The ability to monitor these pollutants, combined with the outdoor AQI, provides valuable insights for understanding air quality in urban and rural areas. Furthermore, the system's connection to the Arduino Cloud allows for remote monitoring and analysis, making it versatile for various applications, from personal use to environmental research.
325
+
The development of this outdoor air quality monitor demonstrates the effectiveness of using affordable and accessible sensors to measure key environmental parameters in real-time. Integrating the Nicla Sense Env with the Portenta C33 allows the system to track temperature, humidity, NO2, and O3 levels. The ability to monitor these pollutants, combined with the outdoor AQI, provides valuable insights for understanding air quality in urban and rural areas. Furthermore, the system's connection to the Arduino Cloud allows for remote monitoring and analysis, making it versatile for various applications, from personal use to environmental research.
369
326
370
327
## Next Steps
371
328
372
-
Several improvements can be considered to extend the functionality of the environmental monitor:
329
+
Several improvements can be considered to extend the functionality of the outdoor air quality monitor:
373
330
374
-
- Add sensors to measure pollutants such as carbon monoxide (CO) or sulfur dioxide (SO2).
331
+
- Add more sensors to the monitor to measure pollutants such as carbon monoxide (CO) or sulfur dioxide (SO2).
375
332
- Improve the monitor's energy efficiency for long-term deployment in remote or outdoor environments.
376
333
- Build a custom dashboard on Arduino Cloud to visualize trends over time and allow for more detailed analysis of air quality data.
377
334
- Implement an alert system that notifies users when pollutant levels exceed safe thresholds.
0 commit comments