施勢帆老師的教學網站

 找回密碼
 立即註冊
搜索
熱搜: 活動 交友 discuz
查看: 3035|回復: 0

ESP13 wifi Shield

[複製鏈接]

609

主題

619

帖子

2897

積分

管理員

Rank: 9Rank: 9Rank: 9

積分
2897
發表於 2022-3-24 15:27:30 | 顯示全部樓層 |閱讀模式
http://www.mantech.co.za/datashe ... IELD-ESP13_KEYS.pdf

https://mouse.ee.aeust.edu.tw/Data/Program/ai/IFTTT.zip


Test.ino

#define DEBUG true

String sendData(String command, const int timeout, boolean debug){
    String response = "";
    Serial1.print(command); // send the read character to the esp8266
    long int time = millis();
    while( (time+timeout) > millis()){
      while(Serial1.available()){
        // The esp has data so display its output to the serial window
        char c = Serial1.read(); // read the next character.
        response+=c;
      }  
    }
    if(DEBUG)    {
        Serial.print(response);
    }
    return response;
}

void setup()
{
  Serial.begin(115200);
  while(!Serial);
  Serial1.begin(115200);
  sendData("AT+RST\r\n",2000,DEBUG);
  sendData("AT+CWMODE=3\r\n",2000,DEBUG);
  String commend = "AT+CWJAP=\"";
  commend += "AP-SSID";
  commend += "\",\"";
  commend += "Password";
  commend += "\"\r\n";
  if (sendData(commend,5000,DEBUG)){  
    Serial.print("Join AP success\r\n");
    Serial.print("IP:");
    sendData("AT+CIFSR\r\n",5000,DEBUG);
    sendData("AT+CIPSERVER=0\r\n",200,DEBUG);
    sendData("AT+CIPMUX=0\r\n",200,DEBUG);
  }
}

void loop()
{
  if(Serial1.available()){
    Serial.write(Serial1.read());
  }
  if(Serial.available()){
    Serial1.write(Serial.read());
  }
}      


-----------------------------------------------------------------------------------------------------------------------------------------
String commends = "AT+CIPSTART=\"TCP\",\"";
  commends += host;
  commends += "\",";
  commends += httpsPort; //443
  commends += "\r\n";
  sendData(commends,1000,DEBUG);

  String GET = "GET /update?api_key=T6HJZN26NA26L5FU";
  GET += "&field1=";
  GET += DHT.temperature;
  GET += "&field2=";
  GET += DHT.humidity;
  GET += " HTTP/1.1\r\nHost:";
  GET += host;
  GET += "\r\n\r\n";
  Serial.println(GET);
  String cipSend = "AT+CIPSEND=";

  cipSend += GET.length();
  cipSend += "\r\n";
  sendData(cipSend,500,DEBUG);
  sendData(GET,500,DEBUG);
  delay(200);
  sendData("AT+CIPCLOSE\r\n",500,DEBUG);
  delay(1000);   
  sendData("AT+CIFSR\r\n",5000,DEBUG); --------------------------------------------------------------------------------------------------------------------------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="zh-Hant-TW"><head><meta http-equiv="content-type" content="text/html; charset=UTF-8">

<head>
<title>GET方式接收帳號與密碼</title></head>

<meta http-equiv="refresh" content="60; url=https://news.google.com.tw/">

<body>
接收的姓名為<? echo $_GET['username'];?><br>
接收的密碼為<? echo $_GET['passwd'];?><br>
</body></html>

http://127.0.0.1/test.php?username=abc&passwd=12345

Database
https://mouse.oit.edu.tw/Discuz_X3.2/forum.php?mod=viewthread&tid=1125&extra=page%3D1





本帖子中包含更多資源

您需要 登錄 才可以下載或查看,沒有帳號?立即註冊

x
回復

使用道具 舉報

您需要登錄後才可以回帖 登錄 | 立即註冊

本版積分規則

Archiver|手機版|小黑屋|施勢帆老師的教學網站

GMT+8, 2024-11-22 10:19 , Processed in 0.056953 second(s), 19 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回復 返回頂部 返回列表