Arduino library for the ENS210 relative humidity and temperature sensor with I2C interface from ams
This project is an Arduino library. It implements a driver with examples for the ENS210. The ENS210 chip is a relative humidity and temperature sensor with an I2C interface. The driver in this Arduino library is based on the code supplied by ams, the manufacturer of the chip.
Note that the ENS210 requires a supply voltage of 1.71V .. 3.6V. So, 3.3V is ok, but do not use a 5V board. The Arduino nano has 3v3 supply, but runs I2C on 5V. This does seem to work.
The ENS210 is made by ScioSense formerly ams.
- Find the datasheet of the ENS210 on the product page.
- Sciosense has a github account with a copy of this library.
It is assumed that
- The Arduino IDE has been installed. If not, refer to "Install the Arduino Desktop IDE" on the Arduino site.
- The library directory is at its default location.
For me, Maarten, that is
C:\Users\maarten\Documents\Arduino\libraries
.
Installation steps
- Visit the project page for the Arduino ENS210 library.
- Click the green button
Clone or download
on the right side. - From the pop-up choose
Download ZIP
. - Start Arduino, select from menu Sketch > Include Library > Add .ZIP Library... and select the just downloaded ZIP file.
- An alternative to the last step is to manually add the library
- Unzip the file "Here", so that this
README.md
is in the top-level directory with the nameENS210-master
. - Copy the entire tree to the Arduino library directory.
This
README.md
should be located at e.g.C:\Users\maarten\Documents\Arduino\libraries\ENS210\README.md
.
- Unzip the file "Here", so that this
To build an example sketch
- (Re)start Arduino.
- Open File > Example > Examples from Custom Libraries > ENS210 > ens210basic.
- Make sure Tools > Board lists the correct board.
- Select Sketch > Verify/Compile.
There are several examples available with this library.
This library has been tested with three boards.
For the NodeMCU (ESP8266), connect as follows (I did not use pull-ups, presumably they are inside the MCU)
ENS210 | ESP8266 |
---|---|
VDD | 3V3 |
GND | GND |
SDA | D2 |
SCL | D1 |
For the Pro Mini (do not use a 5V board), connect as follows (I did not use pull-ups, presumably they are inside the MCU)
ENS210 | Pro mini |
---|---|
VDD | VCC |
GND | GND |
SDA | A4 |
SCL | A5 |
For the Arduino Nano, connect as follows (I did not use pull-ups, presumably they are inside the MCU)
ENS210 | Nano |
---|---|
VDD | 3V3 |
GND | GND |
SDA | A4 |
SCL | A5 |
To flash an example sketch
-
(Re)start Arduino.
-
Open File > Example > Examples from Custom Libraries > ENS210 > ens210basic.
-
Alternatively open File > Example > Examples from Custom Libraries > ENS210 > ENS210full.
-
In
setup()
make sure to start the I2C driver correctly. For example, for ESP8266 NodeMCU haveWire.begin(D2,D1); // For ESP8266 nodemcu boards [VDD to 3V3, GND to GND, SDA to D2, SCL to D1] // Wire.begin(); // Arduino pro mini or Nano [VDD to VCC/3V3, GND to GND, SDA to A4, SCL to A5]
and for Arduino pro mini or Nano have
// Wire.begin(D2,D1); // For ESP8266 nodemcu boards [VDD to 3V3, GND to GND, SDA to D2, SCL to D1] Wire.begin(); // Arduino pro mini or Nano [VDD to VCC/3V3, GND to GND, SDA to A4, SCL to A5]
-
Make sure Tools > Board lists the correct board and Tools > Port the correct COM port.
-
Select Sketch > Upload.
-
Select Tools > Serial Monitor.
-
Enjoy the output, which should be like this for
ens210basic
:Starting ENS210 basic demo 19.9 C, 59 %RH 23.1 C, 79 %RH 23.1 C, 79 %RH 27.7 C, 94 %RH 26.5 C, 95 %RH 23.5 C, 94 %RH 21.1 C, 94 %RH 20.2 C, 94 %RH 20.1 C, 94 %RH 19.4 C, 87 %RH 19.3 C, 79 %RH 19.3 C, 68 %RH
(end of doc)