查看: 949|回复: 0

小e开发板打造Hello World网页服务器

[复制链接]
  • TA的每日心情
    奋斗
    2019-10-1 12:54
  • 签到天数: 313 天

    连续签到: 1 天

    [LV.8]以坛为家I

    发表于 2016-4-27 12:43:45 | 显示全部楼层 |阅读模式
    分享到:
    下面介绍使用小e开发板打造一个简易Hello World网页服务器,首先按下面的帖子搭载开发环境
    https://www.eeboard.com/bbs/thread-47295-1-1.html
    然后新建源代码输入如下

    #include <ESP8266WiFi.h>#include <WiFiClient.h>#include <ESP8266WebServer.h>#include <ESP8266mDNS.h>const char* ssid = "无线信号名称";const char* password = "无线密码";MDNSResponder mdns;ESP8266WebServer server(80);void handleRoot() {  server.send(200, "text/plain", "Hello World!");}void handleNotFound(){  String message = "File Not Foundnn";  message += "URI: ";  message += server.uri();  message += "nMethod: ";  message += (server.method() == HTTP_GET)?"GET":&quotOST";  message += "nArguments: ";  message += server.args();  message += "n";  for (uint8_t i=0; i<server.args(); i++){    message += " " + server.argName(i) + ": " + server.arg(i) + "n";  }  server.send(404, "text/plain", message);}void setup(void){  Serial.begin(115200);  WiFi.begin(ssid, password)  Serial.println("");  // Wait for connection  while (WiFi.status() != WL_CONNECTED) {    delay(500);    Serial.print(".");  }  Serial.println("");  Serial.print("Connected to ");  Serial.println(ssid);  Serial.print("IP address: ");  Serial.println(WiFi.localIP());  if (mdns.begin("esp8266", WiFi.localIP())) {    Serial.println("MDNS responder started");  }  server.on("/", handleRoot);  server.on("/inline", [](){    server.send(200, "text/plain", "this works as well");  });  server.onNotFound(handleNotFound);  server.begin();  Serial.println("HTTP server started");}void loop(void){  server.handleClient();}然后在菜单栏选Build

    然后设置串口

    然后把程序上传到小e开发板中,把小e所有的拨码开关拨到自己想用的功能上,按住开发板 AirKiss 键不放给开发板上电,然后点击upload按键,等待程序烧写完毕运行,接着在路由器里面找到小e开发板的局域网IP,在浏览器里面输入小e开发板的局域网IP即可显示如下
    回复

    使用道具 举报

    您需要登录后才可以回帖 注册/登录

    本版积分规则

    关闭

    站长推荐上一条 /4 下一条

    手机版|小黑屋|与非网

    GMT+8, 2024-11-16 16:52 , Processed in 0.124891 second(s), 18 queries , MemCache On.

    ICP经营许可证 苏B2-20140176  苏ICP备14012660号-2   苏州灵动帧格网络科技有限公司 版权所有.

    苏公网安备 32059002001037号

    Powered by Discuz! X3.4

    Copyright © 2001-2024, Tencent Cloud.