c# - 树莓派 2 和 BMP280 : Slave address was not acknowledged

标签 c# windows arduino raspberry-pi2 windowsiot

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

上查看我的连接

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

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

最佳答案

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

我看到您正在使用 Adafruit 分线板,并将基于此引用引脚。

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

  2. 接下来是 Vin。 Hackster.io 上的 Fritzing 图像不正确。 Vin 应该连接到你的 3.3V 线,PI 上的引脚 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 时 HDMI 端口指向您,而 SD 卡插槽在左侧,您对 Pi 上的引脚连接感兴趣,那么您对 ​​40 针接头的最左边的引脚感兴趣.

5V | 5V |地面
3.3V | SDA(SDI) |时钟信号

另请参阅此标题图。 Pi3 Header Map

关于c# - 树莓派 2 和 BMP280 : Slave address was not acknowledged,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35368372/

相关文章:

抽象类特定代码的 C# 模式

c# - 如何初始化字典数组

c# - 如何使用 MVVM 将焦点设置到文本框?

windows - 可以在 Windows 和 Mac OS 上使用的类似 DB 的 Redis 吗?

c - 程序不读取整个文件

c++ - 键盘有一些问题

c - 如何使用多路复用器查看以前的数据

c# - 您能否在运行时从外部修改 Java(更具体地说是 javaw)的内存?

c++ - 如何同步 2 个或更多监视文件夹

c++ - Arduino:在构造函数中初始化自定义对象