-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSHT.ino
66 lines (52 loc) · 1.36 KB
/
SHT.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
/**
* ReadSHT1xValues
*
* Read temperature and humidity values from an SHT1x-series (SHT10,
* SHT11, SHT15) sensor.
*
* Copyright 2009 Jonathan Oxer <[email protected]>
* www.practicalarduino.com
*/
#include <SHT1x.h>
#include <OneWire.h>
#include <DallasTemperature.h>
// Specify data and clock connections and instantiate SHT1x object
#define dataPin 13
#define clockPin 14
#define ONE_WIRE_BUS 26
SHT1x sht1x(dataPin, clockPin);
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
void setup()
{
Serial.begin(115200); // Open serial connection to report values to host
pinMode (12, OUTPUT);
digitalWrite (12, HIGH);
pinMode (27, OUTPUT);
digitalWrite (27, HIGH);
pinMode (25, OUTPUT);
digitalWrite (25, LOW);
delay(200);
Serial.println("Starting up");
sensors.begin();
}
void loop()
{
float temp_c;
float temp_f;
float humidity;
// Read values from the sensor
temp_c = sht1x.readTemperatureC();
humidity = sht1x.readHumidity();
// Print the values to the serial port
Serial.print("SHT: ");
Serial.print(temp_c, DEC);
Serial.print("/ ");
Serial.print(humidity);
delay(200);
sensors.requestTemperatures(); // Send the command to get temperature readings
Serial.print("% - DS18B20: ");
Serial.print(sensors.getTempCByIndex(0));
Serial.println("C");
delay(3000);
}