I am attempting to determine the I2C address of an Nokia LCD screen. I have a sketch that will produce various addresses (i.e. 0x00) as strings. My problem is determining how to use these strings in the Wire.requestFrom() function. From what i can tell the only address this function will accept is one that is predefined (i.e. #define ADRS 0x00). I have attempted to obtain the address from the web but could not find one.
Run this code to scan the I2C bus for devices (thanks, Nick Gammon). If the device is correctly connected to the bus this will give you the address. Set the baud rate in serial monitor to 115200.
#include <Wire.h>
void setup() {
Serial.begin (115200);
// Leonardo: wait for serial port to connect
while (!Serial)
{
}
Serial.println ();
Serial.println ("I2C scanner. Scanning ...");
byte count = 0;
Wire.begin();
for (byte i = 1; 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() {}