Raspberry pi 2 和 BMP280:从站地址未被确认

Raspberry pi 2 and BMP280 : Slave address was not acknowledged

我在 https://www.hackster.io Windows IOT 上关注项目 WheatherStation
我在 github 上下载了项目并在 Raspberry 上连接了我的 BMP280 传感器。
你可以在

上查看我的连接

对我来说,这是正确的,但我有一个例外 bmp280.WriteRead(WriteBuffer, ReadBuffer);

System.IO.FileNotFoundException: The system cannot find the file specified. Slave address was not acknowledged.

这可能是 I2C 总线的问题(因为未收到 ACK)。

如果没问题,请交叉检查您是否使用 --recursive 标志克隆了他们的存储库?使用它可以正确克隆所有子模块。 (否则可能会丢失一些文件。)

这个问题有几个不同的原因,其中大部分与硬件有关。

我看到您使用的是 Adafruit 分线板,将参考基于此的引脚。

  1. 确保您的 SDO 和 SCL 线正确连接到您的 Raspberry PI。 SDO 应该连接到引脚 3,SCL 应该连接到引脚 5。从你的图表图片来看,这应该是正确的。

  2. 接下来是 Vin。 Hackster.io 上的 Fritzing 图像不正确。 Vin 应该连接到你的 3.3V 线,PI 上的 Pin 1。

    This is because Vin is the supply level of your logic signal. In this case the Raspberry PI is 3.3V, putting it at 5 can cause issues where data is not properly clocked in via I2C.

  3. 最后,通过将 SDO 连接到 V3.3 来将其拉高。

    The reason for this is if you read the datasheet for the BMP280/BME280 and look at the schematic you will see SDO has a pullup resistor that pulls it to 3.3V it's internal logic level. This is going to be exceptionally weird if using 5v rails as you're not technically in a tristate neither low nor hi so you will probably end up with a random address.

    Pulling this to 0V via ground will cause the slave address to be 0x76. With it pulled high the slave address of the BMP280/BME280 sensor will be 0x77. From looking at their supplied code they expect this pin to be pulled high giving a 0x77 address.

#3 的另一种软件解决方案是更改 BME280 设备代码中的 I2C 从地址。在示例代码中,它包含在 Lesson_203\StartSolution\BMP280.cs:

class BMP280
{
    //The BMP280 register addresses according the the datasheet: http://www.adafruit.com/datasheets/BST-BMP280-DS001-11.pdf
    const byte BMP280_Address = 0x77;  //If SDI is pulled high 0x77, if pulled low 0x76
    const byte BMP280_Signature = 0x58;

最后,你的 Pi 上的引脚连接,如果你从顶部看 pi,HDMI 端口指向你,左边的 SD 卡插槽,你对 40 个最左边的引脚感兴趣引脚 header.

5V | 5V |地面
3.3V | SDA(SDI) | SCLK

另请参阅这张 header 地图。 Pi3 Header Map

检查你的电线。确保它们被完全推到正确的位置。这对我来说是个问题。

你必须焊接 BMP280...