일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- OCPP
- Android
- raspberry
- flask
- 디자인패턴
- everon
- 라즈베리파이
- thread
- homeassistant
- STM32
- dynamodb
- YMODEM
- 완속충전기
- 급속충전기
- 안드로이드
- 펌웨어
- 충전기
- 홈어시스턴트
- 전기차
- lambda
- 전기차충전기
- IOT Core
- 전기차충전
- esp8266
- 서버리스
- 보안
- 에버온
- 플라스크
- AWS
- 파이썬
Archives
- Today
- Total
Louie NRT Story
[Node MCU ESP8266] Monitoring DHT11 via thingspeak 본문
반응형
Writed 24 DEC 2019
Why I am posting blog at work on Christmas Adam.
1. System DiagramESP8266 and DHT11 Schematic Diagram
2. Login
3. Make My Channel
4. Input Text
- There are many options with help next to them
5. Change charing setting from private to public
6. Install Library
7. Save as Open Example Code
- To avoid library issues
8. Input your infomation
- You can find Channel ID and Write_APIkey on API Keys tap
9. Code
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
67
68
69
70
71
72
73
|
#include "DHT.h"
#include "ThingSpeak.h"
#include "secrets.h"
#include <ESP8266WiFi.h>
#define DHTPIN 5 // Digital pin connected to the DHT sensor
#define DHTTYPE DHT11 // DHT 11
DHT dht(DHTPIN, DHTTYPE);
char ssid[] = SECRET_SSID; // your network SSID (name)
char pass[] = SECRET_PASS; // your network password
int keyIndex = 0; // your network key Index number (needed only for WEP)
WiFiClient client;
unsigned long myChannelNumber = SECRET_CH_ID;
const char * myWriteAPIKey = SECRET_WRITE_APIKEY;
int number = 0;
void setup() {
Serial.begin(115200); // Initialize serial
ThingSpeak.begin(client); // Initialize ThingSpeak
dht.begin();
}
void loop() {
// Connect or reconnect to WiFi
Serial.print("Attempting to connect to SSID: ");
Serial.println(SECRET_SSID);
WiFi.begin(ssid, pass); // Connect to WPA/WPA2 network. Change this line if using open or WEP network
Serial.print(".");
delay(5000);
}
Serial.println("\nConnected.");
}
float h = dht.readHumidity();
float t = dht.readTemperature();
// Check if any reads failed and exit early (to try again).
if (isnan(h) || isnan(t)) {
Serial.println(F("Failed to read from DHT sensor!"));
return;
}
ThingSpeak.setField(1, t);
ThingSpeak.setField(2, h);
// Write to ThingSpeak. There are up to 8 fields in a channel, allowing you to store up to 8 different
// pieces of information in a channel. Here, we write to field 1.
int x = ThingSpeak.writeFields(myChannelNumber, myWriteAPIKey);
if(x == 200){
Serial.println("Channel update successful.");
}
else{
Serial.println("Problem updating channel. HTTP error code " + String(x));
}
Serial.print(F("Humidity: "));
Serial.print(F("% Temperature: "));
Serial.println(F("°C "));
delay(20000); // Wait 20 seconds to update the channel again
}
|
10. Result
Reference
반응형
'에너지' 카테고리의 다른 글
[나인와트] 2019 Incheon Civic Hack-Fair (0) | 2020.01.05 |
---|---|
[기본상식] App 만드는 방법 (0) | 2019.12.26 |
[Node MCU ESP8266] LED On/Off via thinger.io (0) | 2019.12.20 |
[Arduino UNO] DHT11 (0) | 2019.12.17 |
[NodeMCU ESP 8266] DHT11 (0) | 2019.12.16 |
Comments