-
Notifications
You must be signed in to change notification settings - Fork 816
fix: fix data acquisition from SHT21 temperature and humidity sensor #2774
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
Conversation
Reviewer's GuideThis PR refactors the SHT21 sensor acquisition pipeline by introducing an enum-based mode API, static and concise data‐conversion methods with robust checksum/error handling, updates dependent data‐fetch and UI code to the new API, and cleans up logging, unused fields, and adds documentation for I2C.readBulk. Sequence diagram for SHT21 sensor data acquisition with new enum-based APIsequenceDiagram
participant SensorSHT21 as SensorSHT21.SensorDataFetch
participant SHT21 as SHT21
participant I2C as I2C
SensorSHT21->>SHT21: setMode(Mode.TEMPERATURE)
SensorSHT21->>SHT21: getRaw()
SHT21->>I2C: writeBulk(ADDRESS, [registerAddress])
SHT21->>I2C: readBulk(ADDRESS, registerAddress, 3)
I2C-->>SHT21: List<Integer> vals
SHT21->>SHT21: calculateChecksum(vals, 2)
SHT21->>SHT21: rawToTemp(vals)
SHT21-->>SensorSHT21: Double temperature
SensorSHT21->>SHT21: setMode(Mode.HUMIDITY)
SensorSHT21->>SHT21: getRaw()
SHT21->>I2C: writeBulk(ADDRESS, [registerAddress])
SHT21->>I2C: readBulk(ADDRESS, registerAddress, 3)
I2C-->>SHT21: List<Integer> vals
SHT21->>SHT21: calculateChecksum(vals, 2)
SHT21->>SHT21: rawToRH(vals)
SHT21-->>SensorSHT21: Double humidity
Class diagram for SensorSHT21.SensorDataFetch data handling changesclassDiagram
class SensorSHT21.SensorDataFetch {
-Double dataSHT21Temp
-Double dataSHT21Humidity
-float timeElapsed
+boolean getSensorData()
+void updateUi()
}
SensorSHT21.SensorDataFetch --> SHT21
Class diagram for I2C readBulk method additionclassDiagram
class I2C {
+ArrayList<Integer> readBulk(int deviceAddress, int registerAddress, int bytesToRead)
}
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Build successful. APKs to test: https://github.com/fossasia/pslab-android/actions/runs/16101167033/artifacts/3472568630 |
Part of #2773
The fixed code can be used as a template for the Flutter version of the app.
Changes
Screenshots / Recordings
Screen_recording_20250706_184339.mp4
Checklist:
strings.xml
,dimens.xml
andcolors.xml
without hard coding any value.strings.xml
,dimens.xml
orcolors.xml
.Summary by Sourcery
Fix SHT21 sensor data acquisition by correcting register addresses, conversion formulas, and checksum handling; refactor measurement API to use an enum; and improve logging, buffer management, and error handling across sensor and communication modules.
Bug Fixes:
Enhancements:
Documentation: