Last active
June 1, 2020 06:09
-
-
Save tmeissner/5923615 to your computer and use it in GitHub Desktop.
Bash script to read out the DS18B20 1wire temp sensor. You have to modprobe the w1-gpio and w1-therm modules before using it.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
THERM=$(cat $1) | |
CPU=$(cat /sys/class/thermal/thermal_zone0/temp) | |
DATE=$(date +%Y,%m,%d%t%H,%M,%S) | |
echo ${THERM} | tr '\n' ' ' | grep -q "YES" | |
if [ $? -eq 0 ]; then | |
BLUB=$(echo -n ${THERM} | tr '\n' ' ' | sed "s/.*\([0-9][0-9]\)\([0-9][0-9][0-9]\).*/\1.\2/"); | |
BLOB=$(echo -n ${CPU} | sed "s/.*\([0-9][0-9]\)\([0-9][0-9][0-9]\).*/\1.\2/"); | |
echo "$DATE $BLUB $BLOB"; | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment