查看: 844|回复: 0

LinkNode R4 ——1.试用

[复制链接]
  • TA的每日心情
    开心
    2020-1-10 15:57
  • 签到天数: 14 天

    连续签到: 1 天

    [LV.3]偶尔看看II

    发表于 2016-11-21 09:34:45 | 显示全部楼层 |阅读模式
    分享到:
    本文基于爱板网 板卡资料:https://www.eeboard.com/evaluation/linknode-r4/
    和爱板网经验频道,作者NinthCode 的文章——LinkNode R4 试用(1)
    https://jingyan.eeboard.com/article/75453
    总结而来!阅读本文之前还请先阅读一下前人的文章,在此我也再次分类整理一下
    发现的坑:
    1.按照官方给的教程:首先打开Arduino IDE,在文件->首选项->附加开发板管理网址处添加:https://arduino.esp8266.com/versions/2.3.0/package_esp8266com_index.json  有的网络不一定能链接上外国网站,这第一个坑就是翻墙!在这里也给大家推荐一款很不错的翻墙软件——Hotspot Shield ,我在公司的电脑(电信宽带)的时候是不需要翻墙的,家里(长城宽带)确实不好连上

    2.官方板卡资料里第四页"还要在在开发板的库管理器中添加wifimanger的库,打开项目-->管理库"  这句话里单词“wifimanger”编写错误,害我找半天,最终发现是这个单词错误,实际应该是“WiFiManager”
    3.爱板网经验频道,作者NinthCode 的文章——LinkNode R4 试用(1)
    这篇文章的程序是有错的,应该用,板卡资料内的代码修改!
    #include <esp8266wifi.h>   #include <wstring.h>   //the library are needed for autoconfig WiFi   #include <dnsserver.h>   #include <esp8266webserver.h>   #include <wifimanager.h>   // replace with your own API key and device ID,   String apikey = "6fecfa4c-93bc-4704-b8d4-bf2aee5f5d62";   const char* deviceID="02000000dd";  const char* server = "<a href="https://www.linksprite.io" ;"="">www.linksprite.io";</a>  WiFiClient client; void setup() {   Serial.begin(115200);   pinMode(12, OUTPUT);   WiFiManager wifiManager;   wifiManager.setAPStaticIPConfig(IPAddress(10,0,1,1), IPAddress(10,0,1,1), IPAddress(255,255,255,0));   wifiManager.autoConnect("LinkNodeAP");   Serial.print("WiFi Connected ...n");   Serial.println("WiFi connected"); } void loop() {   if (client.connect(server,80)) {   String  postStr ="{";           postStr +="\"action\":\"query\",";           postStr +="\"apikey\":\"";           postStr += apikey;           postStr +="\",";           postStr +="\"deviceid\":\"";           postStr += deviceID;           postStr +="\",";           postStr += "\"params\":";           postStr += "[";           postStr += "\"light\"";           postStr +="]";           postStr +="}";      client.print(&quotOST /api/http HTTP/1.1n");      client.print("Host: ");      client.print(server);      client.print("nContent-Type: application/jsonn");      client.print("Content-Length: ");      client.print(postStr.length());      client.print("nn");      client.print(postStr);   }   delay(1000);   Serial.println("Store response...");   String request = "";   while (client.available()) {     char c = client.read();     request +=c;   } if (request!= NULL) {   int index1 = request.indexOf(":{");   int index2 = request.indexOf("},");   String param = request.substring(index1, index2 + 1);   Serial.print("The param is ");   Serial.println(param);   if(param.indexOf("off")>0){       digitalWrite(12, LOW);       Serial.println("OFF");   } else if(param.indexOf("on")>0){       digitalWrite(12, HIGH);       Serial.println("ON");   } client.stop(); Serial.println("Waiting..."); delay(2000); } }</wifimanager.h></esp8266webserver.h></dnsserver.h></wstring.h></esp8266wifi.h>到此终于编译完成
    总的来所此板资料内的坑非常多!
    请大家多试试各种方法!总能成功
    待续……
    回复

    使用道具 举报

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

    本版积分规则

    关闭

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

    手机版|小黑屋|与非网

    GMT+8, 2024-5-14 08:24 , Processed in 0.123603 second(s), 18 queries , MemCache On.

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

    苏公网安备 32059002001037号

    Powered by Discuz! X3.4

    Copyright © 2001-2024, Tencent Cloud.