-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhdc1080emg3003.ino
45 lines (37 loc) · 1.03 KB
/
hdc1080emg3003.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
//Board selection and libraries
#include <Arduino.h>
#if defined(ESP32)
#include <WiFi.h>
#elif defined(ESP8266)
#include <ESP8266WiFi.h>
#endif
//Insert Library (if any)
#include "ClosedCube_HDC1080.h"
#include <Wire.h>
//Create instances for using library
ClosedCube_HDC1080 hdc1080;
void setup() {
Serial.begin(115200); // Initialize serial
Wire.begin();
hdc1080.begin(0x40);
Serial.print("Manufacturer ID=0x");
Serial.println(hdc1080.readManufacturerId(), HEX); // 0x5449 ID of Texas Instruments
Serial.print("Device ID=0x");
Serial.println(hdc1080.readDeviceId(), HEX); // 0x1050 ID of the device
}
void loop() {
// change the values
float t = hdc1080.readTemperature();
float h = hdc1080.readHumidity();
if (isnan(t) || isnan(h))
{
Serial.println("Failed to read from HTU21 sensor!");
return;
}
Serial.print("Temperature: ");
Serial.print(t);
Serial.print(" degrees Celsius, Humidity (%): ");
Serial.print(h);
Serial.println("Sending data to Thingspeak");
delay(1000); // Wait 15 seconds
}