Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CRCs doesn't match #2

Closed
efimovalex opened this issue Feb 12, 2019 · 1 comment
Closed

CRCs doesn't match #2

efimovalex opened this issue Feb 12, 2019 · 1 comment

Comments

@efimovalex
Copy link

efimovalex commented Feb 12, 2019

Code:

const i2CAddress = 0x5c
const i2CBus = 1

// Server struct
type 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()
}

Debug info:

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)

Any ideea why the CRC from sensor is 0?
I am able to read the sensor on the same bus with the same address with a python script.

@efimovalex
Copy link
Author

Found the issue, the function ReadRelativeHumidityAndTemperatureMult10 for AM2320 makes reads twice, submitted a PR with the changes that fixes this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant