emonPi LCD V3.0 Update: SSH toggle, Shutdown, Config & CPU reduction

Tags: #<Tag:0x00007f13e77f1320> #<Tag:0x00007f13e77f11e0>

(Glyn Hudson) #1

Following on from the emonPi SSH disabled by default thread, thanks a lot for everyone who contributed.

With significant contribution from @alandpearson we have now implemented an update (V3.0.1) to the emonPi LCD service. The update will make it easy to toggle SSH (enable/disable) as required on all emonPi’s. The main features of the update are:

  • Add toggle SSH features to the LCD
  • Add shutdown feature to the LCD (shutdown button still works the same)
  • Add config file for customizing the LCD service e.g. enable custom MQTT data to be displayed
  • Refactor Redis polling: reduce Pi CPU usage 30%-40%

Here is a video overview of the new update in action:

The update has been merged into master branch and is available to all emonPi users via emonPi update.

This update will be very useful for existing emonPi users to easily disable SSH if it’s not required.

Advance users can now easily customize features such as backlight timeout, default screen and display custom MQTT feed data. Here is the default LCD config file :

uselogfile = True

# LCD backlight timeout in seconds 0: always on, 300: off after 5 min
# as the emonpi could be installed in a dark place, keep the backlight on, eh ?
backlight_timeout = 0

#How often the LCD is updated when a button is not pressed
lcd_update_sec = 30 

# which page to show after startup (3 is pv/utility readings which should be useful)
default_page = 0
#Names for the power feeds displayed on the LCD
feed1_name = Power1
feed2_name = Power2
feed1_unit = W
feed2_unit = W

mqtt_user = emonpi
mqtt_passwd = emonpimqtt2016
mqtt_host =
mqtt_port = 1883
mqtt_emonpi_topic = emonhub/rx/5/values
mqtt_feed1_topic = emon/emonpi/power1
mqtt_feed2_topic = emon/emonpi/power2

redis_host = localhost
redis_port = 6379

hilink_device_ip =

To view the emonPiLCD script version see the log file:

$ cat /var/log/emonpilcd/emonpilcd.log


2018-12-12 14:34:57,532 INFO Starting emonPiLCD V3.0.1
2018-12-12 14:34:57,618 INFO I2C LCD DETECTED 0x27
2018-12-12 14:34:58,062 INFO SD card image build version: emonSD-30Oct18
2018-12-12 14:34:58,063 INFO Attaching push button interrupt...
2018-12-12 14:34:58,076 INFO Attaching shutdown button interrupt...
2018-12-12 14:34:58,084 INFO Connecting to redis server...
2018-12-12 14:34:58,088 INFO Connected to redis
2018-12-12 14:34:58,089 INFO Connecting to MQTT Server: on port: 1883 with user: emonpi
2018-12-12 14:34:58,094 INFO Connected to MQTT
2018-12-12 14:35:34,203 INFO Mode button SHORT press
2018-12-12 14:35:34,204 INFO Page: 0

Big thanks to @alandpearson for this update :+1:
Here is the original PR:

SSH password error
emonPi SSH disabled by default
emonPi LCD staying on
(Paul Reed) #2

Great to see this finally added, it’s logical to both enable + disable SSH from the interface.


(Steve) #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 "./", 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”.

(Glyn Hudson) #4

Thanks, good spot. This must have got missed out during the refactor

I had to add now = now.time() to setup the backlight timer:

Change has been committed to master (V3.0.1)

(Alandpearson) #5

Really glad to see this in the wild.
Good spot on the timeout issue on the display.

I’ll keep an eye here for any further issues that may arise.

Thanks Glyn for the cool video showing it in action.

(Henrik Østergaard) #6

HI there
Nice work
I am about to update 10 units that i use at my school for education, I could real use a 3th feature on the long button push: “Force it back to AP-mode”. would that be possible and would that be a safety issue?

It that is not possible, what can I do to force the Emonpi to AP-mode after a factory reset?.
It is very time consuming to rewrite all 10 SD cards to accomplish that feature.

Best regards

btw I made som instruction video’s (not finished yet, voice over is missing) but have a look… they could easily be translated into english if that would interest you. The video’s is a part of bachelor project (more education for my part as a teacher)

Part 1:
Part 2:

More parts are comming, adding sensors, creating logs, dashboards etc. adding IoT…