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.

If your DigiSpark is no longer getting programmed from the Arduino IDE, when plugging it in, you might have to re-program the Micronucleus bootloader. You can do this using the Raspberry Pi if you do not have an AVR programmer.

Preperation

Install the AVRDUDE programmer on the Raspberry Pi:

apt-get install avrdude

Copy the default AVRDUDE configuration file to your home directory.

cp /etc/avrdude.conf ~/avrdude_gpio.conf
nano ~/avrdude_gpio.conf

Add this to the end of the file to make AVRDUDE use the Raspberry Pi GPIO port as programming port.

# Raspberry PI GPIO configuration for avrdude.
# Change the lines below to the GPIO pins connected to the AVR.
programmer
  id    = "rpi";
  desc  = "Use the Linux sysfs interface to bitbang GPIO lines";
  type  = "linuxgpio";
  reset = 12;
  sck   = 24;
  mosi  = 23;
  miso  = 18;
;

Next, download the Micronucleus bootloader file called micronucleus-1.06.hex.

wget https://github.com/micronucleus/micronucleus/raw/80419704f68bf0783c5de63a6a4b9d89b45235c7/firmware/releases/micronucleus-1.06.hex

Connect the DigiSpark to the Raspberry Pi using the table below.

AVR pin name DigiSpark pin name RPI pin name RPI pin number
ICSP VCC 5V 5V 2
ICSP GND GND Ground/GND 6
ICSP RESET P5 GPIO #12 32
ICSP SCK P2 GPIO #24 18
ICSP MOSI P0 GPIO #23 16
ICSP MISO P1 GPIO #18 12

When the DigiSpark is connected run this command from your home directory to program the AVR with the bootloader.

sudo avrdude -p attiny85 -C avrdude_gpio.conf -c rpi -U flash:w:micronucleus-1.06.hex:i -U lfuse:w:0xF1:m -U hfuse:w:0x5F:m

AVRDUDE should respond something like this:

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.00s

avrdude: Device signature = 0x1e930b
avrdude: NOTE: "flash" memory has been specified, an erase cycle will be performed
         To disable this feature, specify the -D option.
avrdude: erasing chip
avrdude: reading input file "micronucleus-1.06.hex"
avrdude: writing flash (8162 bytes):

Writing | ################################################## | 100% 1.28s

avrdude: 8162 bytes of flash written
avrdude: verifying flash memory against micronucleus-1.06.hex:
avrdude: load data flash data from input file micronucleus-1.06.hex:
avrdude: input file micronucleus-1.06.hex contains 8162 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 1.09s

avrdude: verifying ...
avrdude: 8162 bytes of flash verified
avrdude: reading input file "0xF1"
avrdude: writing lfuse (1 bytes):

Writing | ################################################## | 100% 0.00s

avrdude: 1 bytes of lfuse written
avrdude: verifying lfuse memory against 0xF1:
avrdude: load data lfuse data from input file 0xF1:
avrdude: input file 0xF1 contains 1 bytes
avrdude: reading on-chip lfuse data:

Reading | ################################################## | 100% 0.00s

avrdude: verifying ...
avrdude: 1 bytes of lfuse verified
avrdude: reading input file "0x5F"
avrdude: writing hfuse (1 bytes):

Writing | ################################################## | 100% 0.01s

avrdude: 1 bytes of hfuse written
avrdude: verifying hfuse memory against 0x5F:
avrdude: load data hfuse data from input file 0x5F:
avrdude: input file 0x5F contains 1 bytes
avrdude: reading on-chip hfuse data:

Reading | ################################################## | 100% 0.00s

avrdude: verifying ...
avrdude: 1 bytes of hfuse verified

avrdude: safemode: Fuses OK (E:FE, H:5F, L:F1)

avrdude done.  Thank you.

After which the Arduino IDE should be able to program it again.

Generated on 2018-05-03 01:14:21.928455