PlatformIO package of the Teensy core framework compatible with GCC 10 & C++20
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

pirms 3 gadiem
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. // --------------------------------------
  2. // i2c_scanner
  3. // http://playground.arduino.cc/Main/I2cScanner
  4. //
  5. // Version 1
  6. // This program (or code that looks like it)
  7. // can be found in many places.
  8. // For example on the Arduino.cc forum.
  9. // The original author is not know.
  10. // Version 2, Juni 2012, Using Arduino 1.0.1
  11. // Adapted to be as simple as possible by Arduino.cc user Krodal
  12. // Version 3, Feb 26 2013
  13. // V3 by louarnold
  14. // Version 4, March 3, 2013, Using Arduino 1.0.3
  15. // by Arduino.cc user Krodal.
  16. // Changes by louarnold removed.
  17. // Scanning addresses changed from 0...127 to 1...119,
  18. // according to the i2c scanner by Nick Gammon
  19. // http://www.gammon.com.au/forum/?id=10896
  20. // Version 5, March 28, 2013
  21. // As version 4, but address scans now to 127.
  22. // A sensor seems to use address 120.
  23. // Version 6, November 27, 2015.
  24. // Added waiting for the Leonardo serial communication.
  25. //
  26. //
  27. // This sketch tests the standard 7-bit addresses
  28. // Devices with higher bit address might not be seen properly.
  29. //
  30. #include <Wire.h>
  31. void setup() {
  32. // uncomment these to use alternate pins
  33. //Wire.setSCL(16);
  34. //Wire.setSDA(17);
  35. Wire.begin();
  36. Serial.begin(9600);
  37. while (!Serial); // Leonardo: wait for serial monitor
  38. Serial.println(F("\nI2C Scanner"));
  39. }
  40. void loop() {
  41. byte error, address;
  42. int nDevices;
  43. Serial.println(F("Scanning..."));
  44. nDevices = 0;
  45. for (address = 1; address < 127; address++) {
  46. // The i2c_scanner uses the return value of
  47. // the Write.endTransmisstion to see if
  48. // a device did acknowledge to the address.
  49. Wire.beginTransmission(address);
  50. error = Wire.endTransmission();
  51. if (error == 0) {
  52. Serial.print(F("Device found at address 0x"));
  53. if (address < 16) {
  54. Serial.print("0");
  55. }
  56. Serial.print(address,HEX);
  57. Serial.print(" (");
  58. printKnownChips(address);
  59. Serial.println(")");
  60. nDevices++;
  61. } else if (error==4) {
  62. Serial.print(F("Unknown error at address 0x"));
  63. if (address < 16) {
  64. Serial.print("0");
  65. }
  66. Serial.println(address,HEX);
  67. }
  68. }
  69. if (nDevices == 0) {
  70. Serial.println(F("No I2C devices found\n"));
  71. } else {
  72. Serial.println(F("done\n"));
  73. }
  74. delay(5000); // wait 5 seconds for next scan
  75. }
  76. void printKnownChips(byte address)
  77. {
  78. // Is this list missing part numbers for chips you use?
  79. // Please suggest additions here:
  80. // https://github.com/PaulStoffregen/Wire/issues/new
  81. switch (address) {
  82. case 0x00: Serial.print(F("AS3935")); break;
  83. case 0x01: Serial.print(F("AS3935")); break;
  84. case 0x02: Serial.print(F("AS3935")); break;
  85. case 0x03: Serial.print(F("AS3935")); break;
  86. case 0x0A: Serial.print(F("SGTL5000")); break; // MCLK required
  87. case 0x0B: Serial.print(F("SMBusBattery?")); break;
  88. case 0x0C: Serial.print(F("AK8963")); break;
  89. case 0x10: Serial.print(F("CS4272")); break;
  90. case 0x11: Serial.print(F("Si4713")); break;
  91. case 0x13: Serial.print(F("VCNL4000,AK4558")); break;
  92. case 0x18: Serial.print(F("LIS331DLH")); break;
  93. case 0x19: Serial.print(F("LSM303,LIS331DLH")); break;
  94. case 0x1A: Serial.print(F("WM8731")); break;
  95. case 0x1C: Serial.print(F("LIS3MDL")); break;
  96. case 0x1D: Serial.print(F("LSM303D,LSM9DS0,ADXL345,MMA7455L,LSM9DS1,LIS3DSH")); break;
  97. case 0x1E: Serial.print(F("LSM303D,HMC5883L,FXOS8700,LIS3DSH")); break;
  98. case 0x20: Serial.print(F("MCP23017,MCP23008,PCF8574,FXAS21002,SoilMoisture")); break;
  99. case 0x21: Serial.print(F("MCP23017,MCP23008,PCF8574")); break;
  100. case 0x22: Serial.print(F("MCP23017,MCP23008,PCF8574")); break;
  101. case 0x23: Serial.print(F("MCP23017,MCP23008,PCF8574")); break;
  102. case 0x24: Serial.print(F("MCP23017,MCP23008,PCF8574")); break;
  103. case 0x25: Serial.print(F("MCP23017,MCP23008,PCF8574")); break;
  104. case 0x26: Serial.print(F("MCP23017,MCP23008,PCF8574")); break;
  105. case 0x27: Serial.print(F("MCP23017,MCP23008,PCF8574,LCD16x2,DigoleDisplay")); break;
  106. case 0x28: Serial.print(F("BNO055,EM7180,CAP1188")); break;
  107. case 0x29: Serial.print(F("TSL2561,VL6180,TSL2561,TSL2591,BNO055,CAP1188")); break;
  108. case 0x2A: Serial.print(F("SGTL5000,CAP1188")); break;
  109. case 0x2B: Serial.print(F("CAP1188")); break;
  110. case 0x2C: Serial.print(F("MCP44XX ePot")); break;
  111. case 0x2D: Serial.print(F("MCP44XX ePot")); break;
  112. case 0x2E: Serial.print(F("MCP44XX ePot")); break;
  113. case 0x2F: Serial.print(F("MCP44XX ePot")); break;
  114. case 0x30: Serial.print(F("Si7210")); break;
  115. case 0x31: Serial.print(F("Si7210")); break;
  116. case 0x32: Serial.print(F("Si7210")); break;
  117. case 0x33: Serial.print(F("MAX11614,MAX11615,Si7210")); break;
  118. case 0x34: Serial.print(F("MAX11612,MAX11613")); break;
  119. case 0x35: Serial.print(F("MAX11616,MAX11617")); break;
  120. case 0x38: Serial.print(F("RA8875,FT6206,MAX98390")); break;
  121. case 0x39: Serial.print(F("TSL2561, APDS9960")); break;
  122. case 0x3C: Serial.print(F("SSD1306,DigisparkOLED")); break;
  123. case 0x3D: Serial.print(F("SSD1306")); break;
  124. case 0x40: Serial.print(F("PCA9685,Si7021,MS8607")); break;
  125. case 0x41: Serial.print(F("STMPE610,PCA9685")); break;
  126. case 0x42: Serial.print(F("PCA9685")); break;
  127. case 0x43: Serial.print(F("PCA9685")); break;
  128. case 0x44: Serial.print(F("PCA9685, SHT3X")); break;
  129. case 0x45: Serial.print(F("PCA9685, SHT3X")); break;
  130. case 0x46: Serial.print(F("PCA9685")); break;
  131. case 0x47: Serial.print(F("PCA9685")); break;
  132. case 0x48: Serial.print(F("ADS1115,PN532,TMP102,LM75,PCF8591")); break;
  133. case 0x49: Serial.print(F("ADS1115,TSL2561,PCF8591")); break;
  134. case 0x4A: Serial.print(F("ADS1115,Qwiic Keypad")); break;
  135. case 0x4B: Serial.print(F("ADS1115,TMP102,BNO080,Qwiic Keypad")); break;
  136. case 0x50: Serial.print(F("EEPROM,FRAM")); break;
  137. case 0x51: Serial.print(F("EEPROM")); break;
  138. case 0x52: Serial.print(F("Nunchuk,EEPROM")); break;
  139. case 0x53: Serial.print(F("ADXL345,EEPROM")); break;
  140. case 0x54: Serial.print(F("EEPROM")); break;
  141. case 0x55: Serial.print(F("EEPROM")); break;
  142. case 0x56: Serial.print(F("EEPROM")); break;
  143. case 0x57: Serial.print(F("EEPROM")); break;
  144. case 0x58: Serial.print(F("TPA2016,MAX21100")); break;
  145. case 0x5A: Serial.print(F("MPR121")); break;
  146. case 0x60: Serial.print(F("MPL3115,MCP4725,MCP4728,TEA5767,Si5351")); break;
  147. case 0x61: Serial.print(F("MCP4725,AtlasEzoDO")); break;
  148. case 0x62: Serial.print(F("LidarLite,MCP4725,AtlasEzoORP")); break;
  149. case 0x63: Serial.print(F("MCP4725,AtlasEzoPH")); break;
  150. case 0x64: Serial.print(F("AtlasEzoEC")); break;
  151. case 0x66: Serial.print(F("AtlasEzoRTD")); break;
  152. case 0x68: Serial.print(F("DS1307,DS3231,MPU6050,MPU9050,MPU9250,ITG3200,ITG3701,LSM9DS0,L3G4200D")); break;
  153. case 0x69: Serial.print(F("MPU6050,MPU9050,MPU9250,ITG3701,L3G4200D")); break;
  154. case 0x6A: Serial.print(F("LSM9DS1")); break;
  155. case 0x6B: Serial.print(F("LSM9DS0")); break;
  156. case 0x6F: Serial.print(F("Qwiic Button")); break;
  157. case 0x70: Serial.print(F("HT16K33")); break;
  158. case 0x71: Serial.print(F("SFE7SEG,HT16K33")); break;
  159. case 0x72: Serial.print(F("HT16K33")); break;
  160. case 0x73: Serial.print(F("HT16K33")); break;
  161. case 0x76: Serial.print(F("MS5607,MS5611,MS5637,BMP280")); break;
  162. case 0x77: Serial.print(F("BMP085,BMA180,BMP280,MS5611")); break;
  163. case 0x7C: Serial.print(F("FRAM_ID")); break;
  164. default: Serial.print(F("unknown chip"));
  165. }
  166. }