pi-scripts/test

66 lines
1.7 KiB
Text
Raw Permalink Normal View History

2020-02-17 05:34:59 -06:00
#!/bin bash
2019-11-24 11:50:31 -06:00
2020-02-17 05:34:59 -06:00
#install/configure real time clock
#20190203 km4ack
#script based on directions from the following web site
#https://thepihut.com/blogs/raspberry-pi-tutorials/17209332-adding-a-real-time-clock-to-your-raspberry-pi
2019-11-24 11:50:31 -06:00
2020-02-17 05:34:59 -06:00
clear;echo;echo
2019-11-24 11:50:31 -06:00
2020-02-17 05:34:59 -06:00
IC2ACTIVE=$(ls /dev/*i2c*)
2019-11-24 11:50:31 -06:00
2020-02-17 05:34:59 -06:00
if [ $IC2ACTIVE = "/dev/i2c-1" ]
2019-11-24 11:50:31 -06:00
then
2020-02-17 05:34:59 -06:00
echo "IC2 is active"
else
clear;echo;echo
#echo "Please enable IC2 interface in the "
#echo "Raspberry Pi Configuration and try again"
sudo sed -i 's/#dtparam=i2c_arm=on/dtparam=i2c_arm=on/' /boot/config.txt
2019-11-24 11:50:31 -06:00
fi
exit 0
2020-02-17 05:34:59 -06:00
clear;echo;echo
date
echo
read -p "Is the time above correct? y/n " ANS
2019-11-24 11:50:31 -06:00
2020-02-17 05:34:59 -06:00
if [ $ANS = 'y' ] || [ $ANS = 'Y' ]; then
echo "Time OK"
2019-11-24 11:50:31 -06:00
else
2020-02-17 05:34:59 -06:00
echo; echo "Please connect to the internet"
echo "or GPS to get correct time"; echo
2019-11-24 11:50:31 -06:00
exit 0
fi
2020-02-17 05:34:59 -06:00
sudo i2cdetect -y 1
echo;echo
read -p "Do you see 68 in the info listed above? y/n " ANS1
echo
if [ $ANS1 = 'y' ] || [ $ANS1 = 'Y' ]; then
sudo modprobe rtc-ds1307
echo "ds1307 0x68" | sudo tee -a /sys/class/i2c-adapter/i2c-1/new_device
sudo hwclock -w
echo rtc-ds1307 | sudo tee -a /etc/modules
sudo sed -i 's/exit\ 0//' /etc/rc.local
echo "echo ds1307 0x68 > /sys/class/i2c-adapter/i2c-1/new_device" | sudo tee -a /etc/rc.local > /dev/null 2>&1
echo "sudo hwclock -s" | sudo tee -a /etc/rc.local > /dev/null 2>&1
echo "date" | sudo tee -a /etc/rc.local > /dev/null 2>&1
echo "exit 0" | sudo tee -a /etc/rc.local > /dev/null 2>&1
echo
echo "The real time clock has been installed & configured"
echo "It is advised you check to make sure everything"
echo "is working correctly. See the video for instructions"
echo "Enjoy! 73, de KM4ACK"
else
echo "Please check that the real time"
echo "clock is installed correctly"
echo "and try again"
2019-11-24 11:50:31 -06:00
fi
2020-02-17 05:34:59 -06:00