Skip to content

Commit dfed486

Browse files
authored
Merge pull request #1 from sciosense/rework_examples_and_documentation
Rework examples and documentation
2 parents c64bdd6 + 3c0ea48 commit dfed486

File tree

19 files changed

+874
-26
lines changed

19 files changed

+874
-26
lines changed

README.md

Lines changed: 49 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,79 @@
1-
# ScioSense ENS21x
1+
# ScioSense ENS21x Arduino Library
22
Arduino library for the ENS21x temperature & humidity sensor family with I2C interface from ScioSense.
33

4-
## Introduction
5-
This project is an Arduino *library*. It implements a driver with examples for the ENS21x sensor family. ENS21x chips are digital temperature & humidity sensors with an I2C interface.
4+
<img src="images/ens21x.png" width="400">
65

7-
Note that the ENS21x requires a supply voltage of 1.71V .. 3.60V.
6+
The ENS21x is a family of high-performance digital temperature and humidity sensors produced by
7+
[ScioSense](http://www.sciosense.com). With industry leading accuracies down to 0.1°C temperature and 0.8% relative
8+
humidity, their rapid response and reliable, long-term performance the ENS21x family addresses the fields of home
9+
appliances, building and automotive HVAC, cold chain management, personal health and wellness monitoring, industrial
10+
automation and instrumentation.
11+
12+
The ENS21x family includes the ENS210, ENS211, ENS212, ENS213A and the ENS215.
813

914
## Links
10-
The ENS21x sensors are made by [ScioSense](http://www.sciosense.com).
11-
- In the library, an implementation for the ENS210 is given. The datasheet and further documents for this sensor can be downloaded here
12-
https://www.sciosense.com/products/relative-humidity-and-temperature-sensors/ens210-relative-humidity-and-temperature-sensor/
13-
15+
* [Further information about the ENS21x](https://www.sciosense.com/products/relative-humidity-and-temperature-sensors/ens210-relative-humidity-and-temperature-sensor/)
16+
* [Datasheet](https://www.sciosense.com/wp-content/uploads/2023/06/SC-001822-DS-3-ENS21x-Datasheet.pdf)
17+
* [Application notes](https://www.sciosense.com/wp-content/uploads/documents/SC-001928-AN-1-ENS21xA-Design-Guidelines.pdf)
18+
* Buy the ENS210 on [Mouser](https://mou.sr/3P3DWmK) or [Digikey](https://www.digikey.nl/en/products/detail/sciosense/ENS210-LQFM/6490747)
19+
* Buy the ENS210 evaluation kit on [Mouser](https://mou.sr/44GNQAi)
20+
21+
1422
## Prerequisites
1523
It is assumed that
1624
- The Arduino IDE has been installed.
1725
If not, refer to "Install the Arduino Desktop IDE" on the
1826
[Arduino site](https://www.arduino.cc/en/Guide/HomePage).
19-
- The library directory is at its default location.
20-
For me, that is `C:\Users\sciosense\Documents\Arduino\libraries`.
27+
- Install your board. This library was tested with the ESP32. Here is a step-by-step guide for board installation
28+
(coming soon).
29+
2130

2231
## Installation
2332

24-
### Installation via Arduino Library Manager
25-
- In the Arduino IDE, navigate to the Arduino Library Manager on the left side (or, alternatively, select Sketch > Include Library > Manage Libraries...)
33+
### Installation via Arduino Library Manager (coming soon)
34+
- In the Arduino IDE, navigate to the Arduino Library Manager on the left side (or, alternatively, select Sketch >
35+
Include Library > Manage Libraries...)
2636
- Search for `ScioSense_ENS21x`
2737
- Select the library from the search results and press `Install`
2838

2939
### Manual installation
30-
- Download the code from this repo via Download ZIP.
40+
- Download the code from this repository via "Download ZIP".
3141
- In Arduino IDE, select Sketch > Include Library > Add .ZIP library... and browse to the just downloaded ZIP file.
32-
- When the IDE is ready this README.md should be located at e.g. `C:\Users\sciosense\Documents\Arduino\libraries\ScioSense_ENS21x\README.md`.
42+
- When the IDE is ready this README.md should be located at `C:\Users\[your_username]\Documents\Arduino\libraries\ScioSense_ENS21x\README.md`.
43+
44+
45+
## Wiring
46+
47+
### General
48+
Please make sure that you use the correct supply voltage: The ENS21x runs at VDD = 1.71...3.60 V.
49+
50+
### Example with ESP32 (I2C)
51+
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)
52+
with the ENS21x flex foil for I2C communication.
53+
54+
| ENS21x flex foil | ESP32 |
55+
|:----------------:|:-----:|
56+
| VDD | 3V3 |
57+
| GND | GND |
58+
| SDA | G21 |
59+
| SCL | G22 |
60+
61+
<img src="images/i2c_pinout_esp32.png" width="1000">
3362

3463
## Build an example
3564
To build an example sketch
3665
- (Re)start Arduino.
37-
- Open File > Examples > Examples from Custom Libraries > ScioSense ENS21x > 01_Basic (or any other of the provided examples you wish to run)
66+
- Open File > Examples > Examples from Custom Libraries > ScioSense_ENS21x > 01_Basic (or any other of the provided
67+
examples you wish to run)
3868
- Make sure Tools > Board lists the correct board.
3969
- Select Sketch > Verify/Compile.
4070

71+
## Contributing
72+
Contributions in the form of issue opening or creating pull requests are very welcome!
73+
4174
## Acknowledgements
4275
This library is developed for ScioSense by [at² GmbH](https://www.at2-software.com/en/)
4376

4477
@at2software
4578

46-
47-
### ScioSense is a Joint Venture of ams AG
79+
### ScioSense is a Joint Venture of ams AG

examples/01_Basic/01_Basic.ino renamed to examples/01_Basic/ENS210/ENS210.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ void loop()
2929
float temperatureCelsius = ens210.getTempCelsius();
3030
float humidityPercent = ens210.getHumidityPercent();
3131

32-
Serial.print("Temperature: ");
32+
Serial.print("Temperature:");
3333
Serial.print(temperatureCelsius);
3434
Serial.print("°C\t");
3535

36-
Serial.print("Humidity: ");
36+
Serial.print("Humidity:");
3737
Serial.print(humidityPercent);
3838
Serial.println("%");
3939
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#include <Arduino.h>
2+
#include <Wire.h>
3+
4+
#include "ens211.h"
5+
6+
using namespace ScioSense;
7+
8+
ENS211 ens211;
9+
10+
void setup()
11+
{
12+
Serial.begin(9600);
13+
Serial.println();
14+
15+
Wire.begin();
16+
ens211.begin();
17+
18+
if (ens211.isConnected() == false)
19+
{
20+
Serial.println("Error -- The ENS211 is not connected.");
21+
while(1);
22+
}
23+
}
24+
25+
void loop()
26+
{
27+
if (ens211.singleShotMeasure() == ENS211::Result::STATUS_OK)
28+
{
29+
float temperatureCelsius = ens211.getTempCelsius();
30+
float humidityPercent = ens211.getHumidityPercent();
31+
32+
Serial.print("Temperature:");
33+
Serial.print(temperatureCelsius);
34+
Serial.print("°C\t");
35+
36+
Serial.print("Humidity:");
37+
Serial.print(humidityPercent);
38+
Serial.println("%");
39+
}
40+
41+
delay(1000);
42+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#include <Arduino.h>
2+
#include <Wire.h>
3+
4+
#include "ens212.h"
5+
6+
using namespace ScioSense;
7+
8+
ENS212 ens212;
9+
10+
void setup()
11+
{
12+
Serial.begin(9600);
13+
Serial.println();
14+
15+
Wire.begin();
16+
ens212.begin();
17+
18+
if (ens212.isConnected() == false)
19+
{
20+
Serial.println("Error -- The ENS212 is not connected.");
21+
while(1);
22+
}
23+
}
24+
25+
void loop()
26+
{
27+
if (ens212.singleShotMeasure() == ENS212::Result::STATUS_OK)
28+
{
29+
float temperatureCelsius = ens212.getTempCelsius();
30+
float humidityPercent = ens212.getHumidityPercent();
31+
32+
Serial.print("Temperature:");
33+
Serial.print(temperatureCelsius);
34+
Serial.print("°C\t");
35+
36+
Serial.print("Humidity:");
37+
Serial.print(humidityPercent);
38+
Serial.println("%");
39+
}
40+
41+
delay(1000);
42+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#include <Arduino.h>
2+
#include <Wire.h>
3+
4+
#include "ens213a.h"
5+
6+
using namespace ScioSense;
7+
8+
ENS213A ens213a;
9+
10+
void setup()
11+
{
12+
Serial.begin(9600);
13+
Serial.println();
14+
15+
Wire.begin();
16+
ens213a.begin();
17+
18+
if (ens213a.isConnected() == false)
19+
{
20+
Serial.println("Error -- The ENS213A is not connected.");
21+
while(1);
22+
}
23+
}
24+
25+
void loop()
26+
{
27+
if (ens213a.singleShotMeasure() == ENS213A::Result::STATUS_OK)
28+
{
29+
float temperatureCelsius = ens213a.getTempCelsius();
30+
float humidityPercent = ens213a.getHumidityPercent();
31+
32+
Serial.print("Temperature:");
33+
Serial.print(temperatureCelsius);
34+
Serial.print("°C\t");
35+
36+
Serial.print("Humidity:");
37+
Serial.print(humidityPercent);
38+
Serial.println("%");
39+
}
40+
41+
delay(1000);
42+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#include <Arduino.h>
2+
#include <Wire.h>
3+
4+
#include "ens215.h"
5+
6+
using namespace ScioSense;
7+
8+
ENS215 ens215;
9+
10+
void setup()
11+
{
12+
Serial.begin(9600);
13+
Serial.println();
14+
15+
Wire.begin();
16+
ens215.begin();
17+
18+
if (ens215.isConnected() == false)
19+
{
20+
Serial.println("Error -- The ENS215 is not connected.");
21+
while(1);
22+
}
23+
}
24+
25+
void loop()
26+
{
27+
if (ens215.singleShotMeasure() == ENS215::Result::STATUS_OK)
28+
{
29+
float temperatureCelsius = ens215.getTempCelsius();
30+
float humidityPercent = ens215.getHumidityPercent();
31+
32+
Serial.print("Temperature:");
33+
Serial.print(temperatureCelsius);
34+
Serial.print("°C\t");
35+
36+
Serial.print("Humidity:");
37+
Serial.print(humidityPercent);
38+
Serial.println("%");
39+
}
40+
41+
delay(1000);
42+
}

examples/02_Continuous_Mode/02_Continuous_Mode.ino renamed to examples/02_Continuous_Mode/ENS210/ENS210.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,11 @@ void loop()
4242
float temperatureCelsius = ens210.getTempCelsius();
4343
float humidityPercent = ens210.getHumidityPercent();
4444

45-
Serial.print("Temperature: ");
45+
Serial.print("Temperature:");
4646
Serial.print(temperatureCelsius);
4747
Serial.print("°C\t");
4848

49-
Serial.print("Humidity: ");
49+
Serial.print("Humidity:");
5050
Serial.print(humidityPercent);
5151
Serial.println("%");
5252
ens210.getStatusH();
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#include <Arduino.h>
2+
#include <Wire.h>
3+
4+
#include "ens211.h"
5+
6+
using namespace ScioSense;
7+
8+
ENS211 ens211;
9+
10+
void setup()
11+
{
12+
Serial.begin(9600);
13+
Serial.println();
14+
15+
Wire.begin();
16+
ens211.begin();
17+
18+
if (ens211.isConnected() == false)
19+
{
20+
Serial.println("Error -- The ENS211 is not connected.");
21+
while(1);
22+
}
23+
24+
ens211.reset();
25+
26+
Serial.print("Starting continous mode..");
27+
while (ens211.startContinuousMeasure() != ENS211::Result::STATUS_OK)
28+
{
29+
Serial.print(".");
30+
delay(ENS211::SystemTiming::BOOTING);
31+
}
32+
Serial.println(" Done!");
33+
34+
Serial.println();
35+
Serial.println("----------------------------------------");
36+
}
37+
38+
void loop()
39+
{
40+
if (ens211.update() == ENS211::Result::STATUS_OK)
41+
{
42+
float temperatureCelsius = ens211.getTempCelsius();
43+
float humidityPercent = ens211.getHumidityPercent();
44+
45+
Serial.print("Temperature:");
46+
Serial.print(temperatureCelsius);
47+
Serial.print("°C\t");
48+
49+
Serial.print("Humidity:");
50+
Serial.print(humidityPercent);
51+
Serial.println("%");
52+
ens211.getStatusH();
53+
}
54+
}

0 commit comments

Comments
 (0)