Skip to content

Commit 382b849

Browse files
1.1.0
- Implemented configuration write - Example output is compatible with the Arduino Serial Plotter
2 parents 181f35a + af01f10 commit 382b849

File tree

11 files changed

+308
-53
lines changed

11 files changed

+308
-53
lines changed

README.md

Lines changed: 48 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,58 @@
11
# ScioSense ENS190 Arduino Library
22
Arduino library for the ENS190 CO2 sensor.
33

4+
<img src="images/ENS190.png" width="400">
5+
46
The ENS190 is a high-performance, non-dispersive infrared (NDIR) CO₂ sensor designed
57
for precise and reliable carbon dioxide measurement. It complies with key regulatory
68
standards such as California Title 24, RESET, WELL, and ASHRAE. It is an ideal solution
79
for air quality monitoring in smart buildings, HVAC systems, and other indoor
810
environments.
911

10-
At the core of the ENS190 is its patented "M-shaped" long optical path gas chamber, a
11-
uniquely engineered design that maximizes the effective optical path within a compact air
12-
cavity. This innovation, combined with a self-developed fully automated high-precision
13-
calibration system, ensures exceptional accuracy, consistency, and a wide measurement
14-
range. With its advanced sensing capabilities and robust design, the ENS190 provides a
15-
solution for applications demanding high-precision CO₂ monitoring.
16-
1712
## Links
18-
* [Datasheet](https://www.sciosense.com/wp-content/uploads/2025/04/ENS190-Datasheet.pdf)
13+
* [ENS190 Datasheet](https://www.sciosense.com/wp-content/uploads/2025/04/ENS190-Datasheet.pdf)
14+
* [Further information about the ENS190](https://www.sciosense.com/ens190/)
15+
16+
## Prerequisites
17+
It is assumed that
18+
- The Arduino IDE has been installed.
19+
If not, refer to "Install the Arduino Desktop IDE" on the
20+
[Arduino site](https://www.arduino.cc/en/Guide/HomePage).
21+
- The library directory is at its default location. Normally this is `C:\Users\[your_username]\Documents\Arduino\libraries`.
22+
23+
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).
24+
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)
25+
26+
## Installation
27+
28+
### Installation via Arduino Library Manager
29+
- In the Arduino IDE, navigate to the Arduino Library Manager on the left side (or, alternatively, select Sketch > Include Library > Manage Libraries...)
30+
- Search for `ScioSense_ENS190`
31+
- Select the library from the search results and press `Install`
32+
33+
### Manual installation
34+
- Download the code from this repository via "Download ZIP".
35+
- In Arduino IDE, select Sketch > Include Library > Add .ZIP library... and browse to the just downloaded ZIP file.
36+
- When the IDE is ready this README.md should be located at `C:\Users\[your_username]\Documents\Arduino\libraries\ScioSense_ENS190\README.md`.
37+
38+
## Wiring
39+
40+
### General
41+
Please make sure that you use the correct supply voltage:
42+
- The ENS190 runs at VDD = 5 V.
43+
- The serial communication runs at 5V, and supports UART, RS485, and Modbus.
44+
45+
### Example UART with ESP32
46+
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)
47+
with the ENS220 breakout board for UART communication.
48+
49+
| ENS190 | ESP32 |
50+
|:------:|:---------:|
51+
| VDD | 5V |
52+
| GND | GND |
53+
| RXD | TX2(17) |
54+
| TXD | RX2(16) |
55+
56+
<img src="images/ens190_pin_out_esp32_uart.png" width="1000">
57+
58+
### ScioSense is a Joint Venture of ams AG

examples/01_Basic/01_Basic.ino

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,9 @@ void loop()
5858
{
5959
if (ens190.update() == RESULT_OK)
6060
{
61-
Serial.print("CO2: ");
62-
Serial.print(ens190.getCo2());
63-
Serial.println(" ppm");
64-
65-
66-
Serial.println("-----------------------");
61+
Serial.print("CO2[ppm]:");
62+
Serial.println(ens190.getCo2());
6763
}
68-
else Serial.println("Result loop not ok");
69-
64+
7065
delay(4000);
7166
}

images/ENS190_Schematic.png

24.7 KB
Loading
431 KB
Loading

keywords.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,18 @@ ens190 KEYWORD1
2020
#######################################
2121
begin KEYWORD2
2222
isConnected KEYWORD2
23+
24+
update KEYWORD2
25+
getCo2 KEYWORD2
26+
getFirmwareVersion KEYWORD2
27+
getSerialNumber KEYWORD2
28+
getProductionDate KEYWORD2
29+
setAbcParameters KEYWORD2
30+
getAlarmThresholdHigh KEYWORD2
31+
getAlarmThresholdLow KEYWORD2
32+
setCo2Baseline KEYWORD2
33+
setBaudrate KEYWORD2
34+
2335
enableDebugging KEYWORD2
2436
disableDebugging KEYWORD2
2537

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=ScioSense_ENS190
2-
version=1.0.0
2+
version=1.1.0
33
author=ScioSense
44
maintainer=ScioSense
55
sentence=Library for the ENS190 CO2 sensor by ScioSense

src/ens190.h

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,17 @@ class ENS190 : public ScioSense_Ens190
2828
inline void clear(); // Clears IO buffers of the Stream device
2929

3030
public:
31-
inline Result update(); // Reads measurement data;
32-
inline uint16_t getCo2(); // Returns CO2 concentration in ppm
33-
inline uint8_t* getFirmwareVersion(); // Returns a pointer to the firmware version
34-
inline uint16_t getSerialNumber(); // Returns serial number
35-
inline uint32_t getProductionDate(); // Returns production date
31+
inline Result update (); // Reads measurement data;
32+
inline uint16_t getCo2 (); // Returns CO2 concentration in ppm
33+
inline uint8_t* getFirmwareVersion (); // Returns a pointer to the firmware version
34+
inline uint16_t getSerialNumber (); // Returns serial number
35+
inline uint8_t* getProductionDate (); // Returns production date
36+
inline uint16_t setAbcParameters (uint16_t periodHrs); // Sets the ABC parameters
37+
inline uint16_t setAlarmThresholds (uint16_t highAlarmThresholdPpm, uint16_t lowAlarmThresholdPpm); // Sets the alarm thresholds
38+
inline uint16_t getAlarmThresholdHigh (); // Returns the value of the higher alarm threshold
39+
inline uint16_t getAlarmThresholdLow (); // Returns the value of the lower alarm threshold
40+
inline uint16_t setCo2Baseline (uint16_t co2BaselinePpm); // Sets the CO2 Baseline
41+
inline uint16_t setBaudrate (Ens190_Baudrate baudrate); // Sets the Baudrate
3642

3743
protected:
3844
ScioSense_Arduino_Serial_Config serialConfig;

src/ens190.inl.h

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ ENS190::~ENS190() { }
55

66
ENS190::ENS190()
77
{
8-
io = { 0 };
9-
fwVersion[0] = 0;
10-
productionDate = 0;
11-
serialNumber = 0;
8+
io = { 0 };
9+
fwVersion[0] = 0;
10+
productionDate[0] = 0;
11+
serialNumber = 0;
1212
}
1313

1414
void ENS190::begin(Stream* serial)
@@ -48,12 +48,42 @@ uint16_t ENS190::getCo2()
4848
return Ens190_GetCo2(this);
4949
}
5050

51+
uint16_t ENS190::setAbcParameters(uint16_t periodHrs)
52+
{
53+
return Ens190_InvokeSetAbcParameters(this, periodHrs);
54+
}
55+
56+
uint16_t ENS190::setAlarmThresholds(uint16_t highAlarmThresholdPpm, uint16_t lowAlarmThresholdPpm)
57+
{
58+
return Ens190_SetAlarmThresholds(this, highAlarmThresholdPpm, lowAlarmThresholdPpm);
59+
}
60+
61+
uint16_t ENS190::getAlarmThresholdHigh()
62+
{
63+
return Ens190_GetAlarmThresholdHigh(this);
64+
}
65+
66+
uint16_t ENS190::getAlarmThresholdLow()
67+
{
68+
return Ens190_GetAlarmThresholdLow(this);
69+
}
70+
71+
uint16_t ENS190::setCo2Baseline(uint16_t co2BaselinePpm)
72+
{
73+
return Ens190_SetCo2Baseline(this, co2BaselinePpm);
74+
}
75+
76+
uint16_t ENS190::setBaudrate(Ens190_Baudrate baudrate)
77+
{
78+
return Ens190_SetBaudrate(this, baudrate);
79+
}
80+
5181
uint16_t ENS190::getSerialNumber()
5282
{
5383
return Ens190_GetSerialNumber(this);
5484
}
5585

56-
uint32_t ENS190::getProductionDate()
86+
uint8_t* ENS190::getProductionDate()
5787
{
5888
return Ens190_GetProductionDate(this);
5989
}

src/lib/ens190/ScioSense_Ens190.h

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,32 @@ typedef struct ScioSense_Ens190
2020
ScioSense_Ens190_IO io;
2121
uint8_t dataBuffer [ENS190_COMMAND_RESPONSE_CO2_VALUE_PAYLOAD];
2222
uint8_t fwVersion [ENS190_COMMAND_RESPONSE_FIRMWARE_VERSION_NUMBER_PAYLOAD];
23+
uint16_t highAlarmPpm;
24+
uint16_t lowAlarmPpm;
2325
uint16_t serialNumber;
24-
uint32_t productionDate;
26+
uint8_t productionDate [ENS190_RESPONSE_PRODUCTION_DATE_PAYLOAD];
2527
} ScioSense_Ens190;
2628

2729
static inline Result Ens190_Update (ScioSense_Ens190* ens190); // Reads measurement data;
2830
static inline Result Ens190_Reset (ScioSense_Ens190* ens190); // Clear variables and read the sensor serial number and firmware version
2931
static inline Result Ens190_InvokeReadSerialNumber (ScioSense_Ens190* ens190); // Reads the serial number and production date
3032
static inline Result Ens190_InvokeReadFirmwareVersion (ScioSense_Ens190* ens190); // Reads the firmware version
3133
static inline bool Ens190_IsConnected (ScioSense_Ens190* ens190); // Checks if the read firmware version is plausible
34+
static inline Result Ens190_InvokeSetAbcParameters (ScioSense_Ens190* ens190, uint16_t periodHrs); // Sets the ABC parameters
35+
static inline Result Ens190_SetAlarmThresholds (ScioSense_Ens190* ens190, uint16_t highAlarmThresholdPpm, uint16_t lowAlarmThresholdPpm); // Sets the alarm thresholds
36+
static inline Result Ens190_GetAlarmThresholds (ScioSense_Ens190* ens190); // Gets the values of the alarm thresholds
37+
static inline Result Ens190_SetCo2Baseline (ScioSense_Ens190* ens190, uint16_t co2BaselinePpm); // Sets the CO2 Baseline
38+
static inline Result Ens190_SetBaudrate (ScioSense_Ens190* ens190, const Ens190_Baudrate baudrate); // Sets the Baudrate
3239
static inline uint16_t Ens190_GetCo2 (ScioSense_Ens190* ens190); // Returns CO2 concentration in ppm
3340
static inline uint8_t* Ens190_GetFirmwareVersion (ScioSense_Ens190* ens190); // Returns a pointer to the firmware version
3441
static inline uint16_t Ens190_GetSerialNumber (ScioSense_Ens190* ens190); // Returns serial number
35-
static inline uint32_t Ens190_GetProductionDate (ScioSense_Ens190* ens190); // Returns production date
42+
static inline uint8_t* Ens190_GetProductionDate (ScioSense_Ens190* ens190); // Returns production date
43+
static inline Result Ens190_GetAlarmThresholds (ScioSense_Ens190* ens190); // Reads the alarm thresholds
44+
static inline uint16_t Ens190_GetAlarmThresholdHigh (ScioSense_Ens190* ens190); // Returns the value of the higher alarm threshold
45+
static inline uint16_t Ens190_GetAlarmThresholdLow (ScioSense_Ens190* ens190); // Returns the value of the lower alarm threshold
3646

37-
static inline Result Ens190_CheckData (const uint8_t* data, const Ens190_CommandResponse size); // calculates the checksum of the data and compares it with the last 2 byte; returns RESULT_CHECKSUM_ERROR on failure
47+
static inline Result Ens190_CheckData (const uint8_t* data, const Ens190_CommandResponse size); // Checks the checksum of the data and compares it with the last 2 byte; returns RESULT_CHECKSUM_ERROR on failure
48+
static inline uint8_t Ens190_CalculateChecksum (const uint8_t* data, const Ens190_CommandResponse size); // Calculates the checksum of the data
3849
static inline Result Ens190_CheckCommandResponse (const Ens190_Command command, const uint8_t* data, const Ens190_CommandResponse size); // checks if the data corresponds to the command result protocol and calculates the checksum thereafter; returns RESULT_INVALID if the protocol does not match
3950

4051
#include "ScioSense_Ens190.inl.h"

0 commit comments

Comments
 (0)