This tutorial explains how to find attached I2C devices and their addresses on Arduino.
1. Introduction
This tutorial explains how to find attached i2c devices with Arduino. It also scans the address of each i2c device attached to the Arudino.
2. Connections:
Make following four connectoins between Arduino and I2C device.
1. Analog 4 -> SDA
2. Analog 5 -> SCL
3. VCC -> VCC
4. GND -> GND
3. I2C Scanner
Download and upload the following code to your Arduino, after uploading open serial monitor and you will find the address of attached i2c devices.
You may download i2c scanner Arduino sketch from here.
// Ref- Nick Gammon http://www.gammon.com.au/forum/?id=10896 // I2C Scanner #include <Wire.h> void setup() { Serial.begin (9600); while (!Serial) // Waiting for serial connection { } Serial.println (); 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)."); } // end of setup void loop() {}
the output of this sketch will be as shown below, the i2c address is highlighted. i2c address of our attached device is 0x3F.
If you have any query please write us at support@roboindia.com
Thanks and Regards
Content Development Team
Robo India
http://roboindia.com
I get no output on the serial monitor
An advice please