我构建了这个项目:http://www.instructables.com/id/Low-cost-WIFI-temperature-data-logger-based-on-ESP/?ALLSTEPS ESP8266输出了一些东西,我认为应该可以。但是在Thingspeak频道里没有条目。我已经检查过API写键了。这是串行输出:
Setting up WIFI...
> IP unavaiable, Waiting...
IP unavaiable, Waiting...
IP unavaiable, Waiting...
IP unavaiable, Waiting...
IP unavaiable, Waiting...
IP unavaiable, Waiting...
Config done, IP is 192.168.1.9
Last temp: 216875
Temp:21.6875.6875 C
Sending data to thingspeak.com
Last temp: 216875
Temp:21.6875.6875 C
Sending data to thingspeak.com
Got disconnection...
Last temp: 216875
Temp:21.6875.6875 C
Sending data to thingspeak.com
Got disconnection...
Last temp: 216875
Temp:21.6875.6875 C
Sending data to thingspeak.com
Got disconnection...
Last temp: 216875
Temp:21.6875.6875 C我该如何解决这个问题?
发布于 2016-03-02 16:06:24
您所引用的项目中的代码曾经起过作用,这是SDK中的一个bug。在预-1.0 SDK中,conn:send是同步的,也就是说,您可以按顺序调用它,它会阻塞,直到每个字符串被发送为止。Espressif后来将基础函数更改为异步函数。因此,https://github.com/ok1cdj/ESP8266-LUA/blob/master/Thermometer-DS18B20-Thingspeak/ds1820.lua#L77的代码失败了。有关详细信息,请参阅net.socket:send() API文档。
但是,由于您已经使用了最新的固件版本(来自dev分支,我相信),您应该充分利用新的HTTP模块。http.put()比在原始套接字上操作方便得多。
有关如何将数据放入ThingSpeak,请参见ThingSpeak。
附带注意:我建议您也使用由DS18B20团队提供的modules/ds18b20中的NodeMCU示例代码。该代码更有可能与固件同步。
https://stackoverflow.com/questions/35732189
复制相似问题