Skip to content

Instantly share code, notes, and snippets.

@okn3
Created February 20, 2016 07:53
Show Gist options
  • Select an option

  • Save okn3/9d9634268ab540b0377a to your computer and use it in GitHub Desktop.

Select an option

Save okn3/9d9634268ab540b0377a to your computer and use it in GitHub Desktop.
IoTハッカソン o202用
#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