-
Notifications
You must be signed in to change notification settings - Fork 585
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
[SHT4x] Read serial number of sensor module #2091
Conversation
…to the sample program.
@dotnet-policy-service agree |
/azp run dotnet.iot |
Azure Pipelines successfully started running 1 pipeline(s). |
ushort? msb = Sensirion.ReadUInt16BigEndianAndCRC8(buffer); | ||
ushort? lsb = Sensirion.ReadUInt16BigEndianAndCRC8(buffer.Slice(3, 3)); | ||
|
||
return lsb + (msb << 16); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In to the example C code provided by Sensirion the serial number is also output as a 32 bit integer. When the manufacturer of the chip interprets the serial number in this way I think it would be best to be consistent and also use a 32 bit integer here.
https://github.com/Sensirion/embedded-sht/blob/master/sht4x/sht4x.c#L103
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok but on this example code, nothing is done with this int. So the question is: how to properly use this version? Are there some specific int versions which can be tested?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed, in this code the serial is just stored in a 32 bit integer, at the pointer which was passed through at function call. There is no example code that uses it.
The Adafruit library has it also implemented in a similar way and has an example on how the serial is used:
Code:
https://github.com/adafruit/Adafruit_SHT4X/blob/master/Adafruit_SHT4x.cpp#L83
Example:
https://github.com/adafruit/Adafruit_SHT4X/blob/master/examples/SHT4test/SHT4test.ino#L26
Serial.println("Found SHT4x sensor");
Serial.print("Serial number 0x");
Serial.println(sht4.readSerial(), HEX);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, still, there is no check. So I4m fine with this int.
The current module has no implementation for reading the serial number of the SHT4x device.
This PR implements the reading of the serial number of the SHT4x device.
Microsoft Reviewers: Open in CodeFlow