LCD temperature display





The following forum message was posted by g1gsw at http://sourceforge.net/projects/owfs/forums/forum/292717/topic/4019366:

Here is the updated script which enables setting the sensor names.  They are
TEMP[1]  to TEMP[4] for a 4 line display.

#!/bin/bash

MYLCD="/var/1-Wire/29. C2A909000000"

# Get sensor values
SENSOR1=`cat /var/1-Wire/10.BC8FF5010800/temperature | sed 's/^[ \t]*//'`
SENSOR2=`cat /var/1-Wire/10.BC8FF5010800/temperature | sed 's/^[ \t]*//'`
SENSOR3=`cat /var/1-Wire/10.BC8FF5010800/temperature | sed 's/^[ \t]*//'`
SENSOR4=`cat /var/1-Wire/10.BC8FF5010800/temperature | sed 's/^[ \t]*//'`

# screen is 2x40 lines in 4 bit mode
LCD1="$MYLCD/LCD_H/screen"
# message is 1x80 line in 4 bit mode
LCD2="$MYLCD/LCD_H/message"

# Sensor values
MSG[1]="$SENSOR1"
MSG[2]="$SENSOR2"
MSG[3]="$SENSOR3"
MSG[4]="$SENSOR4"

# Sensor names can be whatever you like
TEMP[1]="Sensor1"
TEMP[2]="Sensor2"
TEMP[3]="Sensor3"
TEMP[4]="Sensor4"

# Initialise the display
printf "\x0C" > $LCD1
printf "1" > $MYLCD/LCD_H/clear
printf "1" > $MYLCD/LCD_H/home

# Print the display lines in the
# order 1 3 2 4 for 4 line by 20
# character display as it is 2x40
# in 4 bit mode
for INDEX in 1 3 2 4
do
       printf '%-20s' "$ $" > $LCD1
done


Not very good I am afraid but at least it shows it working.  I only have the
one sensor so far but intend to add more once all my parts arrive to build the
boards etc.  Glad it may be useful to someone, took me a little while to work
out how to use it as there seems to be very little info available.  What it
does is send a reset to the screen then a clear and a home cursor hidden.  It
then goes through the 4 sensors defined pads the lines to 20 characters each
using printf and prints the values to the screen.  Sensor1 could do with being
a variable once I get some more sensors.  I will post the update then.

Colin

I forgot to add the display was bought from here for people in the UK

http://cgi.ebay.co.uk/ws/eBayISAPI.dll?ViewItem&item=220359123570&ssPageName=STR
K:MEWNX:IT#ht_3520wt_770