Cool stuff for Raspberry Pi, Arduino and all electronics hobby projects

Install Witty Pi 3 software on Ubuntu

Origin Author: Carlos Aguado  (caaguado AT xcentra DOT com)

Witty Pi 3’s software is officially tested under Raspbian (Raspberry Pi OS) only. However if you would like to run it on Ubuntu (like I do), you can get the information you need here.
Raspbian (Raspberry Pi OS) and Ubuntu are different Linux distributions, but they are both based on Debian, so the difference is not that huge. With reasonable effort you can have Witty Pi 3’s software installed and run on Ubuntu. Here are the steps that need to be done:

Confirm that 1-Wire Interface is disabled:

Reference: https://www.raspberrypi-spy.co.uk/2018/02/enable-1-wire-interface-raspberry-pi/

cat /boot/firmware/config.txt|grep -in dtoverlay              ## This should show nothing.
ll /sys/bus/w1/devices/              ## This should fail with "No such file or directory".

Backup Ubuntu’s original important boot configuration files:

ll /boot/firmware/config.txt /boot/firmware/cmdline.txt
ll /home/ubuntu/__boot__firmware__config.txt_*.ori /home/ubuntu/__boot__firmware__cmdline.txt_*.ori /home/ubuntu/__boot__firmware__config.txt_*.latest /home/ubuntu/__boot__firmware__cmdline.txt_*.latest
yes|sudo cp -v /boot/firmware/config.txt /home/ubuntu/__boot__firmware__config.txt_`date +"%Y%m%d_%H%M%S"`.ori
yes|sudo cp -v /boot/firmware/cmdline.txt /home/ubuntu/__boot__firmware__cmdline.txt_`date +"%Y%m%d_%H%M%S"`.ori
sudo chown -vR ubuntu:ubuntu /home/ubuntu/__boot__firmware__config.txt_*.ori /home/ubuntu/__boot__firmware__cmdline.txt_*.ori /home/ubuntu/__boot__firmware__config.txt_*.latest /home/ubuntu/__boot__firmware__cmdline.txt_*.latest
sudo chmod -vR 0750 /home/ubuntu/__boot__firmware__config.txt_*.ori /home/ubuntu/__boot__firmware__cmdline.txt_*.ori /home/ubuntu/__boot__firmware__config.txt_*.latest /home/ubuntu/__boot__firmware__cmdline.txt_*.latest
ll /home/ubuntu/__boot__firmware__config.txt_*.ori /home/ubuntu/__boot__firmware__cmdline.txt_*.ori /home/ubuntu/__boot__firmware__config.txt_*.latest /home/ubuntu/__boot__firmware__cmdline.txt_*.latest

Check the original contents of the two main boot configuration files:

cat /boot/firmware/config.txt
cat /boot/firmware/cmdline.txt

Manually reproduce the original Witty Pi 3’s scripted installation steps

## Manually reproduce the original Witty Pi 3's scripted installation steps
## for Raspbian into Ubuntu. This procedure is valid as of Ubuntu Server
## 20.10 on arm64:
## su as root to run the main part of the installation procedure:
sudo su
whoami && pwd
## Configure loading of the i2c-bcm2708 and i2c-dev modules at boot time:
cat /etc/modules
echo ''>>/etc/modules
echo '## Witty Pi 3 scripted installation emulation:'>>/etc/modules
echo 'i2c-bcm2708'>>/etc/modules
echo 'i2c-dev'>>/etc/modules
cat /etc/modules
cat /boot/firmware/config.txt
cat /boot/firmware/cmdline.txt
echo ''>>/boot/firmware/config.txt
echo '## Witty Pi 3 scripted installation emulation:'>>/boot/firmware/config.txt
echo 'dtparam=i2c1=on'>>/boot/firmware/config.txt
echo '##dtparam=i2c_arm=on'>>/boot/firmware/config.txt
echo 'dtoverlay=pi3-miniuart-bt'>>/boot/firmware/config.txt
echo 'core_freq=250'>>/boot/firmware/config.txt
cat /boot/firmware/config.txt
## Check whether file /etc/modprobe.d/raspi-blacklist.conf exists
## and if it blocklists spi-bcm2708 and i2c-bcm2708. If it does,
## the blocklisting is removed:
ll /etc/modprobe.d/raspi-blacklist.conf
cat /etc/modprobe.d/raspi-blacklist.conf
if [ -f /etc/modprobe.d/raspi-blacklist.conf ]; then
sed -i 's/^blacklist spi-bcm2708/#blacklist spi-bcm2708/' /etc/modprobe.d/raspi-blacklist.conf
sed -i 's/^blacklist i2c-bcm2708/#blacklist i2c-bcm2708/' /etc/modprobe.d/raspi-blacklist.conf
fi
ll /etc/modprobe.d/raspi-blacklist.conf
cat /etc/modprobe.d/raspi-blacklist.conf
## Check if package i2c-tools is already installed or otherwise install it now:
dpkg -l *i2c-tools*
apt update -y && apt install -y i2c-tools
dpkg -l *i2c-tools*
## Check whether locale en_GB.UTF-8 is installed or otherwise install it now (required by the Witty Pi 3 software):
cat /etc/locale.gen|grep -invE "^#"|grep "en_GB.UTF-8"
## If not installed, run dpkg-reconfigure locales and add it:
dpkg-reconfigure locales

Install wiringPi

## Confirm Raspberry Pi version and, if not installed, install the wiringpi package, which contains the the gpio command:
## http://wiringpi.com/download-and-install/
cat /proc/device-tree/model
dpkg -l *wiringpi*
apt update
apt-cache show *wiringpi*
## Install the arm64 wiringpi package version including command gpio v2.50 or higher:
apt update -y && apt install -y wiringpi
dpkg -l *wiringpi*
## Check the gpio command and its version:
which gpio
gpio -v

Install Witty Pi 3

## Check the existance of WittyPi3 required directories:
ll /usr/local/bin/wittypi /etc/init.d/wittypi ## Both should complain "No such file or directory".
## Download and unzip the latest wittyPi.zip package (v3.11 as of writting):
wget http://www.uugear.com/repo/WittyPi3/LATEST -O /home/ubuntu/WittyPi3.zip
cd /home/ubuntu
unzip ./WittyPi3.zip -d /home/ubuntu/wittypi
cd /home/ubuntu/wittypi
ll
## Fix files permissions, paths and etcetera:
chmod -v +x wittyPi.sh
chmod -v +x daemon.sh
chmod -v +x syncTime.sh
chmod -v +x runScript.sh
chmod -v +x afterStartup.sh
chmod -v +x beforeShutdown.sh
chmod -v +x utilities.sh
sed -e "s#/home/pi/wittypi#/usr/local/bin/wittypi#g" init.sh>/etc/init.d/wittypi
chmod -v +x /etc/init.d/wittypi
ll
ll /etc/init.d/wittypi
cat /etc/init.d/wittypi
touch wittyPi.log
touch schedule.log
ll
cd ..
chown -vR ubuntu:ubuntu wittypi
sleep 2
## Move the WittyPi3 software directory to its final location
## at /usr/local/bin/wittypi:
mv -v ./wittypi /usr/local/bin
ll /usr/local/bin/wittypi /etc/init.d/wittypi
update-rc.d wittypi defaults
echo $?
cd

Reboot and Check if Everything is OK

## Reboot now to see if the Raspberry Pi boots up properly:
date +"Rebooting system `hostname` at %Y-%m-%d %H:%M:%S %Z" && sudo reboot
## Reconnect to the Raspberry Pi and run:
sudo pwd ## Just to force password input!
sudo ps ax kcomm -o comm,user,ppid,pid,%cpu,%mem,vsz,rss,pri,psr,start_time,stat,time,cmd|grep -v grep|grep -i -e "TIME CMD" -e "/usr/local/bin/wittypi/daemon.sh"
ll /usr/local/bin/wittypi/*.log
cat /usr/local/bin/wittypi/wittyPi.log
cat /usr/local/bin/wittypi/schedule.log
## If /usr/local/bin/wittypi/daemon.sh running properly, try
## to schedule something:
ll /usr/local/bin/wittypi/schedules
cat /usr/local/bin/wittypi/schedules/README
cat "/usr/local/bin/wittypi/schedules/7:00_on_7:30_off_21:00_on_21:30_off.wpi"
## Backup Ubuntu's updated important boot configuration files:
ll /boot/firmware/config.txt /boot/firmware/cmdline.txt
ll /home/ubuntu/__boot__firmware__config.txt_*.ori /home/ubuntu/__boot__firmware__cmdline.txt_*.ori /home/ubuntu/__boot__firmware__config.txt_*.latest /home/ubuntu/__boot__firmware__cmdline.txt_*.latest
yes|sudo cp -v /boot/firmware/config.txt /home/ubuntu/__boot__firmware__config.txt_`date +"%Y%m%d_%H%M%S"`.latest
yes|sudo cp -v /boot/firmware/cmdline.txt /home/ubuntu/__boot__firmware__cmdline.txt_`date +"%Y%m%d_%H%M%S"`.latest
sudo chown -vR ubuntu:ubuntu /home/ubuntu/__boot__firmware__config.txt_*.ori /home/ubuntu/__boot__firmware__cmdline.txt_*.ori /home/ubuntu/__boot__firmware__config.txt_*.latest /home/ubuntu/__boot__firmware__cmdline.txt_*.latest
sudo chmod -vR 0750 /home/ubuntu/__boot__firmware__config.txt_*.ori /home/ubuntu/__boot__firmware__cmdline.txt_*.ori /home/ubuntu/__boot__firmware__config.txt_*.latest /home/ubuntu/__boot__firmware__cmdline.txt_*.latest
ll /home/ubuntu/__boot__firmware__config.txt_*.ori /home/ubuntu/__boot__firmware__cmdline.txt_*.ori /home/ubuntu/__boot__firmware__config.txt_*.latest /home/ubuntu/__boot__firmware__cmdline.txt_*.latest
## Done! Thanks for reading :-)

 

See also

Join Waitlist We will inform you when the product arrives in stock. Please leave your valid email address below.