This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[参考译文] TMP117:在 ESP32 上 TMP117 无响应–I2C 上的 ESP_ERR_TIMEOUT

Guru**** 2905440 points

Other Parts Discussed in Thread: TMP117

请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/sensors-group/sensors/f/sensors-forum/1642266/tmp117-tmp117-not-responding-on-esp32-esp_err_timeout-on-i2c

器件型号: TMP117

您好、

我尝试使用 ESP-IDF 将 TMP117 温度传感器与 ESP32 DevKit 连接。 传感器位于 SmartElex 分线板上。 我收到超时错误、I2C 扫描发现总线上没有器件。

设置:

  • MCU:ESP32 DevKit
  • 框架:esp-idf(旧的 i2c 驱动程序)
  • SDA:GPIO21、SCL:GPIO22
  • 使用的 I2C 地址:0x48(如图所示,板上的 ADDR 跳线桥接至 0x48)
  • 上拉:启用内部 GPIO 上拉(电路板可能也有板载上拉电阻)
  • VCC:3.3V、GND 已连接

错误:

ESP_ERR_TIMEOUT (0x107)

I2C 扫描结果: 在任何地址 (0x08 至 0x78) 中均未找到器件

我尝试过的方法:

  • 已验证 ADDR 跳线是否位于 0x48
  • 尝试了 I2C_NUM_0 (GPIO21/22) 和 I2C_NUM_1 (GPIO18/19)
  • 已运行完整的 I2C 总线扫描—未找到器件
  • 启用和禁用内部上拉电阻

    问题:

    1. 这可能是分线板的电源问题吗?
    2. 在 I2C 上 TMP117 响应之前、上电后是否有任何特定的启动时间?
    3. 此传感器在总线上没有顶升是否有任何已知问题?

    连接显示 ADDR 跳线配置的分线板背面。

    谢谢tmp117.jpeg

    #include <stdio.h>
    #include "driver/i2c.h"
    #include "esp_log.h"
    
    #define I2C_MASTER_SCL_IO    22
    #define I2C_MASTER_SDA_IO    21
    #define I2C_MASTER_NUM       I2C_NUM_0
    #define I2C_MASTER_FREQ_HZ   100000
    
    void app_main()
    {
        i2c_config_t conf = {
            .mode = I2C_MODE_MASTER,
            .sda_io_num = I2C_MASTER_SDA_IO,
            .scl_io_num = I2C_MASTER_SCL_IO,
            .sda_pullup_en = GPIO_PULLUP_ENABLE,
            .scl_pullup_en = GPIO_PULLUP_ENABLE,
            .master.clk_speed = I2C_MASTER_FREQ_HZ,
        };
        i2c_param_config(I2C_MASTER_NUM, &conf);
        i2c_driver_install(I2C_MASTER_NUM, conf.mode, 0, 0, 0);
    
        printf("Scanning I2C bus...\n");
    
        for (uint8_t addr = 0x08; addr < 0x78; addr++) {
            i2c_cmd_handle_t cmd = i2c_cmd_link_create();
            i2c_master_start(cmd);
            i2c_master_write_byte(cmd, (addr << 1) | I2C_MASTER_WRITE, true);
            i2c_master_stop(cmd);
            esp_err_t ret = i2c_master_cmd_begin(I2C_MASTER_NUM, cmd, pdMS_TO_TICKS(50));
            i2c_cmd_link_delete(cmd);
            if (ret == ESP_OK) {
                printf("Found device at 0x%02X\n", addr);
            }
        }
    
        printf("Scan done.\n");
    }
    
    
    
    // these are the terminal output i am getting 
    W (299) spi_flash: Detected size(4096k) larger than the size in the binary image header(2048k). Using the size in the binary image header.
    W (312) i2c: This driver is an old driver, please migrate your application code to adapt `driver/i2c_master.h`
    I (323) main_task: Started on CPU0
    I (333) main_task: Calling app_main()
    E (1333) TMP117: Failed: ESP_ERR_TIMEOUT (0x107)
    E (4333) TMP117: Failed: ESP_ERR_TIMEOUT (0x107)
    E (7333) TMP117: Failed: ESP_ERR_TIMEOUT (0x107)
  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    1.是的,这可能是电源问题。

    2. 上电时有 1.5ms 的复位时间。

    3. TMP117 没有已知问题。 NACK 是所有 I2C 器件的一个常见问题。

    检查 SCL/SDA 处的电压。 它应该处于高怠速状态。 如果它不是高电平、则必须安装上拉电阻器。

    检查您的连接。

    使用示波器或逻辑分析仪检查 SCL/SDA 活动。

    谢谢、

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    我使用万用表检查了 SDA 和 SCL 上是否有稳定的电源  

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    请继续调试示波器或逻辑分析仪。