metriful / sensor

Sensor by Metriful | Indoor environment monitoring | Documentation and code samples
https://www.sensor.metriful.com
MIT License
110 stars 37 forks source link

Not working on Raspberry Pi B Rev 2.0 - raises "NotImplementedError' #38

Closed Ch3wi3 closed 1 month ago

Ch3wi3 commented 1 month ago

I tried to repurpose my trusty old RPI1 B rev 2.0 as a environment sensor platform. I purchased a ms430 and tried to use the example python scripts.

Unfortunately the lib rpi-lgpio crashed with the error message: "NotImplementedError - 'This module does not understand old-style revision codes'"

After poking aroung in: /usr/lib/python3/dist-packages/RPi/GPIO/__init__.py I found def _get_rpi_info() and applied my own 'sledgehammer method' there. I hardcoded the following right at the beginning of def _get_rpi_info():

 revision = int('000e',base=16)
 return {'P1_REVISION':0,'REVISION':hex(revision)[2:],'TYPE':'Model B','MANUFACTURER':'Sony UK','PROCESSOR':'BCM2835','RAM':'512M'}

This obviously circumvents the whole revsion-parsing stuff in def _get_rpi_info()` and I am not sure at all if this hack has some nasty side effects but in my case it worked like a charm: I can now use the Metriful sensor example python scripts without any problem.

I also opened an issue at the githup repo of rpi-lgpio but I think the Readme in here should be updated with a workaround for RPI B rev. 2.0 users like me ;-)

metriful commented 1 month ago

Thanks and well done for getting it working! We will try to include this in the next release.