These instructions will enable lcdproc to display computer status on Debian stretch using a Digispark microcontroller board, an I2c to HD44780 interface, and a 20x4 HD44780 chracter LCD.

lcdproc support the HD44780 LCD connected via I2C but uses a pin mapping that is different from the above board. However, an updated driver exists, allowing customising the pin mapping of the I2C to HD44780 interface. To use this driver the Debian package has to be rebuild substituting the driver sources.

Preparations

Digispark

Information on installing the I2C-tiny-USB firmware can be found here: https://github.com/harbaum/I2C-Tiny-USB/tree/master/digispark

Connecting the Digispark to the I2C to HD44780 module

Below is a table of the connections needed:

Digispark pin ATtiny85 pin I2C to HD44780 pin
GND N/A GND
5V N/A VCC
P0 AREF, SDA, DI, PWM SDA
P2 D/A, SCK SDL

The Digispark pin, and the ATtiny85 pin are both printed on the silkscreen of my Digispark clone. One set on the top-, and one on the bottom side.

Debian Machine

Install the required dependencies to build the debian package:

apt install build-essential autotools-dev cme debhelper dh-systemd libg15-dev libg15daemon-client-dev libg15render-dev liblircclient-dev libncurses5-dev libusb-1.0-0-dev libxosd-dev pkg-config libftdi-dev libusb-dev i2c-tools

Download and unpack the Debian package source:

wget http://http.debian.net/debian/pool/main/l/lcdproc/lcdproc_0.5.7.orig.tar.gz
wget http://http.debian.net/debian/pool/main/l/lcdproc/lcdproc_0.5.7-7.debian.tar.xz

tar xvzf lcdproc_0.5.7.orig.tar.gz lcdproc-0.5.7/
cd lcdproc-0.5.7/
tar xvJf ../lcdproc_0.5.7-7.debian.tar.xz 
cd ..

Clone the modified I2C HD44780 driver:

git clone https://github.com/wilberforce/lcdproc

Copy the modified driver source into the Debian sources:

cd lcdproc
cp -rv docs server ../lcdproc-0.5.7/.
cd ..

Building the package

cd lcdproc-0.5.7
dpkg-buildpackage -b

Installing the package

cd ..
dpkg -i lcdproc_0.5.7-7_i386.deb

Finding the I2C LCD

First load the needed I2C kernel moduled: modprobe i2c-dev modprobe i2c-tiny-dev

Next, find the I2C device that the LCD is attached to, use i2cdetect -l to list all I2C devices in the system:

$ i2cdetect -l
i2c-1   i2c             i2c-tiny-usb at bus 001 device 004      I2C adapter
i2c-0   smbus           SMBus Via Pro adapter at 5000           SMBus adapter

The adapter we are looking for is the i2c-tiny-usb with bus number 001 and available at device node /dev/i2c-1.

The address of the LCD is also found using i2cdetect. This time called with the -y parameter followed by the bus number found above.

$ i2cdetect -y 1
    0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- 27 -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --

From the above output, the address is the default of 0x27.

Configure

Add the following lines to /etc/modules to load the needed I2C modules at boot:

i2c
i2c-tiny-usb

Edit /etc/LCDd.conf to look like below. Adjust Device, andPort` with the values learned above.

[server]
DriverPath=/usr/lib/i386-linux-gnu/lcdproc/
Driver=hd44780
NextScreenKey=Right
PrevScreenKey=Left
ReportToSyslog=yes
ReportLevel=2
ToggleRotateKey=Enter
WaitTime=3
ServerScreen=no


[menu]
DownKey=Down
EnterKey=Enter
MenuKey=Escape
UpKey=Up

[hd44780]
ConnectionType=i2c
Device=/dev/i2c-1
OutputPort=no
Port=0x27
Backlight=no
Size=20x4
DelayBus=false
DelayMult=1
Keypad=no
# edit the pin configurations for your i2c module (Note2)
i2c_line_RS=0x01
i2c_line_RW=0x02
i2c_line_EN=0x04
i2c_line_BL=0x08
i2c_line_D4=0x10
i2c_line_D5=0x20
i2c_line_D6=0x40
i2c_line_D7=0x80

My /etc/lcdproc.conf contains the following:

# LCDproc client configuration file

## general options ##
[lcdproc]
# address of the LCDd server to connect to
Server=localhost

# Port of the server to connect to
Port=13666

# set reporting level
ReportLevel=2

# report to syslog?
ReportToSyslog=false

# run in foreground [default: false; legal: true, false]
#Foreground=true

# PidFile location when running as daemon [default: /var/run/lcdproc.pid]
#PidFile=/var/run/lcdproc.pid

# slow down initial announcement of modes (in 1/100s)
#delay=2

# display name for the main menu [default: LCDproc HOST]
#DisplayName=lcdproc


## screen specific configuration options ##

[CPU]
# Show screen
Active=True
OnTime=1
OffTime=2
ShowInvisible=false


[Iface]
# Show screen
Active=True

# Show stats for Interface0
Interface0=eth0
# Interface alias name to display [default: <interface name>]
Alias0=LAN

# Show stats for Interface1
Interface1=eth1
Alias1=WAN

# Show stats for Interface2
Interface2=tun0
Alias2=VPN

# for more than 3 interfaces change MAX_INTERFACES in iface.h and rebuild

# Units to display [default: byte; legal: byte, bit, packet]
unit=byte

# add screen with transferred traffic
transfer=TRUE


[Memory]
# Show screen
Active=True


[Load]
# Show screen
Active=True
# Min Load Avg at which the backlight will be turned off [default: 0.05]
LowLoad=0.05
# Max Load Avg at which the backlight will start blinking [default: 1.3]
HighLoad=1.3


[TimeDate]
# Show screen
Active=True
# time format [default: %H:%M:%S; legal: see strftime(3)]
TimeFormat="%H:%M:%S"
# date format [default: %x; legal: see strftime(3)]
DateFormat="%x"


[About]
# Show screen
Active=false


[SMP-CPU]
# Show screen
Active=false


[OldTime]
# Show screen
Active=false
# time format [default: %H:%M:%S; legal: see strftime(3)]
TimeFormat="%H:%M:%S"
# date format [default: %x; legal: see strftime(3)]
DateFormat="%x"
# Display the title bar in two-line mode. Note that with four lines or more
# the title is always shown. [default: true; legal: true, false]
#ShowTitle=false


[BigClock]
# Show screen
Active=False


[Uptime]
# Show screen
Active=True


[Battery]
# Show screen
Active=false


[CPUGraph]
# Show screen
Active=True


[ProcSize]
# Show screen
Active=false


[Disk]
# Show screen
Active=True


[MiniClock]
# Show screen
Active=False
# time format [default: %H:%M; legal: see strftime(3)]
TimeFormat="%H:%M"


# EOF

Testing

By issuing the following command the server and the lcdproc client is started in the foreground running until you press CTRL+C. The LCD should start displaying the screens configured in /etc/lcdproc.conf.

service LCDd start
lcdproc -f

Making it survive reboots

Enable LCDd at boot:

systemctl enable LCDd

Edit /etc/rc.local and add /usr/bin/lcdproc towards the end before the line exit 0 to have the lcdproc client start at boot.

This setup is used on a ECM3610 Debian machine serving as a firewall, DHCP server, and DNS server. The following assumes that you have a working installation something like this:

  • eth0 is connected to the local (192.168.0.0/24) network.
  • eth1 is connected to the internet.
  • Shorewall is installed and configured for regular firewall duty.
  • dnsmasq is installed and configured to act as DHCP and DNS server.
  • lighttpd is installed and only exposed on the local network.

Functional description.

This setup allows requests to a list of domains to be redirected to an internal web server. Use this setup to block for instance known tracking servers on the internet.

Somewhere along investigating how to do this I read, in the ArchWiki privoxy page that blocking trackers creates a unique browser signature. I have absolutely no reason to doubt this, but there were some servers that I simply did not want to talk to.

Using dnsmasq to redirect domains.

dnsmasq.conf:

If your dnsmasq is configured to listen on an interface, reconfigure it to use addresses to make stuff prettier when assigning another IP address to the interface in a little while.

listen-address=192.168.0.1
listen-address=127.0.0.1

Use files in /etc/dnsmasq.d/ as configuration files. Uncomment or add the following:

conf-dir=/etc/dnsmasq.d/

Get a list of servers to block, http://pgl.yoyo.org/adservers/serverlist.php spits out a list formatted for dnsmasq, if you ask it to. The list uses 127.0.0.1 as target, replace it with the address of a local web server if you want to inform the user that something was blocked, 192.168.0.201 in this case.

curl -s 'http://pgl.yoyo.org/adservers/serverlist.php?hostformat=dnsmasq&showintro=0&mimetype=plaintext' | sed -r 's/127.0.0.1/192.168.0.201/' > /etc/dnsmasq.d/block2local

This could be made into a cron job to update the list from time to time.

Setting up a web server to show an information page.

I have lighttpd serving some pages to the local network, so I add another IP address to eth0, and configure lighttpd to serve this address from another directory.

interfaces:

Add this:

iface eth0 inet static
    address 192.168.0.201
    netmask 255.255.255.0

lighttpd.conf:

Add this:

$SERVER["socket"] == "192.168.0.201:80" {
   server.document-root = "/var/www/blocked"
}

Add something that serves your purpose to the server.document-root directory. Simplest is something like:

index.html

<html>
<head>
<title>Server blocked.</title>
</head>
<body>
<p>This server is blocked on this network.</p>
</body>
</html>

My Acer Aspire One D250, kept going into suspend every minute or so, whenever I was not logged in to a window manager. I run Debian testing and had my first real interaction with systemd (except for systemctl).

Turns out there are some settings in /etc/systemd/logind.conf that configures some of the power management features.

#  This file is part of systemd.
#
#  systemd is free software; you can redistribute it and/or modify it
#  under the terms of the GNU Lesser General Public License as published by
#  the Free Software Foundation; either version 2.1 of the License, or
#  (at your option) any later version.
#
# See logind.conf(5) for details

[Login]
#NAutoVTs=6
#ReserveVT=6
#KillUserProcesses=no
#KillOnlyUsers=
#KillExcludeUsers=root
#InhibitDelayMaxSec=5
HandlePowerKey=poweroff
HandleSuspendKey=ignore
HandleHibernateKey=ignore
HandleLidSwitch=ignore
#PowerKeyIgnoreInhibited=no
#SuspendKeyIgnoreInhibited=no
#HibernateKeyIgnoreInhibited=no
#LidSwitchIgnoreInhibited=yes
IdleAction=ignore
#IdleActionSec=30min
#RuntimeDirectorySize=10%
#RemoveIPC=yes

First I asked systemd to ignore everything but the power button, and as I somewhat expected this didn't do the trick. Then I set the IdleActionSec to the actual amount of second (1800), that didn't work either. In the end completely disabling idling, stopped the suspend.

IdleAction=ignore

My Acer Aspire One D250, kept going into suspend every minute or so, whenever I was not logged in to a window manager. I run Debian testing and had my first real interaction with systemd (except for systemctl).

Turns out there are some settings in /etc/systemd/logind.conf that configures some of the power management features.

#  This file is part of systemd.
#
#  systemd is free software; you can redistribute it and/or modify it
#  under the terms of the GNU Lesser General Public License as published by
#  the Free Software Foundation; either version 2.1 of the License, or
#  (at your option) any later version.
#
# See logind.conf(5) for details

[Login]
#NAutoVTs=6
#ReserveVT=6
#KillUserProcesses=no
#KillOnlyUsers=
#KillExcludeUsers=root
#InhibitDelayMaxSec=5
HandlePowerKey=poweroff
HandleSuspendKey=ignore
HandleHibernateKey=ignore
HandleLidSwitch=ignore
#PowerKeyIgnoreInhibited=no
#SuspendKeyIgnoreInhibited=no
#HibernateKeyIgnoreInhibited=no
#LidSwitchIgnoreInhibited=yes
IdleAction=ignore
#IdleActionSec=30min
#RuntimeDirectorySize=10%
#RemoveIPC=yes

First I asked systemd to ignore everything but the power button, and as I somewhat expected this didn't do the trick. Then I set the IdleActionSec to the actual amount of second (1800), that didn't work either. In the end completely disabling idling, stopped the suspend.

IdleAction=ignore

Generated on 2018-03-06 19:14:41.203804