Author Topic: LCD2S via I2C with Arduino tutorial, for UNKNOWN I2C address:  (Read 4461 times)


  • Administrator
  • Hero Member
  • *****
  • Posts: 564
    • View Profile
This tutorial was created by Matt (;u=10810). It shows the procedure for finding the I2C address of a device with an unknown I2C address. This is useful if the LCD2S module's base address has been changed to an unknown address.

The Modtronix LCD2S family of Serial LCD Displays can be configured to communicate via the I2C or SPI (mode 0) protocol. To use the I2C mode, both switches on the DIP switch must be set to the off (0) position. Please refer to the LCD2S data sheet (link: to find the possible DIP switches combination for different I2C addresses.

Note: The documented I2C addresses are different when the module is connected to an Arduino. This problem can be overcome by using I2CScanner program which will be explained below

LCD2S via I2C with Arduino tutorial, for UNKNOWN I2C address:

Step 1: Connect the LCD2S module with an Arduino. In this case the I2C bus pin on an Adruino UNO is as follow: (Refer to Adruino page for other boards' I2C pins)
===== For I2C operation =====
- LCD2S SDI to Uno SDA (A4)
- LCD2S CLK to Uno SCL (A5)
- LCD2S 5V to Uno 5V
- LCD2S 0V to Uno Gnd

Fire up the the LCD!!!

Step 2: Find what I2C address the LCD2C board is:
-Go to:
-Copy the given code and paste to a new sketch in Adruino IDE. Alternatively, the I2CScanner code can be found below:
Code: [Select]
#include <Wire.h>

void setup()

  Serial.println("\nI2C Scanner");

void loop()
  byte error, address;
  int nDevices;


  nDevices = 0;
  for(address = 1; address < 127; address++ )
    // The i2c_scanner uses the return value of
    // the Write.endTransmisstion to see if
    // a device did acknowledge to the address.
    error = Wire.endTransmission();

    if (error == 0)
      Serial.print("I2C device found at address 0x");
      if (address<16)
      Serial.println("  !");

    else if (error==4)
      Serial.print("Unknow error at address 0x");
      if (address<16)
  if (nDevices == 0)
    Serial.println("No I2C devices found\n");

  delay(5000);           // wait 5 seconds for next scan
-Upload to your Arduino
-Make sure both DIP switches are in the correct position

-Open Serial monitor and see what address the scanner returned, note this address down as you will need it later. In my case, my scan returned address 0x28

Step 3: Write your own sketch:
-Open a new sketch
-Copy and paste the following skeleton code for writing "Hello World" into your new sketch:
Code: [Select]

#include <Wire.h>

void setup()
  Wire.begin();  //Join bus as master
  Wire.beginTransmission(0x28);  //Start condition at the given I2C address or Mark the begining of a data packet, change 0x28 address to what your I2C scan returned
  Wire.write(0x80);  //Initiate Display Commands
  Wire.write(0x0c);  //Clear display and go to first line
  Wire.write("Hello World!");  //Write message
  Wire.endTransmission(false);  //End condition or Mark the end of data packet and send to LCD, and hold I2C bus connection

void loop()
-Change the "0x28" address in the skeleton with what you got from the I2CScanner in the previous step.
-Upload and enjoy.

-To begin using the LCD2S, there are two pages you need to visit and learn
1. For further LCD commands, refer to LCD2S data sheet which can be found here:
2. To enable Arduino to communicate via I2C, you need to use Wire library. For I2C commands for Arduino, visit: