Add a diag script for Raspberry Pi user to check i2c && GPIO functinality - #46
Open
raz0rsedge1975 wants to merge 2 commits into
Open
Add a diag script for Raspberry Pi user to check i2c && GPIO functinality#46raz0rsedge1975 wants to merge 2 commits into
raz0rsedge1975 wants to merge 2 commits into
Conversation
GPIO && I2C diagnostics for Raspberry Pi's
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
After messing around with a dozen different Pi's with MS430 sensor boards and running into some challenging difficulties with i2c bus errors and/or GPIO errors (even if the sensor board was running fine before), I decided to write me a script that can do some diagnosis.
Why:
It may be helpful since even running Pi's with MS430 can run into errors due to loose cable, corrosion, updates etc.
i2c has some flaws that may render the sensor board unusable (bus blocking) until removing power cable for 10 secs
and GPIO is also difficult to handle, depending on your Ri hardware and OS version.
What it checks:
SDA/SCL pin function and level via raspi-gpio get (read-only — does not reconfigure the pins, so the I2C bus stays untouched)
Status pins (LIGHT_INT, SOUND_INT, READY)
I2C reachability at address 0x71
Register write access (reset command + particle sensor select register), polling READY after reset instead of a fixed delay
Summary output:
The script ends with a clear DIAGNOSTICS FINISHED: OK (GO) / NOT OK (NOGO) summary, listing any failed checks by name, and exits with code 0 (OK) or 1 (NOT OK) — so it can be used in cron/systemd/CI health checks, not just interactively.
Dependencies:
Python: RPi.GPIO, smbus (already used elsewhere in this repo)
System package: raspi-gpio (sudo apt install raspi-gpio) — optional; if missing, that one check is skipped and reported as such, everything else still runs.