# ScioSense ENS17x Arduino Library
Arduino library for the ENS17x digital four channel MOX gas sensors with I2C/SPI interface from ScioSense.

<img src="images/ens17x.png" width="400">

ENS17x is a range of digital multi-gas metal oxide (MOX) sensors, specifically designed for automotive-grade air quality monitoring. It offers raw resistance outputs from three independent MOX hot plates, each with different sensitivities to various gases.

## Prerequisites
It is assumed that
 - The Arduino IDE has been installed.
   If not, refer to "Install the Arduino Desktop IDE" on the
   [Arduino site](https://www.arduino.cc/en/Guide/HomePage).
- The library directory is at its default location. Normally this is `C:\Users\[your_username]\Documents\Arduino\libraries`.

You might need to add your board to the Arduino IDE. This library was tested with the [Espressif ESP32](https://www.espressif.com/en/products/socs/esp32). 
For the installation of the ESP32 in the Arduino IDE, see [Arduino ESP32 Installation](https://docs.espressif.com/projects/arduino-esp32/en/latest/installing.html)


## Installation

### Installation via Arduino Library Manager
- In the Arduino IDE, navigate to the Arduino Library Manager on the left side (or, alternatively, select Sketch > Include Library > Manage Libraries...)
- Search for `ScioSense_ENS17x`
- Select the library from the search results and press `Install`

### Manual installation
- Download the code from this repository via "Download ZIP".
- In Arduino IDE, select Sketch > Include Library > Add .ZIP library... and browse to the just downloaded ZIP file.
- When the IDE is ready this README.md should be located at `C:\Users\[your_username]\Documents\Arduino\libraries\ScioSense_ENS17x\README.md`.

## Wiring

### General
Please ensure that the supply and interface voltages are correct:
- The ENS17x requires VDD = 3.3 V.
- On this board, 3.3 V is supplied directly to the ENS171A.
- The I2C and SPI interface pins are 3.3 V tolerant.

### I²C example with ESP32
This example shows how to wire a [ESP32DevKitC](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/hw-reference/esp32/get-started-devkitc.html#get-started-esp32-devkitc-board-front) 
with the ENS17x breakout board for I2C communication.

| ENS17x breakout board | ESP32 |
|:---------------------:|:-----:|
|          VDD          |  3V3  |
|          GND          |  GND  |
|          SDA          |  G21  |
|          SCL          |  G22  |

<img src="images/ESP32_I2C.png" width="1000">


### SPI example with ESP32
This example shows how to wire a [ESP32DevKitC](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/hw-reference/esp32/get-started-devkitc.html#get-started-esp32-devkitc-board-front) 
with the ENS17x breakout board for SPI communication. Make sure you modify the evaluation board by opening solderbridge J3 according application note [SC-002530-AN](www.sciosense.com/wp-content/uploads/2025/02/ENS170-ENS171-Evaluation-Board-Application-Note.pdf).

| ENS17x breakout board | ESP32 |
|:---------------------:|:-----:|
|          VDD          |  3V3  |
|          GND          |  GND  |
|          MOSI         |  G23  |
|          MISO         |  G19  |
|          SCK          |  G18  |
|          CS           |  G05  |

<img src="images/ESP32_SPI.png" width="1000">

## Build an example
To build an example sketch
 - (Re)start Arduino.
 - Open File > Example > Examples from Custom Libraries > ScioSense_ENS17x > 01_Basic (or any other of the provided examples you wish to run)
 - Make sure Tools > Board lists the correct board.
 - Select Sketch > Verify/Compile.

## Contributing
Contributions in the form of issue opening or creating pull requests are very welcome!

### ScioSense is a Joint Venture of ams AG 