Created
February 20, 2016 07:53
-
-
Save okn3/9d9634268ab540b0377a to your computer and use it in GitHub Desktop.
IoTハッカソン o202用
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include "DHT.h" | |
| #define DHTPIN 2 | |
| #define DHTTYPE DHT11 | |
| DHT dht(DHTPIN, DHTTYPE); | |
| void setup() { | |
| Serial.begin(9600); | |
| Serial.println("DHT11 test!"); | |
| dht.begin(); | |
| } | |
| int count = 1; | |
| void loop() { | |
| delay(1000*10); //運用は60秒 | |
| int h = dht.readHumidity(); | |
| int t = dht.readTemperature(); | |
| if (isnan(h) || isnan(t)) { | |
| Serial.println("Failed to read from DHT sensor!"); | |
| return; | |
| } | |
| Serial.print("["); | |
| Serial.print(count); | |
| Serial.print(","); | |
| Serial.print(h); | |
| Serial.print(","); | |
| Serial.print(t); | |
| Serial.println("]"); | |
| count++; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment