How to use BME280 connected with SPI on Automation PHAT?


#1

Hello
unfortunately I’m not able to get the Adafruit BME280 sensor on the SPI ports from the Automation PHAT running.
Raspberry Pi zero W
-I’m running the latest Raspbian stretch image
-Automation PHAT is running fine
-All Adafruit SW is installed and is running
-Output from blinka test is:
Hello blinka!
Digital IO ok!
I2C ok!
SPI ok!
done!
-wireing is checked, as CS port I configured CE0 (BCM8) --> D8

Code:
#!/usr/bin/python3
import board
import busio
import digitalio
import adafruit_bme280
spi = busio.SPI(board.SCK, MOSI=board.MOSI, MISO=board.MISO)
cs = digitalio.DigitalInOut(board.D8)
bme280 = adafruit_bme280.Adafruit_BME280_SPI(spi, cs)
print("\nTemperature: %0.1f C" % bme280.temperature)
print(“Humidity: %0.1f %%” % bme280.humidity)
print(“Pressure: %0.1f hPa” % bme280.pressure)

Output:
Traceback (most recent call last):
File “./getMeteo.py”, line 8, in
bme280 = adafruit_bme280.Adafruit_BME280_SPI(spi, cs)
File “/usr/local/lib/python3.5/dist-packages/adafruit_bme280.py”, line 247, in init
super().init()
File “/usr/local/lib/python3.5/dist-packages/adafruit_bme280.py”, line 78, in init
raise RuntimeError(‘Failed to find BME280! Chip ID 0x%x’ % chip_id)
RuntimeError: Failed to find BME280! Chip ID 0xff

any suggestion for further troubleshooting?

many thanks and kind regards


#2

I don’t think the automation pHat factors into it, per say. Other than maybe a soldering issue? I do believe the SPI just passes right through it. You could try your BME280 without the Automation Phat and see if you get the same error.


#3

Thanks for reply
You’r right, the pHat only passes right through. In the meantime I tested without pHat and had no success.
BUT, I also tested to use other CS port. As example I connected the CS port of the sensor with BCM5 (D5) port with success! It works. My conclusion, the standard configuration of my raspberry uses the SPI0 CE0 already.
Unfortunately with the Ports on the pHat I have no choice.
Any suggestion for further troubleshoot this issue?


#4

I don’t have any ideas for testing, its out of my skill level. If you put a Proto pHat in there on a stacking header, between your Pi and automation pHat. You could use i2c instead, assuming there is no address conflict.