Using LiquidCrystal_I2C displays with Photon

I've been using these nifty 20x4 LCD displays with Arduino.

https://www.amazon.com/gp/product/B07MTFDHXZ/ref=ppx_yo_dt_b_asin_image_o02_s00?ie=UTF8&th=1

I thought it would be pretty neat to use them with my Photon since they come with an I2C comm module soldered on the back. Only pins D0 and D1 are required for control of the display, with 5V and GND of course. I thought the library in the Particle Web IDE might work (v.1.0.3), but it didn't. So, I used the Arduino version instead v.1.1.2 http://downloads.arduino.cc/libraries/github.com/marcoschwartz/LiquidCrystal_I2C-1.1.2.zip

The usage.ino file in the IDE was completely useless, and would not compile. I was surprised to not find any current information about this in the forums. If you want to use these displays, you will need to add LiquidCrystal_I2C.cpp and LiquidCrystal_I2C.h to your build directory, and include LiquidCrystal_I2C.h, and Wire.h in the main program file.
I also compiled the code below successfully to show how it works. Maybe this will help someone.

#include <Wire.h>
#include <LiquidCrystal_I2C.h>

// | made by Arduino_uno_guy 11/13/2019 |
// | Arduino Project Hub

//initialize the liquid crystal library
//the first parameter is the I2C address
//the second parameter is how many rows are on your screen
//the third parameter is how many columns are on your screen

LiquidCrystal_I2C lcd(0x27, 20, 4);

void setup() {

//initialize lcd screen
lcd.init();
// turn on the backlight
lcd.backlight();
}
void loop() {
//wait for a second
delay(1000);
// tell the screen to write on the top row
lcd.setCursor(0,0);
// tell the screen to write “hello, from” on the top row
lcd.print("Hello From");
// tell the screen to write on the bottom row
lcd.setCursor(0,1);
// tell the screen to write “Arduino_uno_guy” on the bottom row
// you can change whats in the quotes to be what you want it to be!
lcd.print("Arduino_uno_guy");
lcd.setCursor(0,2);
// tell the screen to write “hello, from” on the top row
lcd.print("Hello From");
lcd.setCursor(0,3);
// tell the screen to write “hello, from” on the top row
lcd.print("Pop Quiz");

}

2 Likes

@PopQuiz, the library you used on the Web IDE is old and not supported. The LiquidCrystal_I2C_Spark library has over 144K downloads and works as expected. It has a clock example you could test with. Give it a shot!

BTW, on the Particle platform, #include <Wire.h> is not necessary.

4 Likes

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.