亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

AM2320 傳感器:CRC 不匹配,來自傳感器的 CRC(0)

AM2320 傳感器:CRC 不匹配,來自傳感器的 CRC(0)

Go
繁華開滿天機 2023-06-05 18:24:51
注意:代碼是在 windows 10 中交叉編譯的。代碼:package mainimport (    "fmt"    "io"    "log"    "net/http"    aosong "github.com/d2r2/go-aosong"    i2c "github.com/d2r2/go-i2c")const i2CAddress = 0x5cconst i2CBus = 1// Server structtype Server struct {    Sensor *aosong.Sensor    I2C    *i2c.I2C}func main() {        var err error    s := Server{Sensor: aosong.NewSensor(aosong.AM2320)}    s.I2C, err = i2c.NewI2C(i2CAddress, i2CBus)    if err != nil {        log.Printf(err.Error())    }    fmt.Println(s.Sensor.ReadRelativeHumidityAndTemperature(s.I2C))    defer s.I2C.Close()}調試信息:2019-02-12T10:29:19.692 [     i2c] DEBUG  Write 3 hex bytes: [030004]2019-02-12T10:29:19.697 [     i2c] DEBUG  Read 8 hex bytes: [0304012500d92045]2019-02-12T10:29:19.698 [     i2c] DEBUG  Read 8 hex bytes: [0000000000000000]CRCs doesn't match: CRC from sensor(0) != calculated CRC(6912).知道為什么來自傳感器的 CRC 為 0 嗎?我能夠使用 python 腳本讀取具有相同地址的同一總線上的傳感器。
查看完整描述

1 回答

?
翻翻過去那場雪

TA貢獻2065條經驗 獲得超14個贊

庫本身似乎有問題,它進行了兩次讀取,但由于未發送讀取代碼,因此值變為 0,如日志中所示:


2019-02-12T10:29:19.692 [? ? ?i2c] DEBUG? Write 3 hex bytes: [030004]

2019-02-12T10:29:19.697 [? ? ?i2c] DEBUG? Read 8 hex bytes: [0304012500d92045] (first read that was ignored)

2019-02-12T10:29:19.698 [? ? ?i2c] DEBUG? Read 8 hex bytes: [0000000000000000] (second one that came a 0)

CRCs doesn't match: CRC from sensor(0) != calculated CRC(6912)

查看完整回答
反對 回復 2023-06-05
  • 1 回答
  • 0 關注
  • 172 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號