This repository has been archived by the owner on Jan 2, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathENS145_RHT_read.ino
100 lines (83 loc) · 2.81 KB
/
ENS145_RHT_read.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/*
Example code for the ENS145 Development Shield
This example will read the ENS145 as well as the ENS210
2021 Jan 24 v0.3 Christoph Friese
2021 Jan 21 v0.2 Patryk Hallek
2020 Dec 08 v0.1 Patryk Hallek Created
*/
// Library to drive the ENS145 sensor
#include <ScioSense_ENS145.h>
ScioSense_ENS145 ens145;
// Library to drive the EN210 temperture & humidity sensor
#include <ScioSense_ENS210.h>
ScioSense_ENS210 ens210;
void setup() {
Serial.begin(9600);
while(!Serial) { delay(100); };
Serial.println("ENS145 Development Shield demo");
Serial.print("ENS145...");
ens145.begin(ENS145_ADC_RESOLUTION, false); // debug mode enabled
// If ENS145 initialization is not successful, stop execution
if (!ens145.available()) {
Serial.println("failed!");
while (1) {
delay(500);
}
}
Serial.println("done!");
// Set voltage of heaters for operation
uint16_t voltageP1 = 800;
if (!ens145.setHeaterVoltage(ENS145_HP1, voltageP1)) {
Serial.println("Issue setting voltage for HP1");
}
uint16_t voltageP3 = 1100;
if (!ens145.setHeaterVoltage(ENS145_HP3, voltageP3)) {
Serial.println("Issue setting voltage for HP3");
}
Serial.print("ENS210...");
ens210.begin();
// If ENS210 initialization is not successful, then stop execution
if (!ens210.available()) {
Serial.println("failed!");
while (1) {
delay(500);
}
}
Serial.println("done.");
ens210.setSingleMode(false);
}
void loop() {
if (ens145.available()) {
Serial.print("ENS145 HP1:");
Serial.print("\t");
Serial.print(ens145.measureHeaterVoltage(ENS145_HP1));
Serial.print(" mV\t");
Serial.print(ens145.measureHeaterResistance(ENS145_HP1)); //expected below 100Ohm
Serial.print(" Ohm\t");
Serial.print(ens145.measureSensorVoltage(ENS145_HP1));
Serial.print(" mV\t");
Serial.print(ens145.measureSensorResistance(ENS145_HP1)); //expected up to 1MOhm
Serial.print(" Ohm\t");
Serial.print("ENS145 HP3:");
Serial.print("\t");
Serial.print(ens145.measureHeaterVoltage(ENS145_HP3));
Serial.print(" mV\t");
Serial.print(ens145.measureHeaterResistance(ENS145_HP3)); //expected below 100Ohm
Serial.print(" Ohm\t");
Serial.print(ens145.measureSensorVoltage(ENS145_HP3)); //expected up to 1MOhm
Serial.print(" mV\t");
Serial.print(ens145.measureSensorResistance(ENS145_HP3));
Serial.print(" Ohm\t");
}
if (ens210.available()) {
ens210.measure();
Serial.print("ENS210:");
Serial.print("\t");
Serial.print(ens210.getTempCelsius());
Serial.print("°C\t");
Serial.print(ens210.getHumidityPercent());
Serial.print("%\t");
}
Serial.println();
delay(1000);
}