294 Star 1.6K Fork 387

GVP合宙Luat / LuatOS

 / 详情

Air101@V0005 驱动AHT10问题

已完成
缺陷
创建于  
2021-12-15 16:54

固件版本

  • 固件名称:V0005_NOLVGL
  • 使用设备:Air101开发板
  • 使用功能:i2c

描述一下这个问题

无法正常与AHT10通信

复现步骤

测试脚本

sys.taskInit(function()
        local tag = "i2cTest"
        local i2cId = 0
        local i2cSlaveAddr = 0x38
        log.info(tag, "START")
        assert(i2c.setup(i2cId) == 0, tag .. ".setup ERROR")
        assert(i2c.send(i2cId, i2cSlaveAddr, string.char(0xac, 0x22, 0x00)) ==
                   true, tag .. ".send ERROR")
        local receivedData = i2c.recv(i2cId, i2cSlaveAddr, 6)
        assert(#receivedData == 6, tag .. ".recv ERROR")

        log.info(tag .. ".receivedDataHex", receivedData:toHex())
        local tempBit = string.byte(receivedData, 6) + 0x100 *
                            string.byte(receivedData, 5) + 0x10000 *
                            (string.byte(receivedData, 4) & 0x0F)
        local humidityBit = string.byte(receivedData, 4) & 0xF0 + 0x100 *
                                string.byte(receivedData, 3) + 0x10000 *
                                string.byte(receivedData, 2)
        humidityBit = humidityBit >> 4
        log.info(tag .. ".tempBit", tempBit)
        log.info(tag .. ".humidityBit", humidityBit)
        local calcTemp = (tempBit / 1048576) * 200 - 50
        local calcHum = humidityBit / 1048576
        log.info(tag .. ".当前温度", string.format("%.1f℃", calcTemp))
        log.info(tag .. ".当前湿度", string.format("%.1f%%", calcHum * 100))
        i2c.close(i2cId)

        log.info(tag, "DONE")
    end)

预期的行为

与AHT10正常通信

截图

测试

附件
Jeremy 2021-12-15 16:54

评论 (2)

Jeremy 创建了缺陷

v0005版的i2c有点问题, 云编译取个新固件吧

V0006已经解决了这个问题

Wendal 任务状态待办的 修改为已完成

登录 后才可以发表评论

状态
负责人
项目
里程碑
Pull Requests
关联的 Pull Requests 被合并后可能会关闭此 issue
分支
开始日期   -   截止日期
-
置顶选项
优先级
预计工期 (小时)
参与者(2)
4674 wendal 1578914274 5315890 hashjeremy 1663571659
Lua
1
https://gitee.com/openLuat/LuatOS.git
git@gitee.com:openLuat/LuatOS.git
openLuat
LuatOS
LuatOS

搜索帮助

344bd9b3 5694891 D2dac590 5694891