The I2C protocol allows multiple devices to be attached to the same pin using only 4 wires! All you need to know is the address of your device! But wait, my device didn't come with one! That's what this instructable is all about.
We are going to use the LinkIt ONE development board to find out the address of our screen, real time clock or other device so that we can use it!
All you need is the device you want to use, 4 wires, and a LinkIt ONE board.
Step 1: Wire Your Device
This is easy because there are only 4 wires and it is standard across the protocol. First, attach the VCC wire from your device to either 5v or 3.3v. This will depend on what your device can handle. Check the product listing that you got it from, or search for a data sheet. Alternatively, you could always use 3.3v and step it up if it does not register.
Now wire the rest of the connections. GND(ground) to GND, SDA to SDA, and SCL to SCL.
That's it for this step!
Step 2: Upload the Scanner Code
First, I would like to give credit where credit is due. I did not write this code. I picked it up in a forum some time ago and according to the comments in the code it is by Arduino.cc user Krodal.
Download the file below and upload it to your board.
Step 3: Finding Your Device's Address
Now, that you have the code uploaded its time to find the device's address! Open the serial monitor and wait. The Scanner will check all the possible addresses and list any address's found.
For example if your LCD Screen had the address 0x27 then it would print:
I2C device found at address 0x27.
It is really that easy!
Step 4: Use
I hope this helped some one! This is very useful when you buy 16x2 screens with bad product descriptions and bad customer support. Without this, if you don't know the address your device is basically useless.
Once you have the address you can but it in the code specific to your device. Again, for example the 16x2 screen has a library where you must have a line that states the address and size of the screen. This is where you would insert the address!
Happy making and if you have Questions/comments don't hesitate to do so below!