Arduino Nano 33 IoT - LCD 20x4

This guide shows you how to hook up a 20x4 LCD screen (a type of liquid display) to the Arduino Nano 33 IoT board using the I2C connection.

Arduino Nano 33 IoT LCD 20x4 I2C

Hardware Preparation

1×Arduino Nano 33 IoT
1×Micro USB Cable
1×LCD 20x4
1×Jumper Wires
1×Optionally, DC Power Jack
1×Recommended: Screw Terminal Expansion Board for Arduino Nano
1×Recommended: Breakout Expansion Board for Arduino Nano
1×Recommended: Power Splitter for Arduino Nano

Or you can buy the following sensor kits:

1×DIYables Sensor Kit (30 sensors/displays)
1×DIYables Sensor Kit (18 sensors/displays)
Disclosure: Some of the links provided in this section are Amazon affiliate links. We may receive a commission for any purchases made through these links at no additional cost to you.
Additionally, some of these links are for products from our own brand, DIYables .

Overview of LCD I2C 20x4

Pinout

The 20x4 LCD with I2C works with an I2C connection, so it has four pins:

  • GND pin: Connect this to ground (0 volts).
  • VCC pin: Connect this to the power supply (5 volts).
  • SDA pin: This is the data line for I2C.
  • SCL pin: This is the clock line for I2C.
LCD 20x4 I2C Pinout

LCD Coordinate

LCD I2C 20x4 has 20 columns and 4 rows. The columns and rows start counting from 0.

Arduino Nano 33 IoT LCD I2C Coordinate

Wiring Diagram

  • When giving power to the Arduino Nano 33 IoT board through the USB port.
The wiring diagram between Arduino Nano and 33 IoT LCD 20x4 I2C

This image is created using Fritzing. Click to enlarge image

  • When powering the Arduino Nano 33 IoT board through the Vin pin.
The wiring diagram between Arduino Nano and 33 IoT LCD 20x4 I2C external power source

This image is created using Fritzing. Click to enlarge image

※ NOTE THAT:

If you power the Arduino Nano 33 IoT using the USB port, you can also use the VBUS pin to run the LCD display without needing another power source. However, be aware that the VBUS pin might not give enough power for the LCD display to work correctly.

LCD I2C Arduino Nano 33 IoT
VCC 5V
GND GND
SDA A4
SCL A5

How To Program For LCD I2C

Thanks to the LiquidCrystal_I2C library, using the LCD is very easy.

  • Add the library:
#include <LiquidCrystal_I2C.h> // Include LiquidCrystal_I2C library for controlling I2C-enabled LCD displays
  • Create a LiquidCrystal_I2C object by providing its I2C address, the number of columns, and the number of rows.
LiquidCrystal_I2C lcd(0x27, 20, 4); // I2C device at address 0x27, configured for a 20-column by 4-row display
  • Set up the LCD.
lcd.init(); // Initialize the LCD display module lcd.backlight(); // Enable the LCD backlight illumination
  • Move the cursor to the spot you want (column number, row number)
lcd.setCursor(column_index, row_index);
  • Display a message on the LCD screen.
lcd.print("Hello World!");

※ NOTE THAT:

The LCD's I2C address might be different depending on who made it. In our code, we used 0x27, which is recommended by the DIYables manufacturer.

Arduino Nano 33 IoT Code

/* * This Arduino Nano 33 IoT code was developed by newbiely.com * * This Arduino Nano 33 IoT code is made available for public use without any restriction * * For comprehensive instructions and wiring diagrams, please visit: * https://newbiely.com/tutorials/arduino-nano-iot/arduino-nano-33-iot-lcd-20x4 */ #include <LiquidCrystal_I2C.h> LiquidCrystal_I2C lcd(0x27, 20, 4); // Set up an LCD with I2C address 0x27 and a display size of 20 columns by 4 rows void setup() { lcd.init(); // Start the initialization sequence for the LCD display lcd.backlight(); // Turn on the LCD backlight lcd.setCursor(0, 0); // Position the cursor at the beginning of the first row lcd.print("LCD 20x4"); // Display the text "LCD 20x4" on the first row lcd.setCursor(0, 1); // Shift the cursor to the start of the second row lcd.print("I2C Address: 0x27"); // Show the text "I2C Address: 0x27" on the second row lcd.setCursor(0, 2); // Move the cursor to the beginning of the third row lcd.print("DIYables"); // Print "DIYables" on the third row lcd.setCursor(0, 3); // Place the cursor at the start of the fourth row lcd.print("www.diyables.io"); // Print "www.diyables.io" on the fourth row } void loop() { }

Detailed Instructions

If you are new to the Arduino Nano 33 IoT, be sure to check out our Getting Started with Arduino Nano 33 IoT tutorial. Then, follow these steps:

  • Connect the components to the Arduino Nano 33 IoT board as depicted in the diagram.
  • Use a USB cable to connect the Arduino Nano 33 IoT board to your computer.
  • Launch the Arduino IDE on your computer.
  • Select the Arduino Nano 33 IoT board and choose its corresponding COM port.
  • Open the Library Manager by clicking the Library Manager icon on the left side of the Arduino IDE.
  • Type LiquidCrystal I2C into the search box. Then, look for the LiquidCrystal_I2C library by Frank de Brabander.
  • Click the Install button to add the LiquidCrystal_I2C library.
Arduino Nano 33 IoT LiquidCrystal I2C library
  • Copy the code above and open it in the Arduino IDE.
  • Click the Upload button in the Arduino IDE to load the code onto the Arduino Nano 33 IoT.
  • Watch the result on the LCD screen.
  • Try changing the text and its position.

Video Tutorial

※ OUR MESSAGES

  • As freelancers, We are AVAILABLE for HIRE. See how to outsource your project to us
  • Please feel free to share the link of this tutorial. However, Please do not use our content on any other websites. We invested a lot of effort and time to create the content, please respect our work!