Snipets

Odczyt temperatury z czujnika DS18B20 podłaczonego do GPIO

	
#!/bin/sh
sensor=28-0000010725a2
	
while true
do
cat /sys/bus/w1/drivers/w1_slave_driver/$sensor/w1_slave > /tmp/dump-temp
CRC=`cat /tmp/dump-temp | grep crc | awk '{ print $12 }'`
	
if echo $CRC | grep -q YES; then
echo -n `date +%Y-%m-%d`; echo -n " ";echo -n `date +%H:%M`;echo -n " "
val=`cat /tmp/dump-temp | grep t | cut -d " " -f 10 | cut -d "=" -f 2`
echo $val | awk -v temp=${val} '{ printf "%.2f\n", temp/1000}'
break
else
sleep 5;
fi
	
done
	

Format wyjściowy 2010-10-15 13:51 25.31

 

Wyłączenie „echo” dla RSa

	
stty -F /dev/ttyUSB0  raw cread -crtscts -echo cs8 2400
	
  • Facebook
  • Digg
  • RSS Feed
  • Twitter

Skomentuj

Twój adres email nie zostanie opublikowany i nie będzie rozpowszechniany. Wymagane pola są oznaczone *

*
*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Turn on pictures to see the captcha *

Switch to our mobile site