mit welcher I2C Adresse?
manche I2C libs verwenden übrigens die 7-bit Adresse (u.a. Arduino), manche die 8-bit Adresse.
für Arduino:
Code:// -------------------------------------- // i2c_scanner // // This sketch tests the standard 7-bit addresses // Devices with higher bit address might not be seen properly. // #include <Wire.h> #define ESP_SDA 4 //GPIO4=D2 SDA ESP8266 default #define ESP_SCL 5 //GPIO5=D1 SCL ESP8266 default byte error, address; int nDevices; void setup() { // Wire.begin(ESP_SDA,ESP_SCL); // only for ESP8266 if not default Wire.begin(); // AVR, ARM, ESP8266 default Serial.begin(115200); while (!Serial); // Leonardo: wait for serial monitor Serial.println("\nI2C Scanner"); Serial.println("\nScanning..."); } void loop() { nDevices = 0; for(address = 0; address < 128; address++ ) { if (address%16 == 0) { Serial.println(); Serial.print( (address+1)/16); Serial.print(" "); } if(address==0 || address==127) { Serial.print("** "); continue; } Wire.beginTransmission(address); error = Wire.endTransmission(); if (error == 0) { if (address<16) Serial.print("0"); Serial.print(address,HEX); Serial.print(" "); nDevices++; } else if (error==4) { Serial.print("?? "); } else { Serial.print("-- "); } } Serial.println(); Serial.print("found: "); Serial.print(nDevices); Serial.print(" devices \n"); delay(10000); }
Lesezeichen