# Initial build: connecting screen backlight and buttons

**URL:** <https://community.openenergymonitor.org/t/initial-build-connecting-screen-backlight-and-buttons/18544>\
**Category:** Hardware\
**Created:** [5 September 2021 13:46 UTC](https://community.openenergymonitor.org/t/initial-build-connecting-screen-backlight-and-buttons/18544 "2021-09-05T13:46:33Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Transparent](https://community.openenergymonitor.org/user_avatar/community.openenergymonitor.org/transparent/32/19008_2.png) [@Transparent](https://community.openenergymonitor.org/u/Transparent)\
**Post date:** [5 September 2021 13:46 UTC](https://community.openenergymonitor.org/t/initial-build-connecting-screen-backlight-and-buttons/18544/1 "2021-09-05T13:46:33Z")

</div>

I don’t yet have an Energy Monitor - The emonPi Shield has arrived and other component parts will be here shortly.  
I’ve found posts which mention the **Hardware Diagram** , but I cannot find the diagram myself. The best I’ve seen is this diagram on the Wiki

 ![image](https://community.openenergymonitor.org/uploads/default/original/3X/1/5/15ab255fe2c55b6e160d5b3933c16accf3c52a19.jpeg)  
followed by a connection diagram for the GPIO

I’m looking to install an **LCD screen** , back-light and button(s) as per the usual emonPi in order to see system messages at start-up etc. All other use will be from a remote login.

I understand that the EA Dog 128x64 LCD screen connects to the I2C pins on the GPIO.

The **button** connects to GPIO-23 (pin 16) I think. But I guess requires a pull-down resistor?

However this other diagram has two buttons connected differently

> [@Problems with GPIO push button on self build emonPi](https://community.openenergymonitor.org/t/problems-with-gpio-push-button-on-self-build-emonpi/10347/37):
>
> Just as a matter of interests, was not able to get the emonpi in South Africa,managed to get all the bits from hobbie shops and it works slight_smile A big thank you to pb66 Paul you managed to get the last part working. to others my setup

Is that because he’s modified the code?

And finally, there’s the **screen backlight**. I’m happy to simply built a constant-current driver to light it.  
But is there a “standard” way in which it should be connected such that the backlight can be turned on/off or dimmed under software command?

Many thanks

---

<div class="post-metadata">

**Author:** ![Robert.Wall](https://community.openenergymonitor.org/user_avatar/community.openenergymonitor.org/robert.wall/32/38246_2.png) [@Robert.Wall](https://community.openenergymonitor.org/u/Robert.Wall)\
**Post date:** [5 September 2021 15:37 UTC](https://community.openenergymonitor.org/t/initial-build-connecting-screen-backlight-and-buttons/18544/2 "2021-09-05T15:37:41Z")

</div>

> [@Transparent](#):
>
> I’ve found posts which mention the **Hardware Diagram** , but I cannot find the diagram myself.

Do you mean the emonPi circuit diagram and PCB layout? You needed to go nearly to the bottom of the Resources (Wiki) page where you found the other diagram, to “Open-Hardware Design Files” then if you want something readable, follow the link to Github. You need Autodesk Eagle CAD (free, but you need to register) to view the files.

There is no interconnections diagram for the emonPi, I took it up with Glyn a long time ago and he refused to provide one.

The emonPi switches (not dims) the backlight under a software controlled timer.

---

<div class="post-metadata">

**Author:** ![Transparent](https://community.openenergymonitor.org/user_avatar/community.openenergymonitor.org/transparent/32/19008_2.png) [@Transparent](https://community.openenergymonitor.org/u/Transparent)\
**Post date:** [5 September 2021 17:36 UTC](https://community.openenergymonitor.org/t/initial-build-connecting-screen-backlight-and-buttons/18544/3 "2021-09-05T17:36:58Z")

</div>

Thanks @Robert.Wall - yes it was the interconnections diagram I was looking for.  
I can stop now that I know it doesn’t exist!

There do seem to be **_two_ switches** implemented in the emonPi. They are referred to in this post, with one of them being called ‘recessed’:

> <https://github.com/openenergymonitor/emonpi/pull/75#issuecomment-444305173>
>
> Thinking on this....
> 
> To be honest, I don't believe many people will ever pres…s the recessed button, preferring to just rip the power out. Going digging for a pin and messing in a dark utility cupboard for a emonpi mounted to a wall in just the wrong position...  
> 
> So, I've made both shutdown & ssh menu options controlled from the main button. Simply press the button to the corresponding menu item is shown, then press and hold to confirm. Simples.
> 
> I've also left the shutdown handler on the recessed button, while still not able to do a countdown for the five seconds, it should work just the same - a five second press, good night emonpi !
> 
> 
> Spoiler alert - holding the main push button on any other page toggles the backlight
> 
> Spoiler alert #2 - when the recessed button is pressed, display will prompt immediately to hold for 5 secs to shutdown (so you know it's pressed).

But alas, the GPIO diagram only refers to the one button (pin 16).

The **backlight** is also a mystery to me still.  
If there is a software command/time-out to turn it on/off, then there must be a pin assigned to that function somewhere on the Pi-board itself.

This post references some changes being made to the code for the LCD backlight time-out

> [@emonPi LCD V3.0 Update: SSH toggle, Shutdown, Config & CPU reduction](https://community.openenergymonitor.org/t/emonpi-lcd-v3-0-update-ssh-toggle-shutdown-config-cpu-reduction/9459/3):
>
> I tried to use the backlight\_timeout feature (the emonpi is in my kitchen so I don’t want it on all the time) but it has clearly not been tested with non-zero values. File "./emonPiLCD.py", line 543, in main if (backlight\_timeout) and now - buttonPress\_time \> backlight\_timeout and lcd.backlight: NameError: global name 'now' is not defined Got it working by adding a global declaration of “now”.

but alas there is no comment to state where is the pin that gets toggled.

I feeling a bit daunted broaching such a mundane hardware question here. The Forum seems to be well populated by coders - which I’m not. 😮

---

<div class="post-metadata">

**Author:** ![Transparent](https://community.openenergymonitor.org/user_avatar/community.openenergymonitor.org/transparent/32/19008_2.png) [@Transparent](https://community.openenergymonitor.org/u/Transparent)\
**Post date:** [5 September 2021 18:00 UTC](https://community.openenergymonitor.org/t/initial-build-connecting-screen-backlight-and-buttons/18544/4 "2021-09-05T18:00:22Z")

</div>

Update. I’ve followed your suggestion of the link to GitHub @Robert.Wall and found references to an LCD button on the schematic.

To my (pleasant) surprise, the I²C pins for the LCD panel and the ‘LCD-button’ have been brought out to a 6-pin header on the emonPi pcb. So I can now stop looking for them on the Pi board itself!  
 ![image](https://community.openenergymonitor.org/uploads/default/original/3X/5/4/54894659c0c9b4ed122501d574a8f6b312020cd9.png)

And there in the lower-right corner of the emonPi board is the second (recessed) button I was looking for. So this is all good news.

If I keep reading, I might even surprise myself and find a reference to a backlight! 💡

---

<div class="post-metadata">

**Author:** ![Robert.Wall](https://community.openenergymonitor.org/user_avatar/community.openenergymonitor.org/robert.wall/32/38246_2.png) [@Robert.Wall](https://community.openenergymonitor.org/u/Robert.Wall)\
**Post date:** [5 September 2021 18:32 UTC](https://community.openenergymonitor.org/t/initial-build-connecting-screen-backlight-and-buttons/18544/5 "2021-09-05T18:32:47Z")

</div>

> [@Transparent](#):
>
> it was the interconnections diagram I was looking for.

The best you can do is look at the PCB circuit diagram. The pushbutton on the front panel of the emonPi goes via the 6-pin header (Pins 5 & 6, JP2 - I²C, square A5-B5). The remaining connections there are to the LCD. The LCD backlight is software controlled and part of the LCD assembly itself - there are only 4 connections, GND, 3.3 V, SDA & SCL (Pins 1 - 4 respectively).

The recessed pushbutton is on the PCB (squares D3 - E4), and is the reset for the Pi, it goes via the '328P - in on D8 and comes out again on D5 to GPIO 17.

[Written while you were posting.]

---

<div class="post-metadata">

**Author:** ![Transparent](https://community.openenergymonitor.org/user_avatar/community.openenergymonitor.org/transparent/32/19008_2.png) [@Transparent](https://community.openenergymonitor.org/u/Transparent)\
**Post date:** [5 September 2021 19:21 UTC](https://community.openenergymonitor.org/t/initial-build-connecting-screen-backlight-and-buttons/18544/6 "2021-09-05T19:21:31Z")

</div>

Thanks again @Robert.Wall - Yes, I’m happy with connecting push-button and LCD screen to JP2 header.

I’ve got the [documentation](https://www.lcd-module.com/fileadmin/eng/pdf/grafik/dogm128e.pdf) on the EA DOGM lcd screens used in the pre-built emonPi. But that makes no mention of the backlight being controlled in any way from the same I²C connections as the panel itself.

In fact the backlight LEDs are brought out on independent pins, and the EA document states:  
 ![Baclight_I-source](https://community.openenergymonitor.org/uploads/default/original/3X/a/0/a012578d44ab51a5f94c93e56d49c857768a0a90.png)

That strongly suggests that the backlight needs its own supply to drive it. Page-8 even has a wiring diagram for the multi-colour (rgb) backlight option, showing the current limiting resistors which must be added.  
 ![BacklightFeed](https://community.openenergymonitor.org/uploads/default/original/3X/7/5/75aab42757262af41d716ece2f1d5e31c15395bd.png)

I’ll order up a DOGM screen and a couple of backlights so I can have a better look at the physical layout.

---

<div class="post-metadata">

**Author:** ![Robert.Wall](https://community.openenergymonitor.org/user_avatar/community.openenergymonitor.org/robert.wall/32/38246_2.png) [@Robert.Wall](https://community.openenergymonitor.org/u/Robert.Wall)\
**Post date:** [5 September 2021 22:03 UTC](https://community.openenergymonitor.org/t/initial-build-connecting-screen-backlight-and-buttons/18544/7 "2021-09-05T22:03:04Z")

</div>

> [@Transparent](#):
>
> In fact the backlight LEDs are brought out on independent pins,

In that case, the LCD you’re looking at is not the same as the one on my emonPi. The only BOM I have is for V1.2 (we’re now on V1.6) and that gives the type as HD44780LCD-1602.

---

<div class="post-metadata">

**Author:** ![Transparent](https://community.openenergymonitor.org/user_avatar/community.openenergymonitor.org/transparent/32/19008_2.png) [@Transparent](https://community.openenergymonitor.org/u/Transparent)\
**Post date:** [5 September 2021 22:45 UTC](https://community.openenergymonitor.org/t/initial-build-connecting-screen-backlight-and-buttons/18544/8 "2021-09-05T22:45:31Z")

</div>

The 1602 screens are well known to me. I have a whole drawer of them for Arduino work. But they’re a text-only LCD with 2-lines.

I found several references here in the Forum to the EA DOG graphical screens, including [this discussion](https://openenergymonitor.org/forum-archive/node/1976.html) in the archive from 2013.

If all the system messages I need to see on start-up, and the ability to configure IP-address etc are accessible from a 1602, then I’m happy to start with one of those.

---

<div class="post-metadata">

**Author:** ![Robert.Wall](https://community.openenergymonitor.org/user_avatar/community.openenergymonitor.org/robert.wall/32/38246_2.png) [@Robert.Wall](https://community.openenergymonitor.org/u/Robert.Wall)\
**Post date:** [5 September 2021 22:50 UTC](https://community.openenergymonitor.org/t/initial-build-connecting-screen-backlight-and-buttons/18544/9 "2021-09-05T22:50:15Z")

</div>

Normally, and if you are using the SD card image, there’s no need to see any start-up messages, and you actually configure the IP address via your web browser once emonCMS has started.

If you need any more than that, surely you are looking at adding a full-size screen and keyboard?

---

<div class="post-metadata">

**Author:** ![Steve](https://community.openenergymonitor.org/letter_avatar_proxy/v4/letter/s/f19dbf/32.png) [@Steve](https://community.openenergymonitor.org/u/Steve)\
**Post date:** [6 September 2021 08:05 UTC](https://community.openenergymonitor.org/t/initial-build-connecting-screen-backlight-and-buttons/18544/10 "2021-09-06T08:05:46Z")

</div>

If you want to explore the I2C comms with the display, the details are in the code at [emonpi/lcd at master · openenergymonitor/emonpi · GitHub](https://github.com/openenergymonitor/emonpi/tree/master/lcd)

Specifically lcddriver.py which is called by emonPiLCD.py

But the best way to see system messages is to connect by ssh from a proper computer.

---

<div class="post-metadata">

**Author:** ![Transparent](https://community.openenergymonitor.org/user_avatar/community.openenergymonitor.org/transparent/32/19008_2.png) [@Transparent](https://community.openenergymonitor.org/u/Transparent)\
**Post date:** [6 September 2021 08:54 UTC](https://community.openenergymonitor.org/t/initial-build-connecting-screen-backlight-and-buttons/18544/11 "2021-09-06T08:54:42Z")

</div>

That’s what I was looking for. Thanks @Steve  
That [circuit schematic](https://github.com/openenergymonitor/emonpi/blob/master/lcd/datasheet/lcd_schematic.pdf) matches the 1602\_I²C driver boards which I already have here.  
 ![1602_I2C-pcb](https://community.openenergymonitor.org/uploads/default/original/3X/5/f/5ffab6ca743cae86f3c1e88563dc94291d6a9985.jpeg)

Yes, I’ll connect with a ‘proper computer’… I have a few here running Ubuntu. That makes them ‘proper’ doesn’t it? 😉  
But with a 1602-LCD attached I might at least see if the emonPi build is working first before I try to connect to it.

Are you specifically mentioning emonPiLCD.py because it’s not already part of the standard build on the SD card I’ve just received?

---

<div class="post-metadata">

**Author:** ![Transparent](https://community.openenergymonitor.org/user_avatar/community.openenergymonitor.org/transparent/32/19008_2.png) [@Transparent](https://community.openenergymonitor.org/u/Transparent)\
**Post date:** [6 September 2021 09:04 UTC](https://community.openenergymonitor.org/t/initial-build-connecting-screen-backlight-and-buttons/18544/12 "2021-09-06T09:04:47Z")

</div>

For the benefit of others reading this later, here’s a source for those LCD\_I²C driver boards from [World Chips on AliExpress](https://www.aliexpress.com/item/32647285582.html). £3 for 5 incl shipping.

And the 1602 LCD screen itself is [here](https://www.aliexpress.com/item/32802009463.html) at £2.40 each

These low prices obviously come with the proviso that you’ll be waiting a couple of weeks for delivery from China.

---

<div class="post-metadata">

**Author:** ![Steve](https://community.openenergymonitor.org/letter_avatar_proxy/v4/letter/s/f19dbf/32.png) [@Steve](https://community.openenergymonitor.org/u/Steve)\
**Post date:** [6 September 2021 18:51 UTC](https://community.openenergymonitor.org/t/initial-build-connecting-screen-backlight-and-buttons/18544/13 "2021-09-06T18:51:38Z")

</div>

Only mentioned emonPiLCD.py to help you find your way. Yes it’s part of the standard build, in /home/pi/emonpi/lcd.
