This one covers wiring up an LCD I2C character display to the Arduino MKR WiFi 1010, so you can print text and sensor readings without a pile of wires. I2C lets the display talk to the board over just two signal lines instead of the eight or so you'd need for a parallel LCD, which is a nice win when you're already short on pins.
The MKR WiFi 1010 runs on 3.3V logic, so the display matters here: most I2C LCDs on the market are built for 5V and can damage the board if you use them directly.
The full tutorial, with every detail and the line-by-line code explanation, is on our site: Arduino MKR WiFi 1010 - LCD
What you need
- Arduino MKR WiFi 1010
- Micro USB Cable
- LCD I2C Display 3.3V
- LCD I2C 20x4
- Breadboard
- Jumper Wires
- DC Power Jack
- DIYables Sensor Kit (18 sensors/displays)
Wiring
The LCD I2C module has four pins. VCC goes to the board's 3.3V pin, GND goes to ground. SCL carries the I2C clock signal and SDA carries the I2C data signal, both wired to the matching I2C pins on the MKR WiFi 1010. The wiring is slightly different depending on whether you power the board over USB or through the Vin pin, so check which diagram matches your setup.
How it works
I2C is a two-wire protocol: SCL is the clock the board uses to time communication, and SDA is the line the actual data travels on. This lets the LCD and the board exchange information using just those two signal wires plus power and ground, instead of wiring up every single data line separately.
The LCD screen itself is addressed like a grid: rows and columns, both starting at 0. When you place the cursor at a given column and row, that's where the next text you send will start appearing.
Code
The sketch uses the DIYables_LCD_I2C library. You create a DIYables_LCD_I2C object representing your display, call a setup function to initialize it, then use the cursor-positioning function to pick a column and row, followed by a print-style call to display your message at that spot.
arduino-mkr-wifi-1010-lcd.ino
#include <DIYables_LCD_I2C.h> DIYables_LCD_I2C lcd(0x27, 16, 2); // Create an LCD object with I2C address 0x27, supporting 16 columns and 2 rows void setup() { lcd_i2c.init(); // Start the LCD display connected via I2C lcd_i2c.backlight(); // Enable the LCD backlight } void loop() { lcd_i2c.clear(); // Erase all text from the display lcd_i2c.setCursor(0, 0); // Position the cursor at column 0, row 0 lcd_i2c.print("Hello"); // Output the text "Hello" at the current cursor location lcd_i2c.setCursor(2, 1); // Move the cursor to column 2, row 1 lcd_i2c.print("newbiely.com"); // Display "newbiely.com" starting at the current cursor position delay(2000); // Pause for 2000 milliseconds to allow the message to be seen lcd_i2c.clear(); // Remove all content from the display lcd_i2c.setCursor(3, 0); // Set the cursor to column 3, row 0 lcd_i2c.print("DIYables"); // Print "DIYables" beginning at the current position lcd_i2c.setCursor(0, 1); // Place the cursor at column 0, row 1 lcd_i2c.print("www.diyables.io"); // Show "www.diyables.io" starting at the new cursor position delay(2000); // Wait for 2000 milliseconds before refreshing the display } Things that go wrong
If your LCD screen is blank, double check the wiring before assuming the code is at fault, there's a dedicated checklist for exactly that symptom. Also be careful with voltage: most I2C LCDs sold are 5V parts, and running one off the MKR WiFi 1010 can damage the board, so stick with a 3.3V-rated display.
Full tutorial
The complete tutorial - wiring diagram, code explanation and troubleshooting - is here: https://newbiely.com/tutorials/arduino-mkr/arduino-mkr-wifi-1010-lcd
