Use I2C_LCD to Debug Your Project

Introduction: Use I2C_LCD to Debug Your Project

About: Howdy, we are application engineers in Seeed. Sharing projects with maker community is awesome. Hope you like it XD Seeed is the IoT hardware enabler providing services that empower IoT developers to swiftly …

The serial monitor is a useful debugger for arduino, it can print logs on the computer screen. so that, if you want to get running informations of you project, you need to take a computer with you anywhere. Now, you can use I2C_LCD to get running logs anywhere, it will be more convenient.

I2C_LCD(With universal Grove cable):

I2C_LCD(With conversion Grove cable):

Step 1: Install the Arduino Library for I2C_LCD.

You can download from here:

How to install the library? please refer to the "How to use?" section of WIKI page:

Step 2: Connect I2C_LCD to the I2C Port of Your Arduino Board.

We recommend you to use Seeeduino or Seeeduino Lotus.

If you use I2C_LCD with traditional Arduino boards ( The boards with female connectors, like Arduino Uno and so on ), please refer to another version of I2C_LCD (With 4 pin female jumper to Grove 4 pin conversion cable).

Step 3: To Use LCD.print() Function As Serial.print().

The following are extracted from:



Prints data to the I2C_LCD as human-readable ASCII text. This command can take many forms. Numbers are printed using an ASCII character for each digit. Floats are similarly printed as ASCII digits, defaulting to two decimal places. Bytes are sent as a single character. Characters and strings are sent as is. For example:

LCD.print(78) gives "78"

LCD.print(1.23456) gives "1.23"

LCD.print('N') gives "N"

LCD.print("Hello world.") gives "Hello world."

An optional second parameter specifies the base (format) to use; permitted values are BIN (binary, or base 2), OCT (octal, or base 8), DEC (decimal, or base 10), HEX (hexadecimal, or base 16). For floating point numbers, this parameter specifies the number of decimal places to use. For example:

LCD.print(78, BIN) gives "1001110"

LCD.print(78, OCT) gives "116"

LCD.print(78, DEC) gives "78"

LCD.print(78, HEX) gives "4E"

LCD.println(1.23456, 0) gives "1"

LCD.println(1.23456, 2) gives "1.23"

LCD.println(1.23456, 4) gives "1.2346"

You can pass flash-memory based strings to LCD.print() by wrapping them with F(). For example :

LCD.print(F(Hello World )

To send a single byte, use LCD.write().



LCD.print(val, format)


val: the value to print - any data type

format: specifies the number base (for integral data types) or number of decimal places (for floating point types)


size_t (long): print() returns the number of bytes written, though reading that number is optional


Different from Serial.print(), you need to set the position coordinates before print:


LCD.print("Hello world.") ;

Step 4: Example.


//For detials of the function useage, please refer to "I2C_LCD User Manual". //You can download the "I2C_LCD User Manual" from I2C_LCD WIKI page:

I2C_LCD LCD; uint8_t I2C_LCD_ADDRESS = 0x51; //Device address setting, default: 0x51

void setup(void) { Wire.begin(); //I2C controler init. }

void loop(void) { LCD.CleanAll(WHITE); //Erase all. delay(1000); //Delay for 1s.

//8*16 font size, auto new line, black character on white back ground. LCD.FontModeConf(Font_6x8, FM_ANL_AAA, BLACK_BAC); //Set the start coordinate. LCD.CharGotoXY(0, 0); //Print string on I2C_LCD at the start coordinate. LCD.print("Hello, World!");

//Set the start coordinate. LCD.CharGotoXY(0, 10); LCD.print(78); //gives "78" LCD.print('N'); //gives "N" LCD.print(1.23456); //gives "1.23"

//Set the start coordinate. LCD.CharGotoXY(0, 20); LCD.print(78, BIN); //gives "1001110" LCD.print(' '); //gives " " LCD.print(78, OCT); //gives "116" LCD.print(' '); //gives " " LCD.print(78, DEC); //gives "78" LCD.print(' '); //gives " " LCD.print(78, HEX); //gives "4E" LCD.print(' '); //gives " "

//Set the start coordinate. LCD.CharGotoXY(0, 30); LCD.println(1.23456, 0); //gives "1" LCD.println(1.23456, 2); //gives "1.23" LCD.println(1.23456, 4); //gives "1.2346"

LCD.print("Debug with Arduino.");

while(1); //Wait for ever. }

Enjoy yourself!

Be the First to Share


    • Make it Glow Contest

      Make it Glow Contest
    • First Time Author Contest

      First Time Author Contest
    • PCB Challenge

      PCB Challenge