Sunspot Home

more notes for a bad memory - - -

Using a Raspberry Pi Zero linked to my LAN to drive an 8x40 LED matrix

Scroll a message along the array to report greenhouse temperatures etc,

I could use an Arduino and an Ethernet board - but why bother when a Pi zero has so much spare power?

I connected 5 of these in line - they use MAX7219 driver chips - red only.

MAX7219 8x8 LED matrix

MAX7219 - Raspi

DIN(1) - MOSI (D11)
CLK(13) - SCK(D13)
LOAD(12) - SS(D10)

Take power for the display from the power source directly
I did not include 3.3 to 5 volt level shifters - it seems to work OK

Next time I would use a 4 in line strip that integrates 4 8x8 displays on one board.

And you can get them with the driver chip on the back - then build any x by y matrix.


This bash script will ping the Pi in the greenhouse that is generating the data that I want to display.
(I want to know that the displayed data is fresh)
The result goes into the PI Zero ramdisk for later use by the Blassic basic main program


# /home/graham/8x40LEDmatrix/

# -q quiet
# -c nb of pings to perform

ping -q -c2 > /dev/null

if [ $? -eq 0 ]
echo "ok" > /var/www/html/ramdisk2/pingtest.txt
echo "fail" > /var/www/html/ramdisk2/pingtest.txt

This bash script grabs the data that the greenhouse Pi stores in it's own ramdisk and puts it into the Pi Zero ramdisk


# /home/graham/8x40LEDmatrix/

wget -O /var/www/html/ramdisk2/4b0_potpounds_latest.txt
wget -O /var/www/html/ramdisk2/4b1_tmp36_pool-air_latest.txt
wget -O /var/www/html/ramdisk2/4b2_panel_latest.txt
wget -O /var/www/html/ramdisk2/4b3_pool_latest.txt
wget -O /var/www/html/ramdisk2/i2c72temp_latest.txt

The python program,, that accepts a text argument and scrolls it across the LED matrix

#!/usr/bin/env python
import max7219.led as led
import time
from max7219.font import proportional, SINCLAIR_FONT, TINY_FONT, CP437_FONT
import sys
device = led.matrix(cascaded=5)

if len(sys.argv) > 1: device.show_message(str(sys.argv[1]) + " ", font=proportional(CP437_FONT))

This Blassic basic program does the following -

* ping the greenhouse Pi

* run the bash script that gets the data from the greenhouse Pi

* build a string to send to to do the text scrolling


' /home/graham/8x40LEDmatrix/scroll_pool_data_fast.bas

LABEL StartAgain

SHELL "/home/graham/8x40LEDmatrix/"
OPEN "/var/www/html/ramdisk2/pingtest.txt" FOR INPUT AS #1 : INPUT #1,pingtest$ : CLOSE #1
IF pingtest$ = "OK" THEN GOTO PingOK
IF pingtest$ = "fail" THEN GOTO PingFAIL

PRINT "ping OK"
SHELL "/home/graham/8x40LEDmatrix/"

OPEN "/var/www/html/ramdisk2/4b0_potpounds_latest.txt" FOR INPUT AS #1 : INPUT #1,potpounds$ : CLOSE #1
OPEN "/var/www/html/ramdisk2/4b1_tmp36_pool-air_latest.txt" FOR INPUT AS #1:INPUT #1,poolair$:CLOSE #1
OPEN "/var/www/html/ramdisk2/4b2_panel_latest.txt" FOR INPUT AS #1:INPUT #1,panel$:CLOSE #1
OPEN "/var/www/html/ramdisk2/4b3_pool_latest.txt" FOR INPUT AS #1:INPUT #1,pool$:CLOSE #1
OPEN "/var/www/html/ramdisk2/i2c72temp_latest.txt" FOR INPUT AS #1:INPUT #1,i2c72temp$:CLOSE #1

PRINT "potpounds$ = ",potpounds$
PRINT "poolair$ = ",poolair$
PRINT "panel$ = ",panel$
PRINT "pool$ = ",pool$
PRINT "i2c72temp$ = ",i2c72temp$

pipath$ = "/home/graham/MAX7219examples/rm-hull/"

pool$ = STR$(ROUND(VAL(pool$),1))
message$ = " pool " + pool$

poolair$ = STR$(ROUND(VAL(poolair$),1))
message$ = message$ + "_air " + poolair$

i2c72temp$ = STR$(ROUND(VAL(i2c72temp$),1))
message$ = message$ + "_garden " + i2c72temp$

potpounds$ = STR$(ROUND(VAL(potpounds$),1))
message$ = message$ + "_honey " + potpounds$

'message$ = message$ + " * Time $(date +'%d/%m %H:%M')"
message$ = message$ + "_Time $(date +'%H:%M')"
display$ = pipath$ + " " + CHR$(34) + message$ + CHR$(34)
SHELL display$

GOTO StartAgain

message$ = "PING failed"
pipath$ = "/home/graham/MAX7219examples/rm-hull/"
Print "ping failed"
display$ = pipath$ + " " + CHR$(34) + message$ + CHR$(34)
SHELL display$

GOTO StartAgain


With thanks to rm-hull

Please email me if you want to swap notes