四博智联产品售后

 找回密码
 立即注册
搜索
查看: 13148|回复: 0

设置Wifi热点

[复制链接]

252

主题

302

帖子

1817

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
1817
发表于 2015-12-28 18:06:32 | 显示全部楼层 |阅读模式
  1. /*
  2. 可以将您的espduino设置为wifi热点(Soft AP 模式)
  3. */
  4. #include <ESP8266WiFi.h>
  5. /* Create a WiFi access point and provide a web server on it. */
  6. #include <WiFiClient.h>
  7. #include <ESP8266WebServer.h>

  8. /* Set these to your desired credentials. */
  9. const char *ssid = "Charlie Testing AP";
  10. const char *password = "11111111";

  11. ESP8266WebServer server(80);

  12. /* Just a little test message.  Go to http://192.168.4.1 in a web browser
  13. * connected to this access point to see it.
  14. */
  15. void handleRoot() {
  16.   server.send(200, "text/html", "<h1>You are connected</h1>");
  17. }

  18. void setup() {
  19.   delay(1000);
  20.   Serial.begin(115200);
  21.   Serial.println();
  22.   Serial.print("Configuring access point...");
  23.   /* You can remove the password parameter if you want the AP to be open. */
  24.   WiFi.softAP(ssid, password);

  25.   IPAddress myIP = WiFi.softAPIP();
  26.   Serial.print("AP IP address: ");
  27.   Serial.println(myIP);
  28.   server.on("/", handleRoot);
  29.   server.begin();
  30.   Serial.println("HTTP server started");
  31. }

  32. void loop() {
  33.   server.handleClient();
  34. }
复制代码


回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|四博智联 Inc. ( 粤ICP备15034758号-1

GMT+8, 2024-3-28 19:37 , Processed in 0.054951 second(s), 23 queries .

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表