Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
adam.huang
Config
Commits
0ea3ebfc
Commit
0ea3ebfc
authored
Feb 08, 2015
by
Igor Pecovnik
Browse files
soc temp daemon, pir sensor add gpio input to userspace
parent
bf19661f
Changes
2
Hide whitespace changes
Inline
Side-by-side
functions.sh
View file @
0ea3ebfc
...
...
@@ -91,6 +91,14 @@ debconf-apt-progress -- apt-get -y install rpimonitor
# add my own configuration which is not default
cd
/etc/rpimonitor
wget https://github.com/igorpecovnik/Debian-micro-home-server/blob/next/src/rpimonitor-myconfig.tgz?raw
=
true
-O
- |
tar
-xz
cd
/usr/local/bin
wget https://github.com/igorpecovnik/Debian-micro-home-server/blob/next/src/temp-pir-daemon.sh?raw
=
true
chmod
+x /usr/local/bin/temp-pir-daemon.sh
sed
-e
's/exit 0//g'
-i
/etc/rc.local
cat
>>
/etc/rc.local
<<
"
EOF
"
nohup /usr/local/bin/temp-daemon.sh &
exit 0
EOF
service rpimonitor restart
}
...
...
src/temp-pir-daemon.sh
0 → 100644
View file @
0ea3ebfc
#!/bin/bash
#
# SoC/HDD temperature daemon. Writes the current temperatures to
# /run/soc-temp and /run/hdd-temp (since we're experiencing always
# timeouts under heavy load when trying to get the temperatures
# directly from within RPi-Monitor.
Main
()
{
# SoCTempAdjustment is needed because the A20 SoC delivers uncalibrated temp values
SoCTempAdjustment
=
1447
# ensure module sunxi-dbgreg.ko is loaded
grep
-q
sunxi_dbgreg </proc/modules
||
(
modprobe sunxi-dbgreg
;
sleep
0.1
)
# open GPIO22, PIR sensor
echo
22
>
/sys/class/gpio/export
# prepare registers
echo
'f1c25000:27003f'
>
/sys/devices/virtual/misc/sunxi-dbgreg/rw/write
;
echo
'f1c25010:40000'
>
/sys/devices/virtual/misc/sunxi-dbgreg/rw/write
;
echo
'f1c25018:10fff'
>
/sys/devices/virtual/misc/sunxi-dbgreg/rw/write
;
echo
'f1c25004:10'
>
/sys/devices/virtual/misc/sunxi-dbgreg/rw/write
;
while
[
2
-ge
1
]
;
do
# let the value be written to syslog
echo
'f1c25020'
>
/sys/devices/virtual/misc/sunxi-dbgreg/rw/read
;
# wait 0.1 seconds
sleep
0.1
# read return value from syslog and transform it into degrees Celsius
HexVal
=
$(
tail
/var/log/syslog |
awk
-F
" 0x"
'/ 0x/ {print $2}'
|
tail
-n1
)
SoCTemp
=
$(
echo
$((
0
x
${
HexVal
}
-
${
SoCTempAdjustment
}
))
|
awk
'{printf ("%0.1f",$1/10); }'
)
if
[
"X
${
SoCTemp
}
"
!=
"X"
]
;
then
echo
-n
${
SoCTemp
}
>
/run/soc-temp
fi
# HDD/SSD temp
DiskTemp
=
$(
hddtemp
-n
/dev/sda
)
if
[
"X
${
DiskTemp
}
"
!=
"X"
]
;
then
echo
-n
${
DiskTemp
}
>
/run/hdd-temp
fi
# sleep 5 secs
sleep
5
done
}
# Main
Main
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment