手机直接连接esp8266辐射的WIFI,通信。

https://item.taobao.com/item.htm?spm=a230r.1.14.20.eYblO3&id=521945102409&ns=1&abbucket=7#detail

#include <ESP8266WiFi.h>
 
const char *ssid = "Charlie Testing AP";
const char *password = "12345678";
WiFiServer server(80);
void setup()
{
  Serial.begin(115200);
  Serial.println();
 
  Serial.print("Setting soft-AP ... ");
   
IPAddress softLocal(192,168,128,1);  
IPAddress softGateway(192,168,128,1);
IPAddress softSubnet(255,255,255,0);
 
WiFi.softAPConfig(softLocal, softGateway, softSubnet);  
 
    WiFi.softAP(ssid, password);
   
   IPAddress myIP = WiFi.softAPIP();
  Serial.print("AP IP address: ");
  Serial.println(myIP);
 server.begin();
 Serial.printf("Web server started, open %s in a web browser\n", WiFi.localIP().toString().c_str());
 
}
 
void loop()
{
 WiFiClient client = server.available();
 if (client)
  {
    Serial.println("\n[Client connected]");
    while (client.connected())
    {
      // read line by line what the client (web browser) is requesting
      if (client.available())
      {
        String line = client.readStringUntil('\r');
        Serial.print(line);
        // wait for end of client's request, that is marked with an empty line
        if (line.length() == 1 && line[0] == '\n')
        {
          client.println(prepareHtmlPage());
 
           
          break;
        }
      }
    }
    delay(1); // give the web browser time to receive the data
 
    // close the connection:
    client.stop();
    Serial.println("[Client disonnected]");
  }
 
 
}
 
// prepare a web page to be send to a client (web browser)
String prepareHtmlPage()
{
  String htmlPage =
     String("HTTP/1.1 200 OK\r\n") +
            "Content-Type: text/html\r\n" +
            "Connection: close\r\n" +  // the connection will be closed after completion of the response
            "Refresh: 5\r\n" +  // refresh the page automatically every 5 sec
            "\r\n" +
            "<!DOCTYPE HTML>" +
            "<html>" +
            "Analog input:  " + String(analogRead(A0)) +
            "</html>" +
            "\r\n";
  return htmlPage;<br>}

  

Arduino IDE for ESP8266 项目云盒子 (1)AP直接模式的更多相关文章

  1. Arduino IDE for ESP8266 项目云盒子(2)一键自配置+网页服务器

    https://item.taobao.com/item.htm?spm=a230r.1.14.20.eYblO3&id=521945102409&ns=1&abbucket= ...

  2. Arduino IDE for ESP8266 项目云盒子(3)外网访问

    互联网访问esp8266 https://item.taobao.com/item.htm?spm=a230r.1.14.20.eYblO3&id=521945102409&ns=1& ...

  3. Arduino IDE for ESP8266 项目云盒子(4)组网

  4. Arduino IDE for ESP8266 项目(4)HTTP客户端+服务端

    Arduio for esp8266  官网API:http://arduino-esp8266.readthedocs.io/en/latest/esp8266wifi/readme.html 很有 ...

  5. Arduino IDE for ESP8266 项目(1) 点亮灯+按键LED+pwm

    官方文档 http://esp8266.github.io/Arduino/versions/2.1.0/doc/libraries.html 引脚口说明 http://yfrobot.com/thr ...

  6. Arduino IDE for ESP8266 项目(3)创建AP+STA

    官网API:http://arduino-esp8266.readthedocs.io/en/latest/esp8266wifi/readme.html STA (客户端)手机连接路由器 S1 *简 ...

  7. Arduino IDE for ESP8266 项目(2)wifi扫描

    #include "ESP8266WiFi.h" void setup() { Serial.begin(115200); //设定WiFi为STA模式,如果先前已连接上AP,则与 ...

  8. Arduino IDE for ESP8266教程(二) 创建WIFI AP模式

    创建WIFI热点 #include <ESP8266WiFi.h> void setup() { Serial.begin ( 115200 ); Serial.println(" ...

  9. ESP8266开发之旅 进阶篇② 闲聊Arduino IDE For ESP8266烧录配置

    授人以鱼不如授人以渔,目的不是为了教会你具体项目开发,而是学会学习的能力.希望大家分享给你周边需要的朋友或者同学,说不定大神成长之路有博哥的奠基石... QQ技术互动交流群:ESP8266&3 ...

随机推荐

  1. [转]Angular 2 / 4 / 5 not working in IE11

    本文转自:https://stackoverflow.com/questions/35140718/angular-2-4-5-not-working-in-ie11/47777695#4777769 ...

  2. SQL Server新建登录名,实现SQL Server身份验证模式

    一.如果是默认安装,没有选择SQL Server和Windows身份验证模式,需要重新设置. 1.右击服务器,属性,常规项中点选“SQL Server和Windows身份验证模式” 2.点击“确定”按 ...

  3. LeetCode 任务调度器-Python3<八>

    题目:https://leetcode-cn.com/problems/task-scheduler/description/ 给定一个用字符数组表示的 CPU 需要执行的任务列表.其中包含使用大写的 ...

  4. 使用 Immutable Subject 来驱动 Angular 应用

    现状 最近在重构手上的一个 Angular 项目,之前是用的自己写的一个仿 Elm 架构的库来进行的状态管理,期间遇到了这些痛点: 样板代码太多 异步处理太过繁琐 需要单独维护一个 npm 包 其中, ...

  5. 有道云笔记链接——JAVA面向对象的学习

     http://note.youdao.com/noteshare?id=cf39a0e493a6b3c7ad5d22204a7e7843

  6. (三)Sass和Compass--制作精灵图片

    6.1 精灵的工作原理 // 将各种图片合并到一张图片里面,并在不同的状态下改变背景图片的位置; 6.2 精灵的重要性 // 压缩图片的内存; // 减少HTTP请求 6.2.3 Compass处理精 ...

  7. 小结:ES7——async和await初识

    一.async async其实是ES7才有有的关键字,async的意思是异步,顾名思义是有关异步的操作 async用于声明一个函数是异步的. 通常情况下async.await都是跟随promise一起 ...

  8. 【读书笔记】iOS-自定义 URL Scheme 完全指南

    iPhone / iOS SDK 最酷的特性之一就是应用将其自身”绑定”到一个自定义 URL scheme 上,该 scheme 用于从浏览器或其他应用中启动本应用.   注册自定义 URL Sche ...

  9. 安卓开发之ScrollView

    当界面不足以将所有的内容显示出来的时候便导致下面的部分内容无法显示出来 所有加上ScrollView 来讲要显示的内容放入之中便可以实现上下滚动界面内容 但是当要显示多个控件的时候会出错  原因是Sc ...

  10. sqlserver 2017 docker安装(启动代理)

    从 Docker Hub 中拉出 SQL Server 2017 Linux 容器映像. docker pull microsoft/mssql-server-linux:2017-latest 运行 ...