I2C Arduino and ESP8266

I2C

This page is to Scan I2C by Arduino and ESP8266

Hardware and Software

Hardware

Arduino and any I2C Devices Connected

Software

Arduino IDE

Sanki Notes

    • Scan I2C Address

    • THIS IS OLED 0.9 and 1.3 inch I2C Address

    • CHANGING I2C ADDRESSES:

    • SOME I2C interfaces have pins (or solder pads) that can be changed to change the address. They are usually labelled A0-A1-A2 . Here's the way addresses change from a default 0x27 with if you connect address pads together.

  • (1 = Not Connected. 0 = Connected):

  • EEPROM AT24C512 :

      • I2C scanner. Scanning ...

      • Found address: 81 (0x51)

Examples

This example is ..........

I2C scanner. Scanning ... Found address: 39 (0x27) Done. Found 1 device(s).

Scan I2S on ESP8266

  • -- http://www.esp8266.com/viewtopic.php?f=19&t=771

  • -- Scan for I2C devices

  • id=0

  • sda=8

  • scl=9

  • -- initialize i2c, set pin1 as sda, set pin0 as scl

  • i2c.setup(id,sda,scl,i2c.SLOW)

  • for i=0,127 do

  • i2c.start(id)

  • resCode = i2c.address(id, i, i2c.TRANSMITTER)

  • i2c.stop(id)

  • if resCode == true then print("We have a device on address 0x" .. string.format("%02x", i) .. " (" .. i ..")") end

  • end

          1. // I2C Scanner // Written by Nick Gammon // Date: 20th April 2011 #include <Wire.h> void setup() { Serial.begin (115200); // Leonardo: wait for serial port to connect while (!Serial) { } Serial.println (); } // end of setup void loop() {Serial.println ("I2C scanner. Scanning ..."); byte count = 0; Wire.begin(); for (byte i = 8; i < 120; i++) { Wire.beginTransmission (i); if (Wire.endTransmission () == 0) { Serial.print ("Found address: "); Serial.print (i, DEC); Serial.print (" (0x"); Serial.print (i, HEX); Serial.println (")"); count++; delay (1); // maybe unneeded? } // end of good response } // end of for loop Serial.println ("Done."); Serial.print ("Found "); Serial.print (count, DEC); Serial.println (" device(s)."); delay(2000); }