Skip to content

Commit 2c0b940

Browse files
committed
Content update (LED section, user manual)
1 parent 988fc8b commit 2c0b940

File tree

6 files changed

+157
-4
lines changed

6 files changed

+157
-4
lines changed

content/hardware/06.nicla/boards/nicla-sense-env/tutorials/user-manual/content.md

Lines changed: 157 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ This user manual provides a comprehensive Nicla Sense Env board overview, highli
4242

4343
Enhance your environmental sensing capabilities with the Nicla Sense Env board. This board combines three cutting-edge sensors from Renesas® with the Arduino ecosystem's ease of integration and scalability. This board is well-suited for augmenting your Portenta or MKR-based projects with environmental sensing capabilities.
4444

45+
![ ](assets/front_page.png)
46+
4547
The Nicla Sense Env includes an ultra-low power temperature and humidity sensor, complemented by two sophisticated industrial-grade gas sensors capable of assessing air quality in indoor and outdoor settings. Its compact dimensions (22.86 x 22.86 mm) and sturdy build make the Nicla Sense Env an excellent choice for projects that demand sensor fusion and the computational capabilities of Arduino boards.
4648

4749
### Nicla Sense Env Architecture Overview
@@ -62,8 +64,8 @@ Here's an overview of the board's main components shown in the images above:
6264
- **Onboard humidity and temperature sensor**: The Nicla Sense Env features an onboard humidity and temperature sensor, the [HS4001 from Renesas](https://www.renesas.com/us/en/products/sensor-products/environmental-sensors/humidity-temperature-sensors/hs4001-relative-humidity-and-temperature-sensor-digital-output-15-rh). This highly accurate, ultra-low power, fully calibrated relative humidity and temperature sensor features proprietary sensor-level protection, ensuring high reliability and long-term stability.
6365
- **Onboard indoor air quality sensor**: The Nicla Sense Env features an onboard gas sensor, the [ZMOD4410 from Renesas](https://www.renesas.com/us/en/document/dst/zmod4410-datasheet). This sophisticated sensor was designed to detect total volatile organic compounds (TVOC), estimate CO<sub>2</sub>, and monitor and report indoor air quality (IAQ).
6466
- **Onboard outdoor air quality sensor**: The Nicla Sense Env features an onboard gas sensor, the [ZMOD4510 from Renesas](https://www.renesas.com/us/en/document/dst/zmod4410-datasheet). This sophisticated sensor was designed to monitor and report outdoor air quality (OAQ) based on nitrogen dioxide (NO<sub>2</sub>) and ozone (O<sub>3</sub>) measurements.
65-
- **Onboard user LEDs**: The Nicla Sense Env has two onboard user-programmable LEDs; one is a white LED, and the other one is an RGB LED.
66-
- **ESLOV connector**: The Niclas Sense Env has an onboard ESLOV connector to extend the board communication capabilities via I<sup>2</sup>C.
67+
- **Onboard user LEDs**: The Nicla Sense Env has two onboard user-programmable LEDs; one is a orange LED, and the other one is an RGB LED.
68+
- **ESLOV connector**: The Nicla Sense Env has an onboard ESLOV connector to extend the board communication capabilities via I<sup>2</sup>C.
6769
- **Surface mount**: The castellated pins of the board allow it to be positioned as a surface-mountable module.
6870

6971
### Board Libraries
@@ -73,7 +75,7 @@ The [`Arduino_NiclaSenseEnv` library](https://github.com/arduino-libraries/Ardui
7375
- Board control (sleep, reset, and factory reset)
7476
- Board configuration (I<sup>2</sup>C address configuration)
7577
- Onboard RGB LED control
76-
- Onboard white LED control
78+
- Onboard orange LED control
7779
- Onboard indoor air quality sensor control (sulfur detection, odor intensity, ethanol level, TVOC, CO<sub>2</sub>, IAQ measurements)
7880
- Onboard outdoor air quality sensor control (NO<sub>2</sub>, O<sub>3</sub>, OAQ measurements)
7981
- Temperature and humidity sensor control
@@ -83,7 +85,7 @@ The [`Arduino_NiclaSenseEnv` library](https://github.com/arduino-libraries/Ardui
8385

8486
To install the `Arduino_NiclaSenseEnv` library, navigate to `Tools > Manage libraries...` or click the **Library Manager** icon in the left tab of the Arduino IDE. In the Library Manager tab, search for `Arduino_NiclaSenseEnv` and install the latest version of the library.
8587

86-
![Installing the Arduino_NiclaSenseEnv library](assets/user-manual-3.png)
88+
![Installing the board's library in the Arduino IDE](assets/user-manual-3.png)
8789

8890
### Pinout
8991

@@ -517,6 +519,157 @@ You can download the example sketch [here](assets/nicla_sense_env_low_power_mode
517519

518520
## LEDs
519521

522+
This section of the user manual explains how to control both the onboard orange and RGB and LEDs on the Nicla Sense Env board using the `Arduino_NiclaSenseEnv` library API. The LEDs can be used to provide visual feedback for various operations, such as indicating status, warnings, or sensor errors. This section covers the basic usage of both LEDs, including turning them on, changing colors, and adjusting brightness.
523+
524+
### Orange LED
525+
526+
The onboard orange LED on the Nicla Sense Env board can be controlled using the `Arduino_NiclaSenseEnv` library. The example sketch shown below shows how to smoothly increase and decrease the brightness of the onboard orange LED. The LED pulses continuously in the `loop()` function.
527+
528+
```arduino
529+
/**
530+
Orange LED Control Example for Nicla Sense Env
531+
Name: nicla_sense_env_orange_led_control_example_smooth_brightness.ino
532+
Purpose: This sketch demonstrates how to smoothly control the orange LED
533+
by increasing and decreasing its brightness using the Arduino_NiclaSenseEnv library.
534+
535+
@author Arduino Product Experience Team
536+
@version 1.0 31/05/24
537+
*/
538+
539+
// Include the NiclaSenseEnv library
540+
#include "Arduino_NiclaSenseEnv.h"
541+
542+
// Global device object for Nicla Sense Env
543+
NiclaSenseEnv device;
544+
545+
// Initial brightness level
546+
int brightness = 0;
547+
548+
// Amount to increase/decrease the brightness by each loop
549+
int fadeAmount = 5;
550+
551+
void setup() {
552+
// Initialize serial communication and wait up to 2.5 seconds for a connection
553+
Serial.begin(115200);
554+
for (auto startNow = millis() + 2500; !Serial && millis() < startNow; delay(500));
555+
556+
if (device.begin()) {
557+
Serial.println("- Device successfully initialized!");
558+
} else {
559+
Serial.println("- Failed to initialize the device. Please check the connection!");
560+
}
561+
}
562+
563+
void loop() {
564+
// Get the orange LED object
565+
auto orangeLED = device.orangeLED();
566+
567+
// Set the brightness level
568+
orangeLED.setBrightness(brightness);
569+
570+
// Change the brightness for next time through the loop
571+
brightness += fadeAmount;
572+
573+
// Reverse the direction of the fading at the ends of the fade (0 and 255)
574+
if (brightness <= 0 || brightness >= 255) {
575+
// Change the direction of the fade
576+
fadeAmount = -fadeAmount;
577+
}
578+
579+
// Wait for a short time before updating the brightness again
580+
delay(30);
581+
}
582+
```
583+
584+
Here is a detailed breakdown of the example sketch shown before and the `Arduino_NiclaSenseEnv` library API functions used in the sketch:
585+
586+
- `device.begin()`: Initializes the Nicla Sense Env board, setting up communication with all onboard sensors and components, including the orange LED.
587+
- `orangeLED.setBrightness(uint8_t brightness)`: Adjusts the brightness of the orange LED. The brightness ranges from `0` (off) to `255` (full brightness). In this sketch, the brightness gradually increases from `0` to `255` and then decreases back to 0, creating a smooth pulsing effect.
588+
- `fadeAmount`: Controls the rate of change of brightness. When the brightness reaches either 0 or 255, the direction of change is reversed, making the LED brightness smoothly cycle up and down.
589+
590+
After uploading the example sketch to the Nicla Sense Env board, you should see the orange LED smoothly increase and decrease in brightness, creating a continuous pulsing effect.
591+
592+
You can download the example sketch [here](assets/nicla_sense_env_orange_led_control_example.zip).
593+
594+
### RGB LED
595+
596+
The onboard RGB LED on the Nicla Sense Env board can be controlled using the `Arduino_NiclaSenseEnv` library. The example sketch shown below shows how to turn on the LED with different colors and then turn it off using the `setColor()` and `setBrightness()` functions. The LED colors cycle continuously in the `loop()` function.
597+
598+
```arduino
599+
/**
600+
RGB LED Control Example for Nicla Sense Env (with brightness control)
601+
Name: nicla_sense_env_rgb_led_control_example_brightness.ino
602+
Purpose: This sketch demonstrates how to control the RGB LED by setting
603+
different colors and ensuring brightness control using the Arduino_NiclaSenseEnv library.
604+
605+
@author Arduino Product Experience Team
606+
@version 1.0 31/05/24
607+
*/
608+
609+
// Include the NiclaSenseEnv library
610+
#include "Arduino_NiclaSenseEnv.h"
611+
612+
// Global device object for Nicla Sense Env
613+
NiclaSenseEnv device;
614+
615+
void setup() {
616+
// Initialize serial communication and wait up to 2.5 seconds for a connection
617+
Serial.begin(115200);
618+
for (auto startNow = millis() + 2500; !Serial && millis() < startNow; delay(500));
619+
620+
if (device.begin()) {
621+
Serial.println("- Device successfully initialized!");
622+
} else {
623+
Serial.println("- Failed to initialize the device. Please check the connection!");
624+
}
625+
}
626+
627+
void loop() {
628+
// Get the RGB LED object
629+
auto rgbLED = device.rgbLED();
630+
631+
// Turn on the LED with red color
632+
rgbLED.setColor(255, 0, 0);
633+
// Ensure maximum brightness, wait for one second
634+
rgbLED.setBrightness(255);
635+
Serial.println("- RGB LED is now red!");
636+
delay(1000);
637+
638+
// Turn on the LED with green color
639+
rgbLED.setColor(0, 255, 0);
640+
// Ensure maximum brightness, wait for one second
641+
rgbLED.setBrightness(255);
642+
Serial.println("- RGB LED is now green!");
643+
delay(1000);
644+
645+
// Turn on the LED with blue color
646+
rgbLED.setColor(0, 0, 255);
647+
// Ensure maximum brightness, wait for one second
648+
rgbLED.setBrightness(255);
649+
Serial.println("- RGB LED is now blue!");
650+
delay(1000);
651+
652+
// Set the LED color to black and brightness to 0 to turn it off
653+
rgbLED.setColor(0, 0, 0);
654+
// Ensure minimum brightness, wait for one second
655+
rgbLED.setBrightness(0);
656+
Serial.println("- RGB LED is now off!");
657+
delay(1000);
658+
}
659+
```
660+
661+
Here is a detailed breakdown of the example sketch shown before and the `Arduino_NiclaSenseEnv` library API functions used in the sketch:
662+
663+
- `device.begin()`: Initializes the Nicla Sense Env board, setting up communication with all onboard sensors and components, including the RGB LED.
664+
- `rgbLED.setColor(uint8_t red, uint8_t green, uint8_t blue)`: This function sets the RGB LED to a specific color by specifying the intensity of the red, green, and blue components. Each value can range from `0` (off) to `255` (full brightness). In the example, the RGB LED cycles through red (255, 0, 0), green (0, 255, 0), and blue (0, 0, 255).
665+
- `rgbLED.setBrightness(uint8_t brightness)`: Adjusts the brightness of the RGB LED. The value ranges from `0` (off) to `255` (full brightness). In the sketch, the brightness is set to 255 (maximum) when the LED is on, and to 0 (off) when the LED is turned off.
666+
667+
After uploading the example sketch to the Nicla Sense Env board, you should see the following output in the Arduino IDE's Serial Monitor:
668+
669+
![Example sketch output in the Arduino IDE's Serial Monitor](assets/user-manual-19.png)
670+
671+
You can download the example sketch [here](assets/nicla_sense_env_rgb_led_control_example_brightness.zip).
672+
520673
## Temperature and Humidity Sensor
521674

522675
The Nicla Sense Env board has an onboard temperature and humidity sensor, the HS4001 from Renesas. The HS4001 is a highly accurate, ultra-low power, fully calibrated automotive-grade relative humidity and temperature sensor. Its high accuracy, fast measurement response time, and long-term stability make the HS4001 sensor ideal for many applications ranging from portable devices to products designed for harsh environments.

0 commit comments

Comments
 (0)