Project: ArduiBeeScale with WiFi + MQTT + LCD1602 Date: 2025-11-16 Status: Complete Implementation Ready
This guide covers adding a 16x2 character LCD display with I2C backpack and a push button to your ArduiBeeScale system. The display cycles through three screens when you press the button:
- Temperature & Humidity (2 seconds)
- Weight in Kilograms (2 seconds)
- Battery Percentage (2 seconds)
- Display turns off (waits for next button press)
| Part | Cost | Notes |
|---|---|---|
| LCD1602 16x2 I2C Display | €3-5 | Blue or green backlight |
| I2C Backpack Module | Included | Converts 4-wire to I2C |
| Total | €3-5 | Standard item |
| Part | Cost | Notes |
|---|---|---|
| Push Button (momentary) | €0.50-1 | 6mm x 6mm tactile switch |
| 10kΩ resistor | €0.10 | Optional, for debounce |
| Connecting wires | €0.50 | 4-conductor bundle |
| Total | €1-2 | Most Arduino kits include these |
LCD1602 I2C Module: €3-5
Push Button + Wires: €1-2
Level shifter (if needed): €1-3
─────────────────────────
TOTAL: €5-10 ✅
Arduino UNO LCD1602 I2C Module
┌──────────────┐ ┌──────────────┐
│ │ │ (Back of LCD)│
│ 5V (pin +5V) ├─────┤ VCC (red) │
│ │ │ │
│ GND (pin GND)├─────┤ GND (black) │
│ │ │ │
│ A4 (SDA) ├─────┤ SDA (green) │
│ │ │ │
│ A5 (SCL) ├─────┤ SCL (yellow) │
│ │ │ │
└──────────────┘ └──────────────┘
| Arduino Pin | I2C Module Pin | Wire Color | Purpose |
|---|---|---|---|
| 5V | VCC | Red | Power (5V) |
| GND | GND | Black | Ground |
| A4 | SDA | Green | I2C Data |
| A5 | SCL | Yellow | I2C Clock |
IMPORTANT: I2C communicates at 3.3V logic, but the backpack's VCC can accept 5V. Arduino's A4 and A5 have internal pull-up resistors, so this is safe.
Push Button Arduino
┌─────────────┐ ┌─────────────┐
│ Pin 1 ├─────┤ Pin 2 (INT0)│
│ │ │ │
│ Pin 2 ├─────┤ GND │
└─────────────┘ └─────────────┘
Button Pin Connection:
| Button Pin | Arduino Pin | Notes |
|---|---|---|
| Pin 1 (any) | Digital Pin 2 | Input pin (uses INT0 interrupt) |
| Pin 2 (other) | GND | Ground return |
Debounce Resistor (optional but recommended):
- Connect 10kΩ resistor from Pin 2 to GND (in parallel with button connection to GND)
- Helps eliminate electrical noise
- Software debounce (50ms) is also implemented in code
Before wiring, determine your LCD's I2C address:
Most Common Addresses:
- 0x27 - Blue backlight modules (most common)
- 0x3F - Green backlight or some variants
You'll need to find your address. We provide an I2C Scanner sketch for this.
-
Wire VCC (Power):
- Red wire from Arduino 5V → LCD VCC
- Use a short wire (2-3 cm) to minimize voltage drop
-
Wire GND (Ground):
- Black wire from Arduino GND → LCD GND
- Make sure this is a solid connection
-
Wire SDA (I2C Data):
- Green wire from Arduino A4 → LCD SDA
- This is the data line for I2C communication
-
Wire SCL (I2C Clock):
- Yellow wire from Arduino A5 → LCD SCL
- This is the clock line for I2C communication
Verification: After connecting I2C wires, the LCD should light up with a white or blue backlight (with or without text visible).
-
Identify Button Pins:
- Push buttons have 4 pins (2x2 grid)
- Diagonal pins are connected internally
- You need any two pins on the same side OR opposite diagonal
-
Connect Button:
- One button pin → Arduino Pin 2
- Other button pin → Arduino GND
- Use short wires (2-3 cm)
-
Optional Debounce Resistor:
- Connect 10kΩ resistor from Pin 2 to GND (in parallel)
- Solders to back of push button module if available
- Not required (software debounce works fine)
Before uploading code:
Checklist:
□ LCD I2C VCC connected to Arduino 5V
□ LCD I2C GND connected to Arduino GND
□ LCD I2C SDA connected to Arduino A4
□ LCD I2C SCL connected to Arduino A5
□ LCD has blue/white backlight (power test)
□ Button pin 1 connected to Arduino Pin 2
□ Button pin 2 connected to Arduino GND
□ All solder joints are clean and shiny
□ No wires touching or crossed
Most LCD1602 I2C modules use 0x27 or 0x3F. The address is printed on the I2C backpack module (small chip with 8 legs).
Upload the provided I2C_SCANNER.ino sketch:
1. Open Arduino IDE
2. Open: File → New
3. Copy I2C_SCANNER.ino contents (provided separately)
4. Click Upload
5. Open Serial Monitor (9600 baud)
6. Look for: "I2C device found at address 0x27" or "0x3F"
7. Note the address
8. Update LCD_I2C_ADDRESS in config_wifi.hExpected Serial Output:
Scanning I2C bus...
I2C device found at address 0x27 (0x27)
Scanning done.
If you see 0x27, update config_wifi.h:
#define LCD_I2C_ADDRESS 0x27If you see 0x3F, update config_wifi.h:
#define LCD_I2C_ADDRESS 0x3FLook at the I2C backpack (small module attached to LCD):
- Look for a small chip labeled PCF8574 or similar
- The address is often marked as A0, A1, A2 jumpers
- Jumpers set to ground = 0x27
- Jumpers set to high = 0x3F
Take a photo and note the address before final assembly.
# In Arduino IDE:
# Copy: config_wifi_template.h → config_wifi.h
# (Or use your file explorer)Edit config_wifi.h and find the LCD section:
#define ENABLE_LCD true // Enable LCD
#define LCD_I2C_ADDRESS 0x27 // ← UPDATE THIS with your addressChange 0x27 to your found address (0x27 or 0x3F).
Default is Pin 2. If you used a different pin, update:
#define BUTTON_PIN 2 // ← Change if using different pinAvailable pins for interrupt:
- Pin 2 (INT0) - Recommended
- Pin 3 (INT1) - Alternative
Default is 2 seconds per screen. If you want different timing:
#define DISPLAY_DURATION_MS 2000 // 2000 = 2 seconds
// 1000 = 1 second
// 3000 = 3 secondsBefore uploading arduino_wifi_mqtt_lcd.ino:
- ✅ All I2C wires connected (VCC, GND, SDA, SCL)
- ✅ Button wires connected (Pin 2, GND)
- ✅ LCD I2C address found and updated in config_wifi.h
- ✅ No loose wires or cold solder joints
- ✅ Button pin selected (default Pin 2)
1. Open Arduino IDE
2. Open: arduino_wifi_mqtt_lcd.ino
3. Verify → (should compile without errors)
4. Select Board: Arduino UNO
5. Select Port: COM3 (or your port)
6. Upload
7. Wait for "Done uploading" messageTest 1: LCD Display Test
Expected on startup:
- LCD backlight turns on
- First line: "BeezScale v3.1"
- Second line: "WiFi Connecting..."
After WiFi connects:
- First line: "WiFi: Connected"
- Second line: "MQTT: Connecting..."
Test 2: Push Button Test
1. Press button once
2. LCD should turn on (if it was off)
3. Should display: "Temp: XX.XXC Hum: XX%"
4. After 2 seconds: "Weight: X.XXkg"
5. After 2 seconds: "Battery: XX%"
6. After 2 seconds: LCD turns off
7. Press button again to repeat
If nothing happens:
- Check Pin 2 connection to button
- Check button GND connection
- Check LCD_I2C_ADDRESS in config_wifi.h
- Check Serial Monitor for errors
Test 3: Data Display Verification
When displaying temperature/humidity (2 sec):
□ Temperature value appears (XX.XX°C or XX.XXC)
□ Humidity value appears (XX%)
□ Both on same line (16 characters max)
When displaying weight (2 sec):
□ Weight value appears (X.XXkg or X.XXKg)
□ Properly formatted
When displaying battery (2 sec):
□ Battery percentage appears (XX%)
□ Battery voltage appears (X.XXV)
□ Both on same line
┌────────────────┐
│Temp: 22.5C 65%│ (Example)
│Hum: │ (If second line needed)
└────────────────┘
┌────────────────┐
│Weight: 32.45kg │ (Example)
│ │
└────────────────┘
┌────────────────┐
│Battery: 75% │ (Example)
│Voltage: 5.40V │ (Example)
└────────────────┘
Symptoms: Blank LCD, no backlight
Solutions:
- Check VCC wire (5V) - use multimeter to verify 5V at LCD VCC pin
- Check GND wire - ensure solid ground connection
- Try both I2C addresses: 0x27 and 0x3F
- Upload I2C_SCANNER.ino to verify LCD is detected
- Try: Restart Arduino, re-upload code
Symptoms: Blue/white backlight visible, but no characters
Solutions:
- Wrong I2C address - run I2C_SCANNER.ino to find correct address
- Wrong pins - verify A4 (SDA) and A5 (SCL) connections
- Pull-up resistors - Arduino A4/A5 have internal pull-ups (usually fine)
- Try: Unplug and replug USB, wait 5 seconds, re-upload
Symptoms: Press button, nothing happens
Solutions:
- Check button wires - are they loose or cold-soldered?
- Check button polarity - try swapping the two wires
- Check Pin 2 - some Arduino clones use different pin for INT0
- Check Serial Monitor for button press logging
- Try: Press button firmly for 1-2 seconds
- Upload I2C test sketch, ignore errors, still test button
Symptoms: LCD shows garbled characters instead of text
Solutions:
- Wrong I2C address (0x27 vs 0x3F)
- Loose I2C wires (SDA or SCL)
- Power supply too weak - use direct USB power, not extension
- Bad LCD module - try replacing LCD
Symptoms: Serial Monitor shows WiFi/MQTT OK, LCD inactive
Solutions:
- Check ENABLE_LCD is true in config_wifi.h
- Check LCD_I2C_ADDRESS matches your LCD
- Press button - LCD might be in sleep state
- Check button Pin 2 connection
- Look for Serial Monitor errors
Symptoms: Battery always shows same percentage, no change
Solutions:
- Check battery voltage divider connections (pin A0)
- Verify your battery voltage: measure with multimeter
- Calibration values incorrect - battery should be 3.0V min, 6.0V max
- Edit
calculateBatteryPercent()function in code if needed
| Pin | Type | Purpose | Conflict Risk |
|---|---|---|---|
| A4 | Analog/I2C SDA | LCD data | Battery reading uses A0 (no conflict) |
| A5 | Analog/I2C SCL | LCD clock | Same as above |
| Pin 2 | Digital/INT0 | Button input | Used for interrupt (no soft serial conflict) |
| 5V | Power | LCD VCC | Shared with other components (OK) |
| GND | Power | LCD GND | Shared with other components (OK) |
- D0, D1 (serial, don't touch)
- D3, D4, D7, D11, D12, D13 (available)
- A1, A2, A3 (available)
┌─────────────────────────────────────┐
│ Arduino UNO Connections │
└─────────────────────────────────────┘
┌─ 5V ─────────────────────────────────────────────────────┐
│ │
│ ┌──────────────────┐ ┌──────────────────┐ │
│ │ LCD1602 I2C │ │ Push Button │ │
│ │ Module │ │ │ │
│ │ │ │ Pin1 ────────┐ │ │
│ │ VCC (5V) ────────┤ │ │ │ │
│ │ GND ─────────┐ │ │ Pin2 ─────┬──┘ │ │
│ │ SDA (A4) ┐ │ │ │ │ │ │
│ │ SCL (A5) ┤ │ │ └───────────┼──────┘ │
│ └──────────┤ │ │ │ │
│ │ │ │ ┌───────────┘ │
│ │ └───┴──────────┐ │ │
│ │ │ │ │
│ │ Arduino A4(SDA) ├─┐ │ Digital Pin 2
│ │ Arduino A5(SCL) ├─┤ │ (INT0)
│ │ Arduino GND ├─┴──┼──────────────────┤
│ │ Arduino 5V ├────┘
│ │
└─────────────┴────────────────────────────────────────────┘
Legend:
═══ = Power (5V)
─── = Ground (GND)
─•─ = I2C Data (SDA)
─⊙─ = I2C Clock (SCL)
─○─ = Digital Signal
# Test 1: Verify I2C communication
1. Upload I2C_SCANNER.ino
2. Open Serial Monitor
3. Should show: "I2C device found at address 0xXX"
4. Note the address
5. Update config_wifi.h with this addressIf you have issues, test LCD in isolation:
# Create simple test sketch:
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2); // Try 0x27 or 0x3F
void setup() {
Wire.begin();
lcd.init();
lcd.backlight();
lcd.print("LCD Test OK!");
}
void loop() {
delay(1000);
}Upload and check if "LCD Test OK!" appears.
# Simple button test:
void setup() {
Serial.begin(9600);
pinMode(2, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(2), handleButton, FALLING);
}
void handleButton() {
Serial.println("Button pressed!");
}
void loop() {
delay(100);
}Upload and open Serial Monitor. Each button press should print "Button pressed!"
- LCD text displays correctly
- Button press triggers display
- Backlight turns on/off
- No loose wires around I2C connections
- Wipe LCD with soft cloth (no liquid)
- Check solder joints on button connections
- Verify I2C address hasn't changed
- Remove batteries before storing
- Keep LCD away from moisture
- Store wires coiled gently (don't crimp I2C wires)
Q: Can I use different Arduino pins for I2C? A: No. A4 (SDA) and A5 (SCL) are hardware I2C pins on Arduino UNO. Other boards (Mega, Nano) use different pins.
Q: Can I use a different pin for the button?
A: Yes, Pin 3 (INT1) also works. Other pins don't have hardware interrupts. Update BUTTON_PIN and digitalPinToInterrupt() in code.
Q: What if I have 0x3F address instead of 0x27?
A: Just update LCD_I2C_ADDRESS in config_wifi.h to 0x3F. Everything else stays the same.
Q: Can I use 3.3V instead of 5V for LCD? A: No. The I2C backpack expects 5V. The logic levels are compatible with Arduino's 3.3V I2C input (with pull-ups).
Q: How do I turn off the button feature?
A: Set ENABLE_LCD to false in config_wifi.h. The button pins won't be initialized.
Q: Can I add another button?
A: Yes, use Pin 3 (INT1) with a separate attachInterrupt(). Define a different button function to handle it.
| Setting | File | Default | Options |
|---|---|---|---|
| LCD I2C Address | config_wifi.h | 0x27 | 0x27 or 0x3F |
| Button Pin | config_wifi.h | 2 | 2 or 3 (INT0 or INT1) |
| Display Duration | config_wifi.h | 2000ms | 1000-5000ms |
| Enable LCD | config_wifi.h | true | true/false |
- arduino_wifi_mqtt_lcd.ino - Main Arduino sketch with LCD support
- config_wifi_template.h - Configuration template (includes LCD settings)
- I2C_SCANNER.ino - I2C address detection sketch (provided separately)
- LCD_TESTING_GUIDE.md - Detailed testing procedures (if needed)
Last Updated: 2025-11-16 Version: 1.0 Status: Complete ✅