16X2 Liquid Crystal Display (LCD) on Photon2/P2

So I'm quite familiar with particle but a complete Newbie when it comes to using LCDs and 5V vs 3.3V dynamics. To date, I've just always choose hardware that was 3.3V so I didn't have to think about it. However, I'm wanting to use a basic 16x2 LCD similar to this:

These LCDs seem to all be 5V. I'm not constrained on I/O so figured I'd just use the traditional Particle LiquidCrystal Library and use the 6 pins on the LCD (RS, EN, D7, D6, D5, and D4) to any of the GPIO on the Photon. I also will be powering the Photon via VUSB and LCD backlight and contrast pot via 5V.

What I'm not understanding is what is the approach for the data pins and VDD on the LCD when trying to use this with a Photon 2. Since the P2 GPIO is not 5V tolerant will this work? Can I just tie the R/W pin to ground (i.e. disable LCD writing data to the Photon) so LCD will never output 5 volts over the data lines?

In my quick breadboard test, it all works perfectly fine and I can display text as desired but I am tying VDD on the LCD to 5V. Is this safe to do so on the Photon2 or P2 for long periods? Just figured I'd ask before I burn up a new Photon2. :slight_smile:

It looks like that display has an I2C interface, which is fortunate. You typically can power the display at 5V and connect the I2C bus directly, with external hardware pull-ups (4.7K or 10K) to 3V3 on each of SDA and SCL.

This works because I2C never drives a pin high. It relies on the pull-up to do it, and only ever pulls SDA or SCL low using an open-collector driver. In most cases, 5V I2C devices will consider 3.3V to be high, even though it's not a full 5V and it works.

You need to make sure the board does not contain pull-ups to its VCC on the board itself. If it does, you will need to cut the traces or remove the resistors, as that will cause the SDA and SCL to be 5V which will damage the Photon 2. You can be sure if you have a DMM by connecting 5V and GND and powering on the display. If SDA and SCL are 5V, the display has internal pull-ups.

In some cases, you actually do need 5V on SDA and SCL. If this is the case, you need a bidirectional level shifter like the PCA9306, or there's a clever circuit that uses two N-channel MOSFET transistors that does the same thing. Adafruit boards like to use the MOSFET solution for I2C level shifting.

1 Like

Thanks Rick. That worked perfectly! The boards from Amazon did in fact have the pull-up resistors on them, I identified them per your guidance, removed them and added my own tied to 3.3V on the Photon2 instead of to 5V and was able to talk to the LCD right away over I2C with really no issues.

Here is a photo of the original pull-up resisters I removed in case anyone else wants to know in future:

On a related note, I didn't see any good LCD menu libraries in the Particle Ecosystem, or maybe I just wasn't looking hard enough. I ended up downloading this to my LIB folder, it works really nice so far and easy to use. GitHub - forntoh/LcdMenu: Display navigable menu items on your LCD display 📟 with Arduino


FYI - there are versions of the 1602 LCD that work with 3.3 volts, e.g.:

These use a clone of the Hitachi chip that works with a wide range of supply voltages. I have used these with Argons in 4 bit parallel mode and they work just fine - no level conversion needed and logic levels are the full supply voltage. They are 100% software compatible with the 5 volt only versions using the Hitachi chip. The standard LCD library that has been ported to Particle from Arduino works fine too.

1 Like

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