-
Notifications
You must be signed in to change notification settings - Fork 0
/
SHTC3.ino
52 lines (40 loc) · 1.3 KB
/
SHTC3.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
/*
Project : LaLiMat project (https://www.youtube.com/playlist?list=PLJBKmE2nNweRXOebZjydkMEiq2pHtBMOS in Chinese)
file : SHTC3.ino
Author : ykchau
youtube : youtube.com/ykchau888
Licenese : GPL-3.0
Please let me know if you use it commercial project.
*/
#include "SHTC3.h"
#define DELAY 2000
unsigned long startTime, timeUsed;
SHTC3 shtc3;
void setup() {
Serial.begin(115200);
Wire.begin();
startTime = millis();
}
void loop() {
Serial.print("LP CSD - ");
getSHTC3Data(MODE_LOWPOWER, CS_DISABLED);
delay(DELAY);
Serial.print("LP CSE - ");
getSHTC3Data(MODE_LOWPOWER, CS_ENABLED);
delay(DELAY);
Serial.print("NM CSD - ");
getSHTC3Data(MODE_NORMAL, CS_DISABLED);
delay(DELAY);
Serial.print("NM CSE - ");
getSHTC3Data(MODE_NORMAL, CS_ENABLED);
delay(DELAY);
}
void getSHTC3Data(byte mode, byte clockstretch) {
shtc3.wakeup(); // wake up the device
shtc3.getTempFirst(mode, clockstretch); // mesaure temp & RH
shtc3.sleep(); // put it sleep mode for power saving after measurement
Serial.print(String("Humidity : ") + shtc3.RH + "% Temperature : " + shtc3.Temp + " Deg C");
timeUsed = millis() - startTime;
startTime = millis();
Serial.println(String(" - ") + String((timeUsed- DELAY)) + "ms");
}