# X-NODE / XN21 - BME690 Environmental AI Sensor

<figure><img src="https://3632356340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwzhjxMFtAHZqHlRBU68T%2Fuploads%2FAHrVFRU0PAAEZKGnj6hF%2FX-NODE%20Environmental%20AI%20BME690%20XN21%20XIDE%20MICROSIDE%2001%20.webp?alt=media&#x26;token=271f027d-ed1f-4803-ae8b-3f6a6f58d505" alt=""><figcaption></figcaption></figure>

<table data-card-size="large" data-view="cards"><thead><tr><th align="center"></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td align="center"><mark style="color:green;"><strong>Buy</strong></mark></td><td><a href="https://www.microside.com/shop/xide-17/x-node-sensor-ambiental-con-ia-bme690-2050">https://www.microside.com/shop/xide-17/x-node-sensor-ambiental-con-ia-bme690-2050</a></td></tr></tbody></table>

**X-NODE Environmental AI (BME690)** is a module that integrates Bosch’s BME690 AI-enabled gas sensor, capable of measuring volatile organic compounds (VOCs), volatile sulfur compounds (VSCs), barometric pressure, relative humidity, and ambient temperature, with a current consumption as low as 50 µA in ultra-low-power mode.

It is ideal for integration into portable devices or for indoor and outdoor air quality monitoring, as well as applications such as automatic air exchange systems, smart ventilation systems, and similar use cases.

### TABLE OF CONTENTS

1. [**How does it work?**](#i.-how-does-it-work)
2. [**Layout**](#ii.-layout)
3. [**Specification**](#iii.-specification)
4. [**Pinout**](#iv.-pinout)
5. [**Usage**](#v.-usage)
6. [**Downloads**](#vi.-downloads)

## I. How does it work?

**X-NODE Environmental AI (BME690)** module features a microcontroller, allowing users to obtain sensor data without requiring advanced hardware knowledge. Data can be accessed by sending a series of ASCII commands through UART. I2C or SPI communication protocols are also supported, making this module compatible with any system based on microcontrollers, microprocessors, or industrial equipment.

The sensor is capable of measuring barometric pressure, relative humidity, ambient temperature, and gas resistance. This information can be used\* to estimate indoor air quality (IAQ) and to detect volatile organic compounds (VOCs), volatile sulfur compounds (VSCs), and gases such as carbon monoxide and hydrogen.

**X-NODE Environmental AI (BME690)** is compatible with the mikroBUS™ standard from Mikroe® for easy use with a wide ecosystem of hardware development kits. It also features JST connectors compatible with the Qwiic® standard from SparkFun® for quick and easy I2C communication between multiple modules and development boards.

{% hint style="warning" %}
\*NOTE: IAQ, VOC, VSC, and gas detection functions require the use of the BSEC (**B**osch **S**ensortec **E**nvironmental **C**luster) library. [Please refer to the manufacturer's website for more information.](https://www.bosch-sensortec.com/zh/software-tools/software/bme688-and-bme690-software/)
{% endhint %}

## II. Layout

<figure><img src="https://3632356340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwzhjxMFtAHZqHlRBU68T%2Fuploads%2FGfkWpiyYCiZHoDFpxUiP%2FX-NODE%20XN21%20BME690%20Sensor%20IA_Bosch_Descripcion%20del%20hardware_XIDE_Microside.webp?alt=media&#x26;token=04ce1af2-e7fb-4705-b74b-33d4db1ddb9f" alt=""><figcaption></figcaption></figure>

1. [Bosch®](https://www.bosch-sensortec.com/) [BME690](https://www.bosch-sensortec.com/products/environmental-sensors/gas-sensors/bme690/) sensor
2. JST connectors compatible with [Qwiic®](https://www.sparkfun.com/qwiic)
3. Hardware controller
4. UART <> I2C communication ports
5. X-NODE model
6. X-NODE type
7. I2C address selection jumper (open = 0x77, closed = 0x76)
8. I2C / SPI protocol selection jumpers (when using SPI, the hardware controller is not available)
9. SPI Chip Select enable jumper (CS1 <> CS2)
10. [mikroBUS™](https://www.mikroe.com/mikrobus) standard connectors
11. UPDI programming enable jumper for the microcontroller
12. Hardware version: R1
13. Main component on the X-NODE

{% hint style="danger" %}
\*NOTE: The integrated hardware controller uses the I2C protocol. Modifying the solder jumpers to use the SPI protocol will disable UART communication.
{% endhint %}

## III. Specification

<table data-header-hidden><thead><tr><th width="158"></th><th></th></tr></thead><tbody><tr><td><strong>Tags</strong></td><td>Gas sensor, environmental monitoring, air quality</td></tr><tr><td><strong>Applications</strong></td><td>Indoor and outdoor air quality monitoring, automatic air exchange systems, smart ventilation systems, integration into battery-powered portable devices, as well as Internet of Things (IoT), Industry 4.0, and Smart Home applications.</td></tr><tr><td><strong>Module</strong></td><td><a href="https://www.bosch-sensortec.com/products/environmental-sensors/gas-sensors/bme690/">BME690</a></td></tr><tr><td><strong>Manufacturer</strong></td><td><a href="https://www.bosch-sensortec.com/">Bosch®</a></td></tr><tr><td><strong>Features</strong></td><td>Measurement of volatile organic compounds (VOCs), volatile sulfur compounds (VSCs), barometric pressure from 300 to 1100 hPa, relative humidity from 0 to 100%, ambient temperature from -40 to 85 °C, and ultra-low-power consumption mode of 50 µA.</td></tr><tr><td><strong>Interface</strong></td><td>UART, I2C</td></tr><tr><td><strong>Compatibility</strong></td><td><a href="https://www.mikroe.com/mikrobus"><strong>mikroBUS™</strong></a>  &#x26; <a href="https://www.sparkfun.com/qwiic"><strong>Qwiic®</strong></a></td></tr><tr><td><strong>Size</strong></td><td>41 x 25.4 x 20.5 mm</td></tr><tr><td><strong>Voltage</strong></td><td>3.3 V</td></tr></tbody></table>

{% hint style="info" %}
For complete technical information, you can download the manufacturer's specifications at the following link: [BME690](https://www.bosch-sensortec.com/products/environmental-sensors/gas-sensors/bme688/)
{% endhint %}

## IV. Pinout

This table shows how the pinout on **X-NODE Environmental AI (BME690)** corresponds to the pinout on the mikroBUS™ socket (the latter shown in the two middle columns).

<figure><img src="https://3632356340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwzhjxMFtAHZqHlRBU68T%2Fuploads%2FjKfYMIsdt3fWKGkcAdtw%2FX-NODE%20XN09%20BME688%20Sensor%20IA_Bosch_Pinour_XIDE_Microside.webp?alt=media&#x26;token=ca171645-eaac-43cf-ab8d-0580f13f35de" alt="" width="563"><figcaption></figcaption></figure>

## V. Usage

For quick and easy use of the X-NODE, it can be operated through ASCII commands provided by the integrated hardware controller via UART serial communication, or natively through I2C and SPI protocols.

{% hint style="warning" %}
When using the **SPI** protocol, the integrated hardware controller is disabled, so ASCII commands via **UART** communication will not be available.
{% endhint %}

### UART Protocol

**Configuration**

* Baud rate: 115,200 bps
* Parity: None
* Data bits: 8
* Stop bits: 1

**Syntax**

The UART protocol allows sending instructions in plain *ASCII* text. Each instruction consists of the X-NODE identifier, a command, and an end-of-line.

**Identifier**

The **ID** identifier is made up of the X-NODE model, which can be found at point 5 in the Hardware description section, and is complemented by an index, which can be a letter from A to Z, by default is **A**.&#x20;

{% hint style="warning" %}
The UART protocol uses the sensor’s I2C interface, so it is not possible to connect more than one X-NODE Environmental AI (BME690) on the same bus. You should also avoid connecting devices that use the same address (0x77 or 0x76). Remember that the device address can be modified using the ADD jumper.

If you need to use more than one X-NODE Environmental AI (BME690) with the UART protocol, you must isolate the SDA and SCL pins between nodes and assign a unique index to each one.

You may also use the sensor’s SPI interface, which disables the UART protocol, using the CS1 or CS2 pins to select the active device. To use this protocol, you must port the sensor API ([available on GitHub](https://github.com/boschsensortec/BME690_SensorAPI)) to the programming language used in your system.
{% endhint %}

<figure><img src="https://3632356340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwzhjxMFtAHZqHlRBU68T%2Fuploads%2FAAkxmqpticgOGVz3qJcQ%2Fxn21-r1-uart-protocol-index-rule.png?alt=media&#x26;token=38944102-d264-4f13-939b-61d842d4bcd3" alt="XN04_X-NODE"><figcaption></figcaption></figure>

{% hint style="warning" %}
**Note:** From this point on, the default index of the **X-NODE Environmental AI (BME690)** will be used for the rest of the manual: **XN21A**.
{% endhint %}

**Command list**

<table data-header-hidden data-full-width="false"><thead><tr><th width="159"></th><th></th><th data-hidden></th></tr></thead><tbody><tr><td><strong>XN21A?</strong></td><td><p>Checks if communication was established successfully.<br></p><p><strong>Response:</strong> OK</p></td><td></td></tr><tr><td><strong>XN21A+V</strong></td><td><p>Gets the current firmware version integrated in the X-NODE.</p><p><br><strong>Response:</strong> XN21A=Version_FW.Revision_HW<br>       <strong>Example:</strong> XN21A=0.1.0.R01</p></td><td></td></tr><tr><td><strong>XN21A+ID=(A-Z)</strong></td><td><p>Changes the ID index to a different uppercase letter from A to Z. Once changed, you must use the new ID to change it again.</p><p><br><strong>Response:</strong> OK<br>       <strong>Example:</strong> XN21C+ID=H</p></td><td></td></tr><tr><td><strong>XN21A+GT</strong></td><td><p>Gets the temperature value from the sensor. Returns the final value in °C with two decimals.</p><p><br><strong>Response:</strong> XN21A=VAL<br>       <strong>Example:</strong> XN21A=24.36</p></td><td></td></tr><tr><td><strong>XN21A+GH</strong></td><td><p>Gets the humidity value from the sensor. Returns a relative humidity (%) value.</p><p><br><strong>Response:</strong> XN21A=VAL<br>       <strong>Example:</strong> X214A=68.14</p></td><td></td></tr><tr><td><strong>XN21A+GP</strong></td><td><p>Gets the barometric pressure value from the sensor. Returns the final value in hPa with two decimal places.</p><p></p><p><strong>Response:</strong> XN21A=VAL<br>       <strong>Example:</strong> XN21A=778.40</p></td><td></td></tr><tr><td><strong>XN21A+GR</strong></td><td><p>Gets the gas resistance value from the sensor*. Returns the ambient resistance value in kOhms.</p><p></p><p><strong>Response:</strong> XN21A=VAL<br>       <strong>Example:</strong> XN21A=38.72</p></td><td></td></tr></tbody></table>

{% hint style="warning" %}
**\*NOTE:** Gas resistance measurements use an embedded heating element within the device. After powering on the device, the user should read at least one variable at intervals of 1 to 2 seconds until the gas resistance value stabilizes to obtain accurate measurements.
{% endhint %}

**Advanced commands**

<table data-header-hidden data-full-width="false"><thead><tr><th width="159"></th><th></th><th data-hidden></th></tr></thead><tbody><tr><td><strong>XN21A+SLP</strong></td><td><p>Enables the device’s deep sleep mode to reduce power consumption and disable the UART driver. If the <strong>UPDI</strong> jumper is enabled, the device can exit deep sleep mode by writing a logic low (0) to the <strong>CS1</strong> pin.</p><p></p><p><strong>Response:</strong> OK</p><p>       <strong>Example:</strong> XN21A+SLP</p></td><td></td></tr><tr><td><strong>XN21A+RST</strong></td><td><p>Restarts the device; the sensor will be reconfigured with the following parameters:</p><p></p><p>Oversampling THP = 16X</p><p>Heater (°C/ms) = 350 / 150</p><p></p><p><strong>Response:</strong> OK<br>       <strong>Example:</strong> XN21A+RST</p></td><td></td></tr></tbody></table>

### UART Example Arduino Framework

{% hint style="info" %}
Example code for the XC01 - R5. Please refer to the manual for instructions on how to use our XC01 - R5 with Arduino IDE / PlatformIO.
{% endhint %}

```cpp
#include "Arduino.h"

float getVariable( const char * command ){
  // Clear the buffer
  if (Serial2.available()) {
    Serial2.read();
  }

  // Send the command
  Serial2.print(command);
  Serial2.println();

  // Wait for a response
  String variable_value = Serial2.readStringUntil('\n');

  // If the response starts with the ID, communication was successful
  if (!variable_value.startsWith("XN21A=")) {
    Serial.println("Error");
    return NAN;
  }

  // Convert ASCII value to decimal
  return variable_value.substring(variable_value.indexOf('=') + 1).toFloat();
}

void setup() {
  // Initialize serial monitor
  Serial.begin(115200);

  // Initialize UART communication on MikroBUS port
  Serial2.begin(115200, SERIAL_8N1, 9, 10);
}

void loop() {
  // Get environmental variable values

  // Send command to get temperature
  // \r\n represents <CR+LF> in C/C++
  float temp = getVariable("XN21A+GT\r\n");

  // Send command to get humidity
  float hum = getVariable("XN21A+GH\r\n");

  // Send command to get pressure
  float press = getVariable("XN21A+GP\r\n");
  
  // Send command to get resistance
  float res = getVariable("XN21A+GR\r\n");

  Serial.print("Temp: ");
  Serial.print(temp);
  Serial.println(" °C");
  Serial.print("Hum: ");
  Serial.print(hum);
  Serial.println(" %");
  Serial.print("Press: ");
  Serial.print(press);
  Serial.println(" hPa");
  Serial.print("Gas: ");
  Serial.print(res);
  Serial.println(" kOhm");

  delay(1000);
}
```

### I2C & SPI Protocol

To establish communication with the **X-NODE Environmental AI (BME690)**, it must be done natively with the integrated sensor, using the manufacturer’s technical documentation as a reference. You can find the part number on the back of the X-NODE (see point 13 in the “Layout” section), as well as jumpers for changing the I2C address, selecting the SPI Chip Select pin, and switching between I2C and SPI protocols.

{% hint style="info" %}
You can download the manufacturer’s technical documentation at the following [**link**](https://www.bosch-sensortec.com/products/environmental-sensors/gas-sensors/bme690/).
{% endhint %}

## VI. Downloads

<table data-card-size="large" data-view="cards"><thead><tr><th align="center"></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td align="center"><mark style="color:green;"><strong>Schematic</strong></mark></td><td><a href="https://files.gitbook.com/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbyV2zAlQAiqg46a3Lr8z%2Fuploads%2FfYXGnidJAkR6T5umuum7%2Fxn21-r1-schematic.pdf?alt=media&#x26;token=ac4c7fc5-1691-4404-bade-b607176fd507">https://files.gitbook.com/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbyV2zAlQAiqg46a3Lr8z%2Fuploads%2FfYXGnidJAkR6T5umuum7%2Fxn21-r1-schematic.pdf?alt=media&#x26;token=ac4c7fc5-1691-4404-bade-b607176fd507</a></td></tr><tr><td align="center"><mark style="color:green;"><strong>Dimension</strong></mark></td><td><a href="https://files.gitbook.com/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbyV2zAlQAiqg46a3Lr8z%2Fuploads%2FcGJ7OxC1y4GMGbJJcYzH%2Fxn21-r1-dimensions.pdf?alt=media&#x26;token=614f0216-b810-43e5-95e3-a3a7a456f70e">https://files.gitbook.com/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbyV2zAlQAiqg46a3Lr8z%2Fuploads%2FcGJ7OxC1y4GMGbJJcYzH%2Fxn21-r1-dimensions.pdf?alt=media&#x26;token=614f0216-b810-43e5-95e3-a3a7a456f70e</a></td></tr></tbody></table>
