// ------------------------------------------ // AI Thinker A1S Chip identifier for Arduino // i2c_scanner Easy LED detection // AC101 LED 4 is high (next to earphone jack) // ES8388 LED 5 is active (next to earphone jack) // Serial messages 115200 are also available // Friedemann Wolpert 2021 #include const byte led_5 = 19; const byte led_4 = 22; void setup() { bool bFound = false; Wire.begin(33, 32); // Begin with AC-101 Audio Codec Chip pinMode(led_4, OUTPUT); pinMode(led_5, OUTPUT); Serial.begin(115200); Serial.println("\nsetup() finished\n"); digitalWrite(led_4, HIGH); // turn the LED on (HIGH is the voltage level) digitalWrite(led_5, HIGH); // turn the LED on (HIGH is the voltage level) delay(1000); // LED`s should be off after reset } void loop() { byte error, address; int nDevices; Serial.println("Scanning AC-101 address..."); Wire.begin(33, 32); // AC-101 Audio Codec Chip nDevices = 0; for(address = 1; 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); error = Wire.endTransmission(); if (error == 0) { Serial.print("AC-101 I2C device found at address 0x"); digitalWrite(led_4, LOW); // turn LED4 on 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); } } delay (250); Serial.println("Scanning ES-8388 address..."); Wire.begin(18, 23); // ES-8388 Audio Codec Chip nDevices = 0; for(address = 1; 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); error = Wire.endTransmission(); if (error == 0) { Serial.print("ES-8388 I2C device found at address 0x"); digitalWrite(led_5, LOW); // turn LED5 on 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 }