【问题标题】:NodeMCU tmr.alarm always returns falseNodeMCU tmr.alarm 总是返回 false
【发布时间】:2016-10-11 05:20:09
【问题描述】:

我的 NodeMCU 有问题,尝试在 esp8266 上启动 tmr.alarm。

tmr.alarm 从不启动计时器,并且总是返回 false。 我试过更改计时器,甚至更改闹钟的类型(自动、单次...),但我总是得到相同的结果。

这是代码的一部分,我尝试每 5 秒左右与 DS18B20(OneWire 温度传感器)通信一次。

if not tmr.alarm(1, 5000, tmr.ALARM_AUTO, function() 
      -- Comunication with the sensor
    end)
then print("Comunication with DS18B20 couldn't be started.") end

输出总是

Comunication with DS18B20 couldn't be started.

【问题讨论】:

  • 您的代码与straight from the book 差不多,看起来还可以。您使用什么固件(版本、模块)?您是否有其他计时器正在运行,可能在同一个 ID 上?
  • 没有其他计时器在运行,NodeMCU 版本 0.9.5 也许更新固件会很方便?

标签: lua esp8266 nodemcu


【解决方案1】:

不要使用来自https://github.com/nodemcu/nodemcu-firmware/releases 的旧 0.9.x NodeMCU 二进制文件,它们不再受支持并且包含大量错误。 Build a custom firmware 来自 devmaster 分支。

我不知道最近版本中有任何计时器错误。

【讨论】:

  • 感谢您的帮助。该软件现在运行顺利,并且自定义构建消耗的内存比我的其他构建要少。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2020-04-22
  • 2016-07-20
  • 2021-11-05
  • 2018-11-05
  • 2019-05-06
  • 2017-04-29
  • 2013-04-30
相关资源
最近更新 更多