{"id":735,"date":"2015-06-15T01:22:24","date_gmt":"2015-06-14T16:22:24","guid":{"rendered":"https:\/\/hack.gpl.jp\/?p=735"},"modified":"2015-06-15T01:22:24","modified_gmt":"2015-06-14T16:22:24","slug":"post-735","status":"publish","type":"post","link":"https:\/\/hack.gpl.jp\/2015\/06\/15\/post-735.html","title":{"rendered":"ESP12\u5358\u4f53\u3067\u6e7f\u5ea6\u6e29\u5ea6\u7167\u5ea6\u306eIoT\u30c7\u30d0\u30a4\u30b9"},"content":{"rendered":"

\u524d\u56de\u306f\u3001Arduino Nano \u3067DHT22\u306e\u6e7f\u5ea6\u3068\u3001\u6e29\u5ea6\u3092\u30b2\u30c3\u30c8\u3057\u3066\u3044\u307e\u3057\u305f\u3002<\/p>\n

 <\/p>\n

\n

\u7de8\u96c6\u5f8c\u8a18<\/p>\n

\u305d\u306e\u5f8c\u3001\u30ea\u30c1\u30a6\u30e0\u96fb\u6c60\u3068\u7d44\u307f\u3042\u308f\u305b\u3001IoT \u30c7\u30d0\u30a4\u30b9\u3092\u4f5c\u3063\u305f\u8a18\u4e8b\u304c\u3053\u3061\u3089
\u521d\u3081\u3066\u306eIoT\u30c7\u30d0\u30a4\u30b9\u5b8c\u6210<\/a><\/p>\n

\"image\" <\/p>\n<\/blockquote>\n

 <\/p>\n

IoT\u30c7\u30d0\u30a4\u30b9\u3068\u3057\u3066\u30c7\u30fc\u30bf\u3092\u6295\u3052\u3064\u3051\u305f\u3044\u306e\u3067\u3001ESP12\u3001\u5358\u4f53\u3067\u30b3\u30fc\u30c7\u30a3\u30f3\u30b0\u3057\u307e\u3057\u305f\u3002\u3053\u3093\u306a\u611f\u3058\u3067\u3001\u524d\u56de\u4f5c\u6210\u3057\u305f\u3082\u306e\u306b\u3001\u4ed8\u3051\u52a0\u3048\u308b\u611f\u3058\u3067\u3068\u308a\u3042\u3048\u305a\u30c6\u30b9\u30c8\u3002<\/p>\n

\"\u5199\u771f <\/p>\n

 <\/p>\n

\u30b3\u30fc\u30c9\u306f\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u3057\u307e\u3057\u305f\u3002\u30a2\u30af\u30bb\u30b9\u30dd\u30a4\u30f3\u30c8\u3084\u3001ThingSpeak \u306e\u66f8\u304d\u8fbc\u307fAPI key \u306a\u3069\u306f\u307b\u3069\u3088\u304f\u66f8\u304d\u63db\u3048\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n

\u30dd\u30a4\u30f3\u30c8\u306f\u3001DHT \u306e\u30e9\u30a4\u30d6\u30e9\u30ea\u3092\u521d\u671f\u5316\u3059\u308b\u3068\u304d\u306e\u7b2c3\u306e\u30d1\u30e9\u30e1\u30fc\u30bf\u3067\u3001\u3044\u308d\u3044\u308d\u8a66\u3057\u305f\u7d50\u679c\u300115\u3060\u3068\u3046\u307e\u304f\u5024\u304c\u53d6\u308c\u308b\u3088\u3046\u3067\u3059\u3002\u307e\u3060\u3001\u3053\u306e\u5024\u306f\u3088\u304f\u308f\u304b\u3063\u3066\u3044\u307e\u305b\u3093\u304c\u3001CPU Clock \u306b\u5bfe\u5fdc\u3059\u308b\u5024\u306e\u3088\u3046\u3067\u3001Arduino \u3068\u304b\u306f\u300116Mhz \u306e\u306f\u30c7\u30d5\u30a9\u30eb\u30c8\u3067\u3001Arduino Due \u3068\u304b 84mhz \u306f\u300130 \u306b\u305b\u3088\u3068\u306e\u3053\u3068\u3002<\/p>\n

 <\/p>\n

\u3053\u306e\u5024\u306f\u3001\u4ee5\u4e0b\u306e\u30b3\u30fc\u30c9\u3092\u898b\u3066\u307f\u308b\u3068\u3001ESP01 \u306f 11 \u3067\u52d5\u4f5c\u3059\u308b\u3088\u3046\u3067\u3059\u3002<\/p>\n

\n

https:\/\/learn.adafruit.com\/esp8266-temperature-slash-humidity-webserver\/code<\/a><\/a><\/p>\n

\/\/ Initialize DHT sensor
\/\/ NOTE: For working with a faster than ATmega328p 16 MHz Arduino chip, like an ESP8266,
\/\/ you need to increase the threshold for cycle counts considered a 1 or 0.
\/\/ You can do this by passing a 3rd parameter for this threshold.  It’s a bit
\/\/ of fiddling to find the right value, but in general the faster the CPU the
\/\/ higher the value.  The default for a 16mhz AVR is a value of 6.  For an
\/\/ Arduino Due that runs at 84mhz a value of 30 works.
\/\/ This is for the ESP8266 processor on ESP-01
DHT dht(DHTPIN, DHTTYPE, 11); \/\/ 11 works fine for ESP8266<\/p>\n<\/blockquote>\n

ESP12 \u3067\u306f\u300111 \u3060\u3068\u5024\u304c\u304a\u304b\u3057\u304f\u306a\u308a\u300115 \u3060\u3068\u3046\u307e\u304f\u53d6\u308c\u307e\u3057\u305f\u3002\u3042\u3068\u3001IDE \u306f\u3001arduino 1.6.4 \u4ee5\u4e0a\u3067\u4eca\u56de\u306f Hourly Build  \u3092\u4f7f\u3044\u307e\u3057\u305f\u3002Boards Manager \u3068\u3044\u3046\u6a5f\u80fd\u304c\u52a0\u308f\u308a\u3001\u30c4\u30fc\u30eb\u30e1\u30cb\u30e5\u30fc\u306e\u30dc\u30fc\u30c9\u304b\u3089\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3067\u304d\u307e\u3059\u3002<\/p>\n

\u624b\u52d5\u3067\u5165\u308c\u3066\u3082\u3044\u3044\u3093\u3067\u3059\u304c\u3001\u307e\u3041\u4fbf\u5229\u306a\u6a5f\u80fd\u304c\u3064\u304d\u307e\u3057\u305f\u306d\u3002<\/p>\n

\n

http:\/\/arduino.esp8266.com\/package_esp8266com_index.json<\/a><\/p>\n<\/blockquote>\n

 <\/p>\n

\/\nESP8266 HTTP get webclient.\nADC Read (ESP12 + Light(CdS GL5528)) + DHT22(AM2302) 1-Wire\nhttps:\/\/thingspeak.com\/channels\/42239<\/a>\nArduino IDE 1.6.5 Hourly Build 2015\/06\/12 03:13\nesp8266 by ESP8266 Community version 1.6.4-673-g8cd3697\nJunkHack 2015.06.15\n<\/em>\/<\/p>\n

include <ESP8266WiFi.h><\/h1>\n

include <DHT.h><\/h1>\n

define DHTPIN 4<\/h1>\n

define DHTTYPE DHT22<\/h1>\n

DHT dht(DHTPIN, DHTTYPE, 15);<\/p>\n

const char ssid = "JunkHack";\nconst char<\/em> password = "testtest";<\/p>\n

const char* host = "184.106.153.149";<\/p>\n

int WiFiConLed = 13;\/\/ WEB Connect\nint WEBconLed = 0; \/\/ WiFi Connect<\/p>\n

void setup() {\ndht.begin();<\/p>\n

pinMode(WiFiConLed, OUTPUT);\npinMode(WEBconLed, OUTPUT);\nSerial.begin(115200);\ndelay(10);<\/p>\n

\/\/ We start by connecting to a WiFi network<\/p>\n

Serial.println();\nSerial.println();\nSerial.print("Connecting to ");\nSerial.println(ssid);<\/p>\n

WiFi.begin(ssid, password);<\/p>\n

while (WiFi.status() != WL_CONNECTED) {\ndelay(500);\nSerial.print(".");\ndigitalWrite(WiFiConLed, HIGH);\ndelay(400);\ndigitalWrite(WiFiConLed, LOW);\ndelay(100);\n}<\/p>\n

Serial.println("");\nSerial.println("WiFi connected");\nSerial.println("IP address: ");\nSerial.println(WiFi.localIP());<\/p>\n

Serial.println("DHT22 AM2302 test!");\n}<\/p>\n

int value = 0;\nint count = 0;\nint adc = 0;\nfloat h = 0;\nfloat t = 0;<\/p>\n

void loop() {\ndelay(10000); \/\/ 10 sec\n++value;<\/p>\n

Serial.print("connecting to ");\nSerial.println(host);<\/p>\n

\/\/ Use WiFiClient class to create TCP connections\nWiFiClient client;\nconst int httpPort = 80;\nif (!client.connect(host, httpPort)) {\nSerial.println("connection failed");\nreturn;\n}<\/p>\n

digitalWrite(WEBconLed, HIGH);\ndelay(1000);\ncount += 1;<\/p>\n

Serial.print("ADC: ");\nadc = analogRead(A0);\nSerial.println(adc);<\/p>\n

float h = dht.readHumidity();\nfloat t = dht.readTemperature();<\/p>\n

if (isnan(h) || isnan(t) ) {\nSerial.println("Failed to read from DHT sensor!");\nreturn;\n}<\/p>\n

Serial.print("Humidity: ");\nSerial.print(h);\nSerial.print(" %\\t");\nSerial.print("Temperature: ");\nSerial.print(t);\nSerial.println(" *C ");<\/p>\n

\/\/ We now create a URI for the request\nString url = "\/update?key=33HJNSWFZ8EZAXD6&field1=";\nurl += adc;\nurl += "&field2=";\nurl += h;\nurl += "&field3=";\nurl += t;<\/p>\n

Serial.print("Requesting URL: ");\nSerial.println(url);<\/p>\n

\/\/ This will send the request to the server\nclient.print(String("GET ") + url + " HTTP\/1.1\\r\\n" +\n"Host: " + host + "\\r\\n" +\n"Connection: close\\r\\n\\r\\n");\ndelay(10);<\/p>\n

\/\/ Read all the lines of the reply from server and print them to Serial\nwhile(client.available()){\nString line = client.readStringUntil('\\r');\nSerial.print(line);\n}<\/p>\n

\/\/ Close connection\nSerial.println();\nSerial.println("closing connection");\ndigitalWrite(WEBconLed, LOW);\n}<\/pre>\n<\/p>\n

\u00a0<\/p>\n

\u30c7\u30fc\u30bf\u306f\u3001\u3068\u307e\u3063\u3066\u3044\u308b\u3068\u304d\u3082\u3042\u308b\u304b\u3082\u3067\u3059\u304c\u3001\u4ee5\u4e0b\u3067\u898b\u308c\u307e\u3059\u3002<\/p>\n

\u00a0<\/p>\n

https:\/\/thingspeak.com\/channels\/42239<\/a><\/p>\n

\u00a0<\/p>\n

\"2015-06-15<\/a> <\/p>\n

\u00a0<\/p>\n

\u90e8\u5c4b\u306e\u6e29\u5ea6\u304c\u305d\u3053\u305d\u3053\u9ad8\u3044\u306e\u3067\u3001\u5b9f\u969b\u306b\u6e29\u5ea6\u8a08\u3092\u898b\u3066\u307f\u307e\u3057\u305f\u3068\u3053\u308d\u3001\u307b\u307c\u9069\u6b63\u306a\u5024\u3067\u3057\u305f\u3002\u90e8\u5c4b\u6691\u3059\u304e\u3002<\/p>\n

\"\u5199\u771f <\/p>\n

\u00a0<\/p>\n

\u3053\u308c\u3067\u3001\u660e\u308b\u3055\u3001\u6e29\u5ea6\u3001\u6e7f\u5ea6\u304c\u53d6\u308c\u307e\u3057\u305f\u3002\u307e\u3060\u3001GPIO Pin \u304c\u3042\u307e\u3063\u3066\u3044\u308b\u306e\u3067\u3001\u6c17\u5727\u3084\u3001\u96e8\u91cf\u3001\u98a8\u5411\u3001\u98a8\u91cf\u306a\u3069\u53d6\u308d\u3046\u3068\u601d\u3048\u3070\u53ef\u80fd\u3067\u3059\u306d\u3002\u307e\u305f\u3001\u8ab2\u984c\u3068\u306a\u308b\u306e\u306f\u3001\u96fb\u6e90\u3067\u3059\u3002\u7d50\u69cb\u30b7\u30d3\u30a2\u306b\u96fb\u6e90\u54c1\u8cea\u304c\u554f\u308f\u308c\u308b\u3088\u3046\u3067\u3001\u307c\u308d\u3044\u96fb\u6e90\u3060\u3068\u9014\u4e2d\u3067\u6b62\u307e\u308a\u307e\u3059\u3002<\/p>\n

\u00a0<\/p>\n

\u3042\u3068\u3001sleep mode \u306b\u3057\u3066\u5e73\u5e38\u6642\u306b\u3001\u30d1\u30ef\u30fc\u3092\u6291\u3048\u308b\u3088\u3046\u306b\u5236\u5fa1\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n

\u00a0<\/p>\n

\u307e\u3060\u3001\u8ab2\u984c\u306f\u3042\u308a\u307e\u3059\u306d\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

\u524d\u56de\u306f\u3001Arduino Nano \u3067DHT22\u306e\u6e7f\u5ea6\u3068\u3001\u6e29\u5ea6\u3092\u30b2\u30c3\u30c8\u3057\u3066\u3044\u307e\u3057\u305f\u3002   \u7de8\u96c6\u5f8c\u8a18 \u305d\u306e\u5f8c\u3001\u30ea\u30c1\u30a6\u30e0\u96fb\u6c60\u3068\u7d44\u307f\u3042\u308f\u305b\u3001IoT \u30c7\u30d0\u30a4\u30b9\u3092\u4f5c\u3063\u305f\u8a18\u4e8b\u304c\u3053\u3061\u3089 \u521d\u3081\u3066\u306eIoT\u30c7\u30d0\u30a4\u30b9\u5b8c\u6210   […]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_uag_custom_page_level_css":"","footnotes":""},"categories":[6,30,63],"tags":[],"acf":[],"uagb_featured_image_src":{"full":false,"thumbnail":false,"medium":false,"medium_large":false,"large":false,"1536x1536":false,"2048x2048":false,"post-thumbnail":false},"uagb_author_info":{"display_name":"JunkHack","author_link":"https:\/\/hack.gpl.jp\/author\/junkhack\/"},"uagb_comment_info":2,"uagb_excerpt":"\u524d\u56de\u306f\u3001Arduino Nano \u3067DHT22\u306e\u6e7f\u5ea6\u3068\u3001\u6e29\u5ea6\u3092\u30b2\u30c3\u30c8\u3057\u3066\u3044\u307e\u3057\u305f\u3002   \u7de8\u96c6\u5f8c\u8a18 \u305d…","_links":{"self":[{"href":"https:\/\/hack.gpl.jp\/wp-json\/wp\/v2\/posts\/735"}],"collection":[{"href":"https:\/\/hack.gpl.jp\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hack.gpl.jp\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hack.gpl.jp\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/hack.gpl.jp\/wp-json\/wp\/v2\/comments?post=735"}],"version-history":[{"count":0,"href":"https:\/\/hack.gpl.jp\/wp-json\/wp\/v2\/posts\/735\/revisions"}],"wp:attachment":[{"href":"https:\/\/hack.gpl.jp\/wp-json\/wp\/v2\/media?parent=735"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hack.gpl.jp\/wp-json\/wp\/v2\/categories?post=735"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hack.gpl.jp\/wp-json\/wp\/v2\/tags?post=735"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}