How to turn off an I2C LCD display

Good day all.

My project is a solar heating system for a swimming pool.
The coding all seems to work well on the work bench and next week I'm taking it out into the real world but I have one last niggling problem.

I have used a 20 x 4 I2C LCD display to monitor temeratures, pump cycles and a variable I have included that can be changed by way of a potentiometer.

I will probably only look at this display two or three times a day at most but I can't find a way to have the display OFF most of the time and just turn it ON when I want to read it.

Having it ON all the time uses power, reduces the LCD lifespan and, worse than that, is inelegant.

I have tried including a pushbutton on the VCC side but pressing and releasing it just results in the dispaly turning into garbage,

So here, finally, is my question.

How can I turn an LCD display OFF and ON at will diring the operation of a program or, if that is not possibe, what alternative method could I use to display the data I need?

Many thanks for any help you can give me.

Laurence

Go on. How long do you expect to live? How much energy is involved in heating a swimming pool? How long will the pool be used?

There are many everyday items with 16x2 LCD that have been running for 20 years. (in a benign environment)

In practical terms, it is wise to only turn on the backlight when you want to read the LCD. It takes significant current.
The LCD itself takes a trivial current. There is little point in turning it off. If you do, you simply re-initialise it and redraw the display. (you would need to keep track of the last data that was shown)

If your environment is not benign e.g. humid, sunlight, temperature, ... the 16x2 will deteriorate whether it is running or not. But it still might outlive a human.

David.

Laurence:
I have used a 20 x 4 I2C LCD display to monitor temperatures, pump cycles and a variable I have included that can be changed by way of a potentiometer.
...
How can I turn an LCD display OFF and ON at will during the operation of a program or, if that is not possible, what alternative method could I use to display the data I need?

My, but you have programmed a LCD but not looked at the programming manual! :astonished: Why is that? :roll_eyes:

How you turn the backlight on or off depends on how you have it wired.

I'm unsure what you mean when you say turning it on or off depends on how I have wired it. In my ignorance I thought threre was only one way so I wired VCC to 5 volts, GND to ground, SDA to SDA and SCL to SCL.

Having bought off the internet there were no instructions so I just trawled the net and Lo! it worked. Now you have told me of the noDisplay instruction I can add that.

thank you for taking the time to answer my question.

If you are using the typical PCF8574 based backpack, it includes the h/w to control the backlight.
I'd recommend that you use my hd44780 library as the hd44780_I2Cexp i/o class includes API functions to turn on/off the pixels and the backlight separately or at the same time when using one of those backpacks.

david_prentice:
In practical terms, it is wise to only turn on the backlight when you want to read the LCD. It takes significant current.
The LCD itself takes a trivial current. There is little point in turning it off. If you do, you simply re-initialise it and redraw the display. (you would need to keep track of the last data that was shown)

It can be more than just about power savings to turn off the backlight.
The backlight uses LEDs.
LEDs have typical usable lifespan that can be 20k to 50k hours depending on LED and brightness.
At 24x7 that is around 2 to 5.5 years.
If the LED is driven really bright it could even be shorter.
But note that LEDs don't maintain full brightness and then suddenly go out. They dim over time.
I have some LCD panels that I've been testing with for 7-8 years and they are noticeably dimmer than they were when new and these panels are not on anywhere close to 24x7.

The typical i2c hd44780 backpack doesn't have any current limiting resistor in its backlight control circuit, so it depends on there being one on the actual LCD panel. The resistor(s) on the panel are often set to provide a very bright backlight (often too bright for my taste) so the LED is being driven at a fairly high current, which will reduce the overall usable lifespan of the backlight vs using a larger resistor for a dimmer display.

-- bill

Bill

Thank you so much for such a detailed and helpful response.

It is my intention now to include a couple of lines of code to shut the backlight down and turn it back on by using a pushbutton as a toggle.

In your response you say that the backpack includes the h/w to control the backpack. Sorry, that is not a term I have come across so I have no idea what an h/w is or how to use it (it can be painful being a noobie ....)

The environment is not particularly benign being outside in southern Spain so I am not expecting a great lifespan from the LCD but if I can get a couple of years I shall be delighted. In practice it will only be in use for about 6 months a year but no doubt the fairly high temeratures will shorten its life whether or not it is in use.

Thank you again for rsponding.

Laurence:
In your response you say that the backpack includes the h/w to control the backpack.

to control the backlight... :slight_smile:

The backpack has backlight control circuitry to allow turning on the backlight on/off.
This is what allows the library have an API function to turn the backlight on/off.

The hd44780 API functions are all documented and there are examples that demonstrate many of the functions.
Install the hdd44780 library and look at included documentation/information for the the API functions.
You can also see more information on the github page: GitHub - duinoWitchery/hd44780: Extensible hd44780 LCD library

You may be interested in on()/off() and backlight()/noBacklight()

--- bill

Bill

At the moment I am using the LiquidCrystal_I2C library.
I will try that with the display() and noDisplay() and also the backlight() and noBacklight() and the on() and off() instructions.

If I don't get any joy then I'll try again but with your hd44780 library.

Thanks

Laurence:
At the moment I am using the LiquidCrystal_I2C library.

Keep in mind that library only works with a specific backpack design.
It is probably the most common design, but there are several different i2c backpack designs.
So if you happen to buy another one in the future, it might be one of the other designs so it may not work with that library.
hd44780 will autodetect the backpack wiring used on the backpack PCB as well as the i2c address - offering plug and play.
The hd44780 library code is bigger but it is faster, that is the price for the added capabilities.

--- bill

Laurence:
I'm unsure what you mean when you say turning it on or off depends on how I have wired it. In my ignorance I thought there was only one way so I wired VCC to 5 volts, GND to ground, SDA to SDA and SCL to SCL.

OK, so your question did refer to "I have used a 20 x 4 I2C LCD display" - I missed that. :roll_eyes:

Laurence:
Having bought off the internet there were no instructions

Of course not! And if there were, they would probably be in Chinese! :roll_eyes:

bperrybap:
The typical i2c hd44780 backpack doesn't have any current limiting resistor in its backlight control circuit, so it depends on there being one on the actual LCD panel. The resistor(s) on the panel are often set to provide a very bright backlight (often too bright for my taste) so the LED is being driven at a fairly high current, which will reduce the overall usable lifespan of the backlight vs using a larger resistor for a dimmer display.

Interesting point. I may research the 2004 panel later, but for the 1602, R8 on the panel is generally 100 Ohms - "101" and there is a single white LED. So 3 V across the LED, 2 V across the resistor would be 20 mA which is no doubt the rated maximum for the LED. This in fact, should be able to be controlled directly by an Arduino pin if you were not using a backpack - as I have posted in the past.

The more common backpack has a jumper on the end which if removed, disables the backlight. It is easy to add another 100 Ohm resistor to halve the current used which I would expect, more than double the LED lifetime. The connection can also be used to add a "baseline" illumination, perhaps 1 mA.

You could also add a HC-SR505 "people detector", shaded from the sun, to activate the display when someone approaches. Not entirely sure how long they last as I have had two failures out of two expensive PIR inside light switches in two years.

Oops! Called by the boss - leave it at that!

The I2C LCD backpack's I use have a little plastic "shunt" jumper on them that controls the backlight. If you remove the jumper the backlight turns off. It would be easy enough to hook this to a toggle switch. I don't know if they support turning the backlight off with software or not.

jwahaus:
The I2C LCD backpack's I use have a little plastic "shunt" jumper on them that controls the backlight. If you remove the jumper the backlight turns off. It would be easy enough to hook this to a toggle switch. I don't know if they support turning the backlight off with software or not.

Nearly all the i2c backpacks have the jumper. The Jumper functionality can vary between designs but the most common is that the jumper disables the backlight as off if removed and if installed it enables s/w control of the backlight.
But some designs use the jumper to force the backlight to always be on and if removed, backlight can be controlled by s/w.
So it depends on which backpack design you have.

For cool factor, you could use a RCWL-0516 Microwave Radar Sensor module (which are less than $1 off ebay) to detect motion.
If the Arduino doesn't see any "movement" signal from the 516 after a set timeout, it can turn off the backlight.
Similar to a PIR, as Paul mentioned, but uses microwaves.

--- bill

This is giving me all sorts of solutions that I hadn't dreamt of.
I love the "radar detector" suggested by Bill and I think that is the way I'll go.

I'm guessing this is connected across the two contacts visible once the shunt has been removed.

This may have to wait for the Mk II version. I'm only a few days away from departure now and I want to have a fully operational unit before I leave. Perhaps I will just fit a switch for the time being.

Also I need to experiment with the additional commands available by using Bills library.

The help and support available through the forum is such a boost to the lone nerd (i.e. me) working in his attic., What seemed to be a minor irritating problem is now a chance to experiment with more hardware and soft ware and, in the process, learn a bit more about this extraordinay subject.

Laurence:
I love the "radar detector" suggested by Bill and I think that is the way I'll go.

I'm guessing this is connected across the two contacts visible once the shunt has been removed.

The radar device just wiggles an output pin HIGH/LOW when it "sees" something moving.
You would have hook that output pin to an arduino input pin and monitor that Arduino pin to detect movement and deal with it appropriately in your s/w.

--- bill

Yes, the radar device is an excellent suggestion; it will detect the approach of a person (or large wildlife) in almost any direction at a range of several metres.

It only has a logic level output however, probably sufficient to light an indicator LED but not appropriate to control the display backlight directly.

Also, you will find it preferable to determine in software how long the backlight stays on, independent of the delay provided in the module, so you attach it to an Arduino input pin and use the LCD control library to actually switch the backlight.

Yes I can see that I will have to use the Arduino to register a change in response to movement and use that to operate a separate little timer routine to keep the backlight on for, say, 10 seconds.

I got two microwave radar detectors within 24 hours of first hearing of them at a cost of £2.75 including postage. Don't really understand how they can do that.

Loading the car this weekend and will set off early next week. Pump, solar panel, MPPT controller, 100m black irrigation pipe and countless hundreds of components and half a dozen Unos all bound for Andalucia. Add to that a generous helping of enthusiasm and ignorance and the whole project should keep me entertained for weeks.

Hasta luego.

UNOs? I really wouldn't advise buying any more of those! And incidentally, if they do not have the 16U2 chip, they are not fit to be called UNOs anyway.

They are really only for experimentation and demonstration, or when you have a "shield" that just happens to do everything you want.

Nanos are far more practical for real projects, can be used with a "solderless breadboard" or as a "daughterboard" to your own PCB. A Nano will also hide behind the LCD.

If you no longer need repeated code downloads or PC connectivity, Pro Minis and a USB adapter for the odd occasion you do need to reprogram.

Paul__B:
Nanos are far more practical for real projects, can be used with a “solderless breadboard” or as a “daughterboard” to your own PCB. A Nano will also hide behind the LCD.

If you no longer need repeated code downloads or PC connectivity, Pro Minis and a USB adapter for the odd occasion you do need to reprogram.

Once you start looking around for alternate solutions and what is potentially possible, lots of stuff can pop up.
These days I use very little AVR based stuff. I use ESP8266 modules and Raspberry Pi zero W boards.
Both are $5 or less and have gobs of 32 bit horse power and resources like RAM an flash/storage.
And can offer lots of interesting capabilities like IoT type capabilities including Web servers for configuration and displays.
The ESP8266 s/w includes an Arduino addon that also allows doing uploads/updates and serial monitor wirelessly over Wifi.
The Pi is full linux with Wifi and Bluetooth so lots of stuff possible there.

I’ve built several clocks using an ESP8266 module that syncs with NTP servers and has a web server in it for configuration.
The ESP can even figure out where you are located based on the Internet IP address to auto detect your timezone and DST rules.

A lot of it these days comes down to a preference to what you are comfortable using.

— bill

bperrybap:
These days I use very little AVR based stuff. I use ESP8266 modules and Raspberry Pi zero W boards.
Both are $5 or less and have gobs of 32 bit horse power and resources like RAM an flash/storage.
And can offer lots of interesting capabilities like IoT type capabilities including Web servers for configuration and displays.

Oh yes, I was only referring to preferable form factors to the UNO.

The moment someone mentions WiFi, my advice becomes drop the "Arduino" and use the ESP8266. The WeMOS D1 Mini is pretty much the baseline equivalent to the Nano. If more I/O is needed, perhaps another version or using alternate approaches such as I2C modules. Sometimes (but only sometimes :grinning: ) Ethernet is mentioned which is appropriate for more "mission critical" purposes and at that point the Pi Zero clearly would be the better answer.

bperrybap:
The ESP8266 s/w includes an Arduino addon that also allows doing uploads/updates and serial monitor wirelessly over Wifi.

Except for the "bare" ESP-01' so you need the ESP-01S - which arguably should be the only variant made now.

This is a bit of a plug for us, but we have some solutions for you for a display with software backlight/brightness control as well as a keypad interface and nice mounting options.

The LK204-25 I2C LCD
https://www.matrixorbital.com/matrix-orbital/intelligent-display/lk204-25

The OK204-25 I2C OLED

Our LK/OK204-25 units have a keypad interface, so you can use any matrix style keypad or even a nice storm keypad enclosure.

We also have software control over the backlight (LCD) or brightness (OLED)

ex.

7.1. Brightness On Dec: 254 66 Minutes

Turns the brightness on for a specified length of time. If an inverse display color is used this command will essentially turn on the text. Minutes 1 byte, number of minutes

We wrote a little example using an external LCD using an Arduino with I2C

LCD & Arduino Keypad with I2C

Also, we have a really nice mounting options for LCD's (available on digikey)


20x4 LCD Bezel

We have seen a customer use an External LCD the ELK204-7T and only used the front and mounted it to the wall:

http://www.lcdforums.com/forums/viewtopic.php?f=9&t=829&start=75#p26508

I hope this give you some ideas and good luck with your project!