Ameba-AIoT / ameba-arduino-pro2

AmebaPro2 Arduino third-party package SDK
https://www.amebaiot.com/en/ameba-arduino-summary/
MIT License
50 stars 23 forks source link

I2C Scanner Showing Additional Non-Existent Device Address #254

Open Oliver0804 opened 4 months ago

Oliver0804 commented 4 months ago

Boards

AMB82MINI

External Hardware

icm42688 ,sht30

Hardware Configuration

no.

Version

latest main (checkout manually)

IDE Name

arduino 1.8.19

Operating System

macOS M3

Auto Flash Mode

Disable

Erase All Flash Memory (16MB)

Disable

Standard Lib

Arduino_STD_PRINTF

Upload Speed

2000000

Description

Testing the I2C scanner example: SDA => GPIO12 SCL => GPIO13 However, I found that the scan result always shows an additional non-existent device address, while there is actually only one device on the I2C bus.

Sketch

// --------------------------------------
// i2c_scanner
// This sketch tests the standard 7-bit addresses
// Devices with higher bit address might not be seen properly.
// ---------------------------------------

/*

 Example guide:
 https://www.amebaiot.com/en/amebapro2-arduino-i2c-scan/
 */

#include <Wire.h>

void setup()
{
    Wire.begin();

    Serial.begin(115200);
    while (!Serial)
        ;    // wait for serial monitor
    Serial.println("\nI2C Scanner");
}

void loop()
{
    byte error, address;
    byte x = 0;
    int nDevices;

    Serial.println("Scanning...");

    nDevices = 0;
    for (address = 0; address < 127; address++) {
        // The i2c_scanner uses the return value of
        // the Write.endTransmisstion to see if
        // a device did acknowledge to the address.
        Wire.beginTransmission(address);
        Wire.write(x);
        error = Wire.endTransmission();

        if (error == 0) {
            Serial.print("I2C device found at address 0x");
            if (address < 16) {
                Serial.print("0");
            }
            Serial.print(address, HEX);
            Serial.println("  !");

            nDevices++;
        } else if (error == 4) {
            Serial.print("Unknown error at address 0x");
            if (address < 16) {
                Serial.print("0");
            }
            Serial.println(address, HEX);
        }
    }
    if (nDevices == 0) {
        Serial.println("No I2C devices found\n");
    } else {
        Serial.println("done\n");
    }

    delay(5000);    // wait 5 seconds for next scan
}

Error/Debug Message

.

Reproduce remarks

截圖 2024-07-13 下午5 06 01 截圖 2024-07-13 下午5 06 14

No response

I have checked online documentation, FAQ, GitHub Wiki and existing/closed issues.

github-actions[bot] commented 3 months ago

This issue is stale because it has been open for 14 days with no activity.