jardiamj / BYOWS_RPi

weeWX Driver for Build Your Own Weather Station for Raspberry Pi
GNU General Public License v3.0
7 stars 7 forks source link

Pin 8 is already in use by SPI...? #5

Closed MoTLD closed 4 years ago

MoTLD commented 4 years ago

Hi! Thanks for writing this driver, it'll let me get a bargain-basement weather station online...once I get it working. ;)

For now all I have is a BME280, so in weewx.conf I have a sensors = bme280 line so that should be all it's trying to access. But weewx can't load the driver. The log has the following lines:

Apr 20 10:45:36 raspberrypi weewx[3240]: BYOWS RPi: driver version is 0.51 Apr 20 10:45:36 raspberrypi weewx[3240]: engine: Import of driver failed: pin 8 is already in use by SPI(port=0, device=0) (<class 'gpiozero.exc.GPIOPinInUse'>) Apr 20 10:45:36 raspberrypi weewx[3240]: engine: Unable to load driver: pin 8 is already in use by SPI(port=0, device=0) Apr 20 10:45:36 raspberrypi weewx[3240]: **** Exiting...

I'm not sure why it should even be trying to talk to SPI or GPIO pin 8, as the sensor is hooked up to I2C on GPIO2/3.

I've tried the bme280_sensor.py sample script from the raspberrypi.org build instructions and it works fine, so I know the sensor is ok and is talking to the pi over I2C.

I've also tried running "PYTHONPATH=/usr/share/weewx python /usr/share/weewx/user/byows_rpi.py" to test it outside of weewx and see if I got a more detailed error message but all I get is the following:

Traceback (most recent call last): File "/usr/share/weewx/user/byows_rpi.py", line 335, in station = ByowsRpiStation() File "/usr/share/weewx/user/byows_rpi.py", line 113, in init self.bme280_sensor.load_calibration_params(self.bme280_bus, self.bme280_address) File "/usr/local/lib/python2.7/dist-packages/bme280/init.py", line 153, in load_calibration_params compensation_params.dig_T1 = read.unsigned_short(0x88) File "/usr/local/lib/python2.7/dist-packages/bme280/reader.py", line 40, in unsigned_short return self._bus.read_word_data(self._address, register) & 0xffff File "/usr/local/lib/python2.7/dist-packages/smbus2/smbus2.py", line 449, in read_word_data self._set_address(i2c_addr, force=force) File "/usr/local/lib/python2.7/dist-packages/smbus2/smbus2.py", line 333, in _set_address ioctl(self.fd, I2C_SLAVE, address) TypeError: argument must be an int, or have a fileno() method

Not sure what I'm doing wrong here, can you please help? Let me know if there's any more info you might need from me. Thanks!

MoTLD commented 4 years ago

Ok, I think I found the problem. Apparently the "sensors =" in the conf file isn't implemented, so it was trying to read sensors that aren't there. I just gutted everything not directly related to the bme280 and it seems to be working now, except that weewx lists rain as 0 instead of N/A like it does wind.

randallgray commented 4 years ago

Glad you were able to find the problem!

On Mon, Apr 20, 2020 at 9:08 AM Rob Havasy notifications@github.com wrote:

Ok, I think I found the problem. Apparently the "sensors =" in the conf file isn't implemented, so it was trying to read sensors that aren't there. I just gutted everything not directly related to the bme280 and it seems to be working now, except that weewx lists rain as 0 instead of N/A like it does wind.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/jardiamj/BYOWS_RPi/issues/5#issuecomment-616652712, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA7LMK2N632SCSYQ7AXOODDRNRXRRANCNFSM4MMRHWCQ .

jardiamj commented 4 years ago

I am also glad that you found the problem! I remember that I was planning on modifying the configuration options to make it more modular. I don't have the hardware so, I was relying on other people for testing it and since posting in the raspberrypi.org forums didn't show up any interest, I stopped working on it. It would be awesome if you can help improving the driver.

MoTLD commented 4 years ago

Well, the raspberrypi.org folks might not have appreciated it, but I do :)

For now, the BME280 was all I could afford so since I have it working I'm satisfied, but eventually I do plan on getting some wind sensors and maybe even building my own rain sensor. So I'll definitely be revisiting this project one day and if I make any significant changes to the driver I'll be sure to share them back. If I get to feeling really ambitious, maybe I can add that modularity you had planned...

randallgray commented 4 years ago

Jardi, I have the driver functioning with WeeWX 4.0.0b12 and Python 3 with the following sensors (I don't have the soil temp probe) -- BME280, VEML6075, SHT31d, and the wind/rain sensors from Argent Data ( https://www.argentdata.com/catalog/product_info.php?products_id=145). They are only an importer, I think it's actually made by Fine Offset in Taiwan(?).

I had to make changes to get the driver functioning in P3 and, of course, because I'm using different sensors and Adafruit drivers which run in Python 3 only.

Your code helped a great deal as it gave me something to start with -- thank you for the effort!

If you'd like, I can submit the changes I needed to get this functioning. I can do that via the GitHub project...

Thanks again for your work, Jardi.

Randall Gray

On Mon, Apr 20, 2020 at 10:31 PM Jardi Martinez notifications@github.com wrote:

I am also glad that you found the problem! I remember that I was planning on modifying the configuration options to make it more modular. I don't have the hardware so, I was relying on other people for testing it and since posting in the raspberrypi.org forums didn't show up any interest, I stopped working on it. It would be awesome if you can help improving the driver.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/jardiamj/BYOWS_RPi/issues/5#issuecomment-616961405, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA7LMK4L6PID3Z2RTSTT5ADRNUVR5ANCNFSM4MMRHWCQ .

jardiamj commented 4 years ago

@randallgray, It would be awesome if you could share those changes into the project!

peterleban commented 4 years ago

Ok, I think I found the problem. Apparently the "sensors =" in the conf file isn't implemented, so it was trying to read sensors that aren't there. I just gutted everything not directly related to the bme280 and it seems to be working now, except that weewx lists rain as 0 instead of N/A like it does wind.

Hi, can you please advise how you solved this issue? Maybe an excerpt from the weewx.conf? I just have a BME280 on the 0x76 address and a fresh weewx install. The startup error is the same as yours. Many thanks.

MoTLD commented 4 years ago

It's been a while since I did it so I can't remember the details, but basically I commented out everything in the byows_rpi.py script that didn't seem necessary, then uncommented things until it worked again. I'll just attach my current, working byows_rpi.py, hopefully it will work for you (I had to rename to .txt to attach it here, .py isn't a supported attachment type). Note that I've changed the driver name, you'll have to change it back or set station_type to match in weewx.conf. I've also included the applicable sections of weewx.conf.

byows_rpi.py.txt weewx.conf.snippet.txt

Good luck!