1. 구조
2. 파일
https://drive.google.com/file/d/11o5nqnPRkZ3wJ09gnJ6fC0YKESXlhlhr/view?usp=sharing
5. 파일
아두이노 만들기
#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>
#include <DHT.h>
#define DHTPIN D7 // DHT11이 연결된 핀
#define DHTTYPE DHT11 // DHT 11, DHT시리즈중 11을 선택합니다.
const char* DATA_NAME = "Temp";
const char* ssid = "와이파이 아이디";
const char* password = "비밀번호";
DHT dht(DHTPIN, DHTTYPE);
void setup () {
Serial.begin(115200);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(1000);
Serial.print("Connecting..");
}
dht.begin();
}
void loop() {
float h = dht.readHumidity();// 습도를 측정합니다.
float t = dht.readTemperature();// 온도를 측정합니다.
if(int(h) != 0 && int(t) != 0){
if (WiFi.status() == WL_CONNECTED) { //Check WiFi connection status
HTTPClient http; //Declare an object of class HTTPClient
String str = "http://내 아이피/inputdata.php?";
str += "&name=";
str += DATA_NAME;
str += "&temp=";
str += t;
str += "&humm=";
str += h;
http.begin(str); //Specify request destination
int httpCode = http.GET(); //Send the request
if (httpCode > 0) { //Check the returning code
String payload = http.getString(); //Get the request response payload
Serial.println(payload); //Print the response payload
}
http.end(); //Close connection
}
delay(90000); //Send a request every 90 seconds
}
}