Skip to content

Commit 356db4d

Browse files
committed
Content update (datasheet and application note last changes)
1 parent ee03dc1 commit 356db4d

File tree

2 files changed

+347
-23
lines changed
  • content/hardware/06.nicla/boards/nicla-sense-env

2 files changed

+347
-23
lines changed

content/hardware/06.nicla/boards/nicla-sense-env/datasheet/datasheet.md

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -95,22 +95,6 @@ The table below provides a comprehensive guideline for the optimal use of the Ni
9595

9696
<sup>1</sup> Nicla Sense Env powered through the VCC pin (+3.3 VDC).
9797

98-
### Power Consumption
99-
100-
<p style="text-align: justify;">
101-
<strong>Work in progress</strong>. The table below summarizes the power consumption of the Nicla Sense Env in different test cases. Notice that the board's operating current will depend greatly on the application.
102-
</p>
103-
104-
| **Parameter** | **Symbol** | **Min** | **Typ** | **Max** | **Unit** |
105-
|:------------------------------------:|:--------------:|:-------:|:-------:|:-------:|:--------:|
106-
| Typical Mode Current Consumption² | I<sub>NM</sub> | - | TBD | - | mA |
107-
| Low Power Mode Current Consumption³ | I<sub>LP</sub> | - | TBD | - | mA |
108-
| Deep Sleep Mode Current Consumption⁴ | I<sub>DS</sub> | - | TBD | - | mA |
109-
110-
<sup>2</sup> Nicla Sense Env powered through the power supply (+3.3 VDC) of a Portenta C33 board.<br>
111-
<sup>3</sup> Nicla Sense Env powered through the power supply (+3.3 VDC) of a Portenta C33 board.<br>
112-
<sup>4</sup> Nicla Sense Env powered through the power supply (+3.3 VDC) of a Portenta C33 board.
113-
11498
<div style="background-color: #FFFFE0; border-left: 6px solid #FFD700; margin: 20px 0; padding: 15px;">
11599
To put the Nicla Sense Env in <strong>deep sleep mode</strong>, use the API provided by the <strong>Nicla Sense Env Arduino library</strong>.
116100
</div>

content/hardware/06.nicla/boards/nicla-sense-env/tutorials/environmental-monitor-application-note/content.md

Lines changed: 347 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -617,16 +617,356 @@ After uploading the example sketch to the host board, you should see the followi
617617

618618
The complete improved example sketch can be downloaded [here](assets/outdoor_air_quality_monitor_rgb.zip).
619619

620+
## Connecting the Environmental Monitor to Arduino Cloud
621+
622+
As environmental monitoring continues to grow in importance, connecting devices to the Internet enables real-time, remote data monitoring, allowing for easier tracking and response to changing conditions. By connecting our environmental monitor with the [Arduino Cloud](https://cloud.arduino.cc/), we can gain access to live sensor data from anywhere. This connection turns the monitor into an Internet of Things (IoT) device, offering timely insights into air quality, temperature, and humidity through a centralized dashboard.
623+
624+
In this section, we will connect the environmental monitor to Arduino Cloud. The data collected from the monitor's sensors (temperature, humidity, NO₂, O₃, and AQI) will be transmitted to the Arduino Cloud, where it can be monitored via a web-based dashboard or a mobile app. The onboard RGB LED of the Portenta C33 will continue to provide visual feedback based on the current AQI level.
625+
626+
***If you are new to Arduino Cloud, please check out [this tutorial](https://docs.arduino.cc/arduino-cloud/guides/overview/).***
627+
628+
Please, begin by creating a new Thing in your Arduino Cloud with the following variables:
629+
630+
- cloudTemperature
631+
- cloudHumidity
632+
- cloudNO2
633+
- cloudO3
634+
- cloudAQI
635+
636+
All of the variables must be **`float`** type, have **`Read & Write`** permission and a **`On Change`** update policy.
637+
638+
The complete example sketch is shown below.
639+
640+
```arduino
641+
/**
642+
Outdoor Air Quality Monitoring with Arduino Cloud and RGB LED
643+
Name: outdoor_air_quality_monitor_rgb.ino
644+
Purpose: This sketch reads temperature, humidity, and outdoor air quality
645+
(NO2, O3, AQI) from a Nicla Sense Env board connected to a Portenta C33 board.
646+
The data is sent to Arduino Cloud, where it can be monitored remotely via a
647+
web interface or mobile app. The onboard RGB LED of the Nicla Sense Env changes
648+
color based on the AQI status (Green for good, Yellow for moderate, Red for unhealthy).
649+
650+
@version 1.1 06/10/24
651+
@modified by: Arduino Product Experience Team
652+
*/
653+
654+
// Include necessary libraries for Nicla Sense Env sensors and Arduino Cloud
655+
#include "Arduino_NiclaSenseEnv.h"
656+
#include "thingProperties.h" // Automatically generated by Arduino Cloud for property synchronization
657+
658+
// Set time interval (in milliseconds) for sensor readings (10 seconds)
659+
static const uint32_t READ_INTERVAL = 10000;
660+
uint32_t lastReadTime = 0;
661+
662+
// Sensor object for Nicla Sense Env data collection
663+
NiclaSenseEnv device;
664+
665+
/**
666+
Initializes the sensors, serial communication, and Arduino Cloud connection.
667+
This function prepares the system to begin collecting environmental data and
668+
transmitting it to Arduino Cloud.
669+
*/
670+
void setup() {
671+
// Initialize serial communication at 9600 baud rate
672+
Serial.begin(9600);
673+
674+
// Short delay to wait for Serial Monitor to be ready
675+
delay(1500);
676+
677+
// Initialize Cloud properties and connect to Arduino IoT Cloud
678+
initProperties();
679+
ArduinoCloud.begin(ArduinoIoTPreferredConnection);
680+
681+
// Debug information
682+
setDebugMessageLevel(2);
683+
ArduinoCloud.printDebugInfo();
684+
685+
// Initialize Nicla Sense Env sensors
686+
if (device.begin()) {
687+
Serial.println("- Nicla Sense Env board connected!");
688+
689+
// Enable the outdoor air quality sensor
690+
device.outdoorAirQualitySensor().setEnabled(true);
691+
} else {
692+
Serial.println("- ERROR: Nicla Sense Env device not found!");
693+
}
694+
}
695+
696+
/**
697+
Main loop that reads sensor data every 10 seconds and sends updates to Arduino Cloud.
698+
This function also controls the RGB LED to provide local feedback on air quality levels.
699+
*/
700+
void loop() {
701+
// Update Arduino Cloud connection
702+
ArduinoCloud.update();
703+
704+
// Get the current time
705+
uint32_t currentTime = millis();
706+
707+
// Read sensors every 10 seconds
708+
if (currentTime - lastReadTime >= READ_INTERVAL) {
709+
lastReadTime = currentTime;
710+
readSensors();
711+
}
712+
}
713+
714+
/**
715+
Reads sensor data and updates Cloud variables.
716+
Provides real-time feedback via the RGB LED based on AQI levels.
717+
*/
718+
void readSensors() {
719+
// Get temperature/humidity and air quality sensors
720+
TemperatureHumiditySensor& tempHumSensor = device.temperatureHumiditySensor();
721+
OutdoorAirQualitySensor& airQualitySensor = device.outdoorAirQualitySensor();
722+
RGBLED& rgbLED = device.rgbLED();
723+
724+
// Check if sensors are enabled
725+
if (tempHumSensor.enabled() && airQualitySensor.enabled()) {
726+
// Read sensor data
727+
float temperature = tempHumSensor.temperature();
728+
float humidity = tempHumSensor.humidity();
729+
float NO2 = airQualitySensor.NO2();
730+
float O3 = airQualitySensor.O3();
731+
int airQualityIndex = airQualitySensor.airQualityIndex();
732+
733+
// Print sensor data to Serial Monitor
734+
Serial.print("- Temperature: ");
735+
Serial.print(temperature, 2);
736+
Serial.print(" °C, Humidity: ");
737+
Serial.print(humidity, 2);
738+
Serial.print(" %, NO2: ");
739+
Serial.print(NO2, 2);
740+
Serial.print(" ppb, O3: ");
741+
Serial.print(O3, 2);
742+
Serial.print(" ppb, Air Quality Index: ");
743+
Serial.println(airQualityIndex);
744+
745+
// Update RGB LED color based on AQI
746+
if (airQualityIndex <= 50) {
747+
rgbLED.setColor(0, 255, 0); // Green for good air quality
748+
} else if (airQualityIndex <= 100) {
749+
rgbLED.setColor(255, 255, 0); // Yellow for moderate air quality
750+
} else {
751+
rgbLED.setColor(255, 0, 0); // Red for unhealthy air quality
752+
}
753+
rgbLED.setBrightness(255); // Set brightness to max
754+
755+
// Update Arduino Cloud variables
756+
cloudTemperature = temperature;
757+
cloudHumidity = humidity;
758+
cloudNO2 = NO2;
759+
cloudO3 = O3;
760+
cloudAQI = airQualityIndex;
761+
762+
} else {
763+
Serial.println("- ERROR: One or more sensors are disabled.");
764+
}
765+
}
766+
767+
/**
768+
Function called when cloudTemperature variable changes.
769+
This function can be used to respond to changes in temperature values
770+
from the Arduino Cloud dashboard.
771+
*/
772+
void onCloudTemperatureChange() {
773+
// Add your code here to act upon temperature changes
774+
}
775+
776+
/**
777+
Function called when cloudHumidity variable changes.
778+
This function can be used to respond to changes in humidity values
779+
from the Arduino Cloud dashboard.
780+
*/
781+
void onCloudHumidityChange() {
782+
// Add your code here to act upon humidity changes
783+
}
784+
785+
/**
786+
Function called when cloudNO2 variable changes.
787+
This function can be used to respond to changes in NO₂ values
788+
from the Arduino Cloud dashboard.
789+
*/
790+
void onCloudNO2Change() {
791+
// Add your code here to act upon NO₂ changes
792+
}
793+
794+
/**
795+
Function called when cloudO3 variable changes.
796+
This function can be used to respond to changes in O₃ values
797+
from the Arduino Cloud dashboard.
798+
*/
799+
void onCloudO3Change() {
800+
// Add your code here to act upon O₃ changes
801+
}
802+
803+
/**
804+
Function called when cloudAQI variable changes.
805+
This function can be used to respond to changes in AQI values
806+
from the Arduino Cloud dashboard.
807+
*/
808+
void onCloudAQIChange() {
809+
// Add your code here to act upon AQI changes
810+
}
811+
```
812+
813+
The following sections will help you to understand the main parts of the example sketch shown before, which can be divided into the following:
814+
815+
- Library imports
816+
- Cloud and sensors initialization
817+
- Data collection and Cloud Updates
818+
- Cloud variables update
819+
820+
### Library Imports
821+
822+
The necessary libraries for interacting with Nicla Sense Env board sensors and integrating with Arduino Cloud are included at the start.
823+
824+
```arduino
825+
// Include necessary libraries for Nicla Sense Env sensors and Arduino Cloud
826+
#include "Arduino_NiclaSenseEnv.h"
827+
#include "thingProperties.h" // Automatically generated by Arduino Cloud for property synchronization
828+
```
829+
830+
In the code snippet shown before:
831+
832+
- The `thingProperties.h` library is included. This file is generated by Arduino Cloud to handle the synchronization of cloud variables. This allows sensor data (e.g., temperature, humidity, etc.) to be synchronized automatically with the Arduino Cloud dashboard for remote monitoring.
833+
834+
### Cloud and Sensors Initialization
835+
836+
In the `setup()` function, we initialize the Nicla Sense Env onboard sensors and establish the connection to Arduino Cloud.
837+
838+
```arduino
839+
void setup() {
840+
// Initialize serial communication at 9600 baud rate
841+
Serial.begin(9600);
842+
843+
// Short delay to wait for Serial Monitor to be ready
844+
delay(1500);
845+
846+
// Initialize Cloud properties and connect to Arduino IoT Cloud
847+
initProperties();
848+
ArduinoCloud.begin(ArduinoIoTPreferredConnection);
849+
850+
// Debug information
851+
setDebugMessageLevel(2);
852+
ArduinoCloud.printDebugInfo();
853+
854+
// Initialize Nicla Sense Env sensors
855+
if (device.begin()) {
856+
Serial.println("- Nicla Sense Env board connected!");
857+
858+
// Enable the outdoor air quality sensor
859+
device.outdoorAirQualitySensor().setEnabled(true);
860+
} else {
861+
Serial.println("- ERROR: Nicla Sense Env device not found!");
862+
}
863+
}
864+
```
865+
In the code snippet shown before:
866+
867+
- The Arduino Cloud connection is initialized using `initProperties()` and `ArduinoCloud.begin()`. These functions manage the link between local sensor variables and the cloud.
868+
- Debugging is enabled with `setDebugMessageLevel(2)`, providing feedback on the connection status.
869+
- The Nicla Sense Env sensors are also initialized and the outdoor air quality sensor is enabled.
870+
871+
### Data Collection and Cloud Updates
872+
873+
In the `loop()` function, sensor data is collected every 10 seconds and synchronized with the Arduino Cloud.
874+
875+
```arduino
876+
void loop() {
877+
// Update Arduino Cloud connection
878+
ArduinoCloud.update();
879+
880+
// Get the current time
881+
uint32_t currentTime = millis();
882+
883+
// Read sensors every 10 seconds
884+
if (currentTime - lastReadTime >= READ_INTERVAL) {
885+
lastReadTime = currentTime;
886+
readSensors();
887+
}
888+
}
889+
```
890+
891+
In the code snippet shown before:
892+
893+
- The `ArduinoCloud.update()` function ensures that the Cloud connection is maintained and any updates to the sensor data are sent to the Arduino Cloud.
894+
- Every 10 seconds, the `readSensors()` function is called to read sensor data and update the cloud variables.
895+
896+
### Cloud Variables Update
897+
898+
The `readSensors()` function handles reading data from the sensors and updating the Arduino Cloud variables. It also changes the RGB LED color of the Portenta C33 board based on AQI levels.
899+
900+
```arduino
901+
void readSensors() {
902+
// Get temperature/humidity and air quality sensors
903+
TemperatureHumiditySensor& tempHumSensor = device.temperatureHumiditySensor();
904+
OutdoorAirQualitySensor& airQualitySensor = device.outdoorAirQualitySensor();
905+
RGBLED& rgbLED = device.rgbLED();
906+
907+
// Check if sensors are enabled
908+
if (tempHumSensor.enabled() && airQualitySensor.enabled()) {
909+
// Read sensor data
910+
float temperature = tempHumSensor.temperature();
911+
float humidity = tempHumSensor.humidity();
912+
float NO2 = airQualitySensor.NO2();
913+
float O3 = airQualitySensor.O3();
914+
int airQualityIndex = airQualitySensor.airQualityIndex();
915+
916+
// Print sensor data to Serial Monitor
917+
Serial.print("- Temperature: ");
918+
Serial.print(temperature, 2);
919+
Serial.print(" °C, Humidity: ");
920+
Serial.print(humidity, 2);
921+
Serial.print(" %, NO2: ");
922+
Serial.print(NO2, 2);
923+
Serial.print(" ppb, O3: ");
924+
Serial.print(O3, 2);
925+
Serial.print(" ppb, Air Quality Index: ");
926+
Serial.println(airQualityIndex);
927+
928+
// Update RGB LED color based on AQI
929+
if (airQualityIndex <= 50) {
930+
rgbLED.setColor(0, 255, 0); // Green for good air quality
931+
} else if (airQualityIndex <= 100) {
932+
rgbLED.setColor(255, 255, 0); // Yellow for moderate air quality
933+
} else {
934+
rgbLED.setColor(255, 0, 0); // Red for unhealthy air quality
935+
}
936+
rgbLED.setBrightness(255); // Set brightness to max
937+
938+
// Update Arduino Cloud variables
939+
cloudTemperature = temperature;
940+
cloudHumidity = humidity;
941+
cloudNO2 = NO2;
942+
cloudO3 = O3;
943+
cloudAQI = airQualityIndex;
944+
945+
} else {
946+
Serial.println("- ERROR: One or more sensors are disabled.");
947+
}
948+
}
949+
```
950+
951+
In the code snippet shown before:
952+
953+
- The RGB LED changes color based on the AQI value. Green for good air quality, yellow for moderate, and red for unhealthy levels.
954+
- The cloud variables (`cloudTemperature`, `cloudHumidity`, `cloudNO2`, `cloudO3`, and `cloudAQI`) are updated with the latest sensor readings and sent to Arduino Cloud for remote monitoring.
955+
620956
## Conclusions
621957

622-
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, NO₂, 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.
958+
In this application note, we explored how to integrate a Portenta C33 board with a Nicla Sense Env board to monitor environmental data, such as temperature, humidity, NO₂, O₃, and AQI. We demonstrated also how Arduino Cloud allows for easy remote monitoring and real-time visualization of this data.
959+
960+
By using the Portenta C33, the Nicla Sense Env and the Arduino Cloud, we can turn sensor readings into useful information. This setup makes it possible to monitor outdor air quality, provide real-time feedback with the onboard RGB LED of the Portenta C33 and view the data remotely through a web dashboard or mobile app.
961+
962+
The main takeaway from this application is its potential for real-world use. With the integration of IoT and Cloud technology, we can monitor air quality remotely, respond to environmental changes more quickly, and contribute to improving living conditions and sustainability efforts.
623963

624964
## Next Steps
625965

626-
Several improvements can be considered to extend the functionality of the outdoor air quality monitor:
966+
There are several opportunities to enhance the functionality of the outdoor air quality monitor:
627967

628-
- Add more sensors to the monitor to measure pollutants such as carbon monoxide (CO) or sulfur dioxide (SO₂).
629-
- Improve the monitor's energy efficiency for long-term deployment in remote or outdoor environments.
630-
- Build a custom dashboard on Arduino Cloud to visualize trends over time and allow for more detailed analysis of air quality data.
631-
- Implement an alert system that notifies users when pollutant levels exceed safe thresholds.
632-
- Scale the system for use in different geographical regions to collect comparative data on air quality.
968+
- Integrate additional sensors to measure specific pollutants such as carbon monoxide (CO) or sulfur dioxide (SO₂).
969+
- Optimize the monitors energy efficiency to support long-term use in remote or outdoor locations.
970+
- Create a custom dashboard on Arduino Cloud to track data trends over time and enable more in-depth analysis of air quality.
971+
- Develop an alert system that notifies users when pollutant levels exceed safe limits.
972+
- Expand the system’s use to different geographical areas to gather comparative air quality data.

0 commit comments

Comments
 (0)