淘宝;https://detail.tmall.com/item.htm?id=536504922008&spm=a1z09.2.0.0.5e160c66c76b3g&_u=e1qf7bf52e27

产品资料:http://www.kbgogo.com/forum.php?mod=viewthread&tid=64&extra=

烧录时版型和参数选择

测试样例1

说明:

  1. 程序输入 你要连接的路由器 名+密码。
  2. 烧录进入wemos d1 mini 板,程序自动连接路由器,并返回自己分配到的地址。
  3. 手机或电脑连接在同一个路由器下,打开网页,输入刚才返回的地址,网页看到结果。

1 烧录程序

/*
* Copyright (c) 2015, Majenko Technologies
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice, this
* list of conditions and the following disclaimer in the documentation and/or
* other materials provided with the distribution.
*
* * Neither the name of Majenko Technologies nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ #include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
#include <ESP8266mDNS.h> const char *ssid = "dongdong";
const char *password = "dongdong"; ESP8266WebServer server ( 80 ); const int led = 13; void handleRoot() {
digitalWrite ( led, 1 );
char temp[400];
int sec = millis() / 1000;
int min = sec / 60;
int hr = min / 60; snprintf ( temp, 400, "<html>\
<head>\
<meta http-equiv='refresh' content='5'/>\
<title>ESP8266 Demo</title>\
<style>\
body { background-color: #cccccc; font-family: Arial, Helvetica, Sans-Serif; Color: #000088; }\
</style>\
</head>\
<body>\
<h1>Hello from ESP8266!</h1>\
<p>Uptime: %02d:%02d:%02d</p>\
<img src=\"/test.svg\" />\
</body>\
</html>", hr, min % 60, sec % 60
);
server.send ( 200, "text/html", temp );
digitalWrite ( led, 0 );
} void handleNotFound() {
digitalWrite ( led, 1 );
String message = "File Not Found\n\n";
message += "URI: ";
message += server.uri();
message += "\nMethod: ";
message += ( server.method() == HTTP_GET ) ? "GET" : "POST";
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 );
digitalWrite ( led, 0 );
} void setup ( void ) {
pinMode ( led, OUTPUT );
digitalWrite ( led, 0 );
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" ) ) {
Serial.println ( "MDNS responder started" );
} server.on ( "/", handleRoot );
server.on ( "/test.svg", drawGraph );
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();
} void drawGraph() {
String out = "";
char temp[100];
out += "<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\" width=\"400\" height=\"150\">\n";
out += "<rect width=\"400\" height=\"150\" fill=\"rgb(250, 230, 210)\" stroke-width=\"1\" stroke=\"rgb(0, 0, 0)\" />\n";
out += "<g stroke=\"black\">\n";
int y = rand() % 130;
for (int x = 10; x < 390; x+= 10) {
int y2 = rand() % 130;
sprintf(temp, "<line x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" stroke-width=\"1\" />\n", x, 140 - y, x + 10, 140 - y2);
out += temp;
y = y2;
}
out += "</g>\n</svg>\n"; server.send ( 200, "image/svg+xml", out);
}

  2 连接路由器

我们只需要用浏览器打开这个IP就可以看到8266输出的内容了。

最新文章

  1. Asp.net在IE10、IE11下事件丢失经验总结
  2. 问题解决_(转载)VS2015无法启动 IIS Express Web解决办法
  3. 《C#高级编程》学习笔记------C#中的委托和事件(续)
  4. Ad Muncher 宣布免费
  5. CountDownLatch,一个同步辅助类,在完成一组正在其他线程中执行的操作之前,它允许一个或多个线程一直等待。
  6. 初始化一个本地GIT仓储
  7. redis1--redis的介绍
  8. HTTP请求分析工具Fiddler
  9. 有n个数,输出其中所有和为s的k个数的组合。
  10. mssql sqlserver isnull coalesce函数用法区别说明
  11. RecycleView的notifyItemRemoved使用注意
  12. 标识符and数据类型
  13. -source 1.5 中不支持泛型(请使用-source5或更高版本)
  14. Hibernate的应用
  15. 主键非自增列 EF 插入数据库引起的 ID 列不能为 NULL 的错误
  16. 判断两个IP是否处于同一子网(网段)
  17. Linux 任务管理 &amp;&amp; 常用指令
  18. Zabbix应用七:Zabbix发送短信报警
  19. 探索Java的日志世界
  20. Lua 中与字符串有关的函数学习

热门文章

  1. mysql中的游标使用
  2. Java 雇员管理小练习(理解面向对象编程)
  3. WPF通过附加属性控制窗口关闭
  4. 如何判断页面是pc端还是移动端,进入不同的页面
  5. deepin使用笔记-解决安装并解决gvim没有启动器的问题
  6. element-ui中table表头表格错误问题解决
  7. Hbase简单配置与使用
  8. XHTML结构化
  9. SD从零开始71 业务信息仓库(BW)
  10. 转 fiddler常见的应用场景