Be cool Part 5 – Install the fan controller on OSMC
To
do the same fan controller install on OSMC we need to remote login
from another machine as OSMC is headless. That means it has no
desktop from which to start a terminal session. This means we need to
be extra cautious as mistakes are harder to rectify if you render it
unbootable.
You
will have to ssh or start a putty session into the PI and login as
osmc, password osmc (unless you have changed the account or
password). Using Putty.exe on windows http://www.putty.org/ or from a
Linux Machine using ssh. I am not sure what Macs use.
We
will need to copy the files from your
PC
or laptop.
Ensure
that you have enabled SSH on your OSMC install.
Boot
into
OSMC and login from another machine. We
will need to install some packages as OSMC does
not have the Python development environment or Python GPIO library
extensions to control to the fan yet.
sudo
apt-get update
sudo apt-get install python
sudo apt-get install python-dev
sudo apt-get install python
sudo apt-get install python-dev
to
install python-rpi.gpio we need to get code from a different source (updated Aug 2018)
sudo apt-get update
sudo apt-get install build-essential ### this takes quite a while!
export ARCH=arm
export CROSS_COMPILE=/usr/bin/
wget https://files.pythonhosted.org/packages/e2/58/6e1b775606da6439fa3fd1550e7f714ac62aa75e162eed29dbec684ecb3e/RPi.GPIO-0.6.3.tar.gz
tar -zxvf RPi.GPIO-0.6.3.tar.gz
sudo apt-get update
sudo apt-get install build-essential ### this takes quite a while!
export ARCH=arm
export CROSS_COMPILE=/usr/bin/
wget https://files.pythonhosted.org/packages/e2/58/6e1b775606da6439fa3fd1550e7f714ac62aa75e162eed29dbec684ecb3e/RPi.GPIO-0.6.3.tar.gz
tar -zxvf RPi.GPIO-0.6.3.tar.gz
cd RPi.GPIO-0.6.3
sudo python setup.py install
if build-essential seems to freeze, try scrolling the terminal window down!
Let's
make the folders
cd
~
mkdir
scripts
mkdir
logs
Now
test the python script -
cd
scripts
cd
~
press
'ctrl + c' followed by 'enter' to stop the script
If
the fan runs/LED lights for 5 or more seconds then you can make the
launcher executable
cd
~
cd
scripts
sudo chmod +x launcher.sh
sh launcher.sh
sudo chmod +x launcher.sh
sh launcher.sh
test
the launcher with
sudo
sh launcher.sh
press
'ctrl +c' then 'return' to exit
If
that also works we can set up the cron script to make it run at boot
cd
~
sudo
apt-get install cron
mkdir
logs
sudo apt-get install cron
sudo crontab -e
sudo apt-get install cron
sudo crontab -e
Add
the following line to the end of the script (assuming your username
is osmc)
@reboot sh /home/osmc/scripts/launcher.sh >/home/osmc/logs/cronlog 2>&1
sudo reboot
Your
fan or LED should come on for 5 seconds at boot and work accordingly.
Of
course to change the temperature settings you will have to ssh or
putty in and edit the code, but after all that it should be a doddle!