How to Set I²C Addresses and Use an I²C Scanner for LCD1602 and LCD2004
In this tutorial, we will explore how to set I²C addresses and utilize an I²C scanner for the LCD1602 and LCD2004 displays. Understanding I²C communication is crucial for integrating these LCD modules with your Arduino projects, allowing for efficient data transmission and control. By the end of this guide, you will be able to effectively identify the I²C addresses of your LCDs and ensure they are functioning correctly.


We will be using the BMP-180 sensor as part of this project, which operates using I²C communication. The sensor provides temperature and pressure readings, which can be displayed on either the LCD1602 or LCD2004. This tutorial will include wiring instructions, code snippets, and a demonstration of the expected outcomes. For a more visual understanding, be sure to check the associated video (in video at 00:00).
Hardware Explained
The main components for this project include the BMP-180 sensor, an LCD1602 or LCD2004 display, and an Arduino board. The BMP-180 is a digital pressure sensor that communicates via the I²C protocol, requiring only two data lines: SDA (data line) and SCL (clock line). The LCD displays are also I²C compatible and can easily be controlled using the same communication protocol, allowing for a clean and efficient setup.
The BMP-180 operates with a supply voltage between 1.8V and 3.6V, which means it can be powered through a voltage regulator if you are using a higher voltage source. The LCD displays, on the other hand, typically operate at 5V, making it easy to interface with an Arduino board without any additional components.
Datasheet Details
| Manufacturer | Bosch |
|---|---|
| Part number | BMP-180 |
| Logic/IO voltage | 1.8 - 3.6 V |
| Supply voltage | 1.8 - 3.6 V |
| Output current (per channel) | 3.6 µA |
| Peak current (per channel) | 1 mA |
| PWM frequency guidance | N/A |
| Input logic thresholds | N/A |
| Voltage drop / RDS(on) / saturation | N/A |
| Thermal limits | -40 to +85 °C |
| Package | 3.6 x 3.8 mm |
| Notes / variants | Temperature and pressure sensor |
- Ensure proper voltage supply: 1.8V to 3.6V for BMP-180.
- Use pull-up resistors on SDA and SCL lines for stable I²C communication.
- Keep wires short to avoid signal degradation.
- Check for correct I²C address during scanning.
- Monitor temperature range: -40 to +85 °C for BMP-180.
Wiring Instructions

To wire the BMP-180 sensor and the LCD display to your Arduino, follow these steps:

First, connect the BMP-180's Vn pin to the 5V output on the Arduino. Next, connect the GND pin of the BMP-180 to the Arduino's ground. The SDA pin of the BMP-180 should be linked to the Arduino's A4 pin, while the SCL pin connects to A5.
For the LCD1602 or LCD2004, connect the VCC pin to the 5V on the Arduino and the GND pin to ground as well. The SDA pin of the LCD should also connect to A4 (shared with BMP-180), and the SCL pin should connect to A5.
This configuration allows both devices to communicate over the same I²C bus, ensuring a clean and efficient setup.
Code Examples & Walkthrough
To scan for I²C addresses, we will use a simple code snippet. The following excerpt initializes the I²C communication and prepares the serial monitor:
#include
void setup() {
Wire.begin();
Serial.begin(9600);
while (!Serial); // Leonardo: wait for serial monitor
Serial.println("\nI2C Scanner");
}
This code initializes the Wire library for I²C communication and sets up the serial monitor for output. It's essential for debugging and ensuring that the I²C devices are recognized.
The loop function scans for devices on the I²C bus and prints their addresses:
void loop() {
byte error, address;
int nDevices = 0;
Serial.println("Scanning...");
for(address = 1; address < 127; address++) {
Wire.beginTransmission(address);
error = Wire.endTransmission();
if (error == 0) {
Serial.print("I2C device found at address 0x");
Serial.println(address, HEX);
nDevices++;
}
}
if (nDevices == 0) Serial.println("No I2C devices found\n");
delay(5000); // wait 5 seconds for next scan
}
This loop checks each address from 1 to 127, attempting to communicate with any devices present. If a device acknowledges communication, its address is printed to the serial monitor. This is a crucial step in identifying the I²C address of your LCD or other connected devices.
Demonstration / What to Expect
When the I²C scanner is run, you should see messages in the serial monitor indicating whether any I²C devices were found. If successful, the output will display the addresses of connected devices, formatted as hexadecimal values (e.g., "I2C device found at address 0x27"). If no devices are found, you will see a corresponding message.
It is important to ensure that all connections are secure and that the correct voltage levels are supplied to avoid issues with device detection (in video at 05:30).
Things you might need
-
AmazonPurchase LCD1602-I2C from Amazonamzn.to
-
AliExpressPurchase 10pcs LCD1602-I2C from AliExpresss.click.aliexpress.com
-
AliExpressPurchase LCD1602-I2C from AliExpresss.click.aliexpress.com
Resources & references
No resources yet.
Files📁
Arduino Libraries (zip)
-
LCD1602 LCD Arduino library from Robojax
robojax-LCD1602-I2C-library-master.zip0.01 MB
Fritzing File
-
LCD2004-I2C
application/zip0.02 MB