Add scripts for setting up RTC module
This commit is contained in:
parent
98909ff51f
commit
acb2159664
28
scripts/setup-rtc-1.sh
Normal file
28
scripts/setup-rtc-1.sh
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -x
|
||||||
|
|
||||||
|
echo "Setting up the real time clock module, part 1"
|
||||||
|
|
||||||
|
# Enable i2c rtc on bus 3, set GPIO pins sda=23 and sdl=24
|
||||||
|
sudo cat << EOF | sudo tee -a /boot/config.txt
|
||||||
|
dtoverlay=i2c-gpio,bus=3,i2c_gpio_delay_us=1,i2c_gpio_sda=23,i2c_gpio_scl=24
|
||||||
|
dtoverlay=i2c-rtc,ds3231
|
||||||
|
EOF
|
||||||
|
|
||||||
|
# Disable fake-hwclock
|
||||||
|
sudo apt-get remove fake-hwclock
|
||||||
|
sudo update-rc.d -f fake-hwclock remove
|
||||||
|
sudo systemctl disable fake-hwclock
|
||||||
|
|
||||||
|
# Load modules at boot
|
||||||
|
sudo cat << EOF | sudo tee -a /etc/modules
|
||||||
|
i2c-bcm2708
|
||||||
|
i2c-dev
|
||||||
|
rtc-ds1307
|
||||||
|
EOF
|
||||||
|
|
||||||
|
# Remove some lines from /lib/udev/hwclock-set
|
||||||
|
sudo sed -i '/^if \[ \-e \/run\/systemd\/system \] ; then$/,/^fi$/d' /lib/udev/hwclock-set
|
||||||
|
|
||||||
|
echo "Setup RTC part 1 done, reboot and run setup-rtc-2.sh"
|
35
scripts/setup-rtc-2.sh
Normal file
35
scripts/setup-rtc-2.sh
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -x
|
||||||
|
|
||||||
|
echo "Setting up the real time clock module, part 2"
|
||||||
|
|
||||||
|
echo ds1307 0x68 | sudo tee /sys/class/i2c-adapter/i2c-3/new_device
|
||||||
|
|
||||||
|
# Load RTC clock at boot
|
||||||
|
sudo sed -i "s/^exit 0$//" /etc/rc.local
|
||||||
|
sudo cat << EOF | sudo tee -a /etc/rc.local
|
||||||
|
echo ds1307 0x68 | sudo tee /sys/class/i2c-adapter/i2c-3/new_device
|
||||||
|
sudo hwclock -s
|
||||||
|
exit 0
|
||||||
|
EOF
|
||||||
|
|
||||||
|
# Set system time to Internet time
|
||||||
|
|
||||||
|
echo "Restarting systmd-timesyncd to update system time"
|
||||||
|
|
||||||
|
sudo systemctl restart systemd-timesyncd
|
||||||
|
|
||||||
|
echo "System time now:"
|
||||||
|
date
|
||||||
|
|
||||||
|
# Write system time to the RTC module
|
||||||
|
|
||||||
|
echo "Hardware clock time now:"
|
||||||
|
sudo hwclock -r
|
||||||
|
|
||||||
|
echo "Writing system time to hardware clock"
|
||||||
|
sudo hwclock -w
|
||||||
|
|
||||||
|
echo "Hardware clock time now:"
|
||||||
|
sudo hwclock -r
|
25
setup.md
25
setup.md
@ -123,11 +123,32 @@ sudo reboot
|
|||||||
|
|
||||||
This will restart the Raspberry Pi and apply the changes made in the setup. On startup, it should now start recording audio, GPS and depth data.
|
This will restart the Raspberry Pi and apply the changes made in the setup. On startup, it should now start recording audio, GPS and depth data.
|
||||||
|
|
||||||
### 3. Configuration options
|
### 3. Set up the real time clock module
|
||||||
|
|
||||||
|
There are two scripts that configure the Raspberry Pi to read its system time from the RTC module.
|
||||||
|
|
||||||
|
The first part enables the i2c interface (bus 3 with SDA at GPIO pin 23 and SCL at GPIO pin 24) and loads the needed hardware modules at boot. After that, a reboot is needed to enable the hardware interface. The second part updates the hardware clock module time and configures the Raspberry Pi to set the hardware clock time as the system time on startup.
|
||||||
|
|
||||||
|
Connect to the Raspberry Pi over ssh and navigate to the home directory:
|
||||||
|
|
||||||
|
```
|
||||||
|
ssh pi@<IP>
|
||||||
|
cd $HOME
|
||||||
|
sh hydrophonitor/scripts/setup-rtc-1.sh
|
||||||
|
sudo reboot
|
||||||
|
```
|
||||||
|
|
||||||
|
```
|
||||||
|
ssh pi@<IP>
|
||||||
|
cd $HOME
|
||||||
|
sh hydrophonitor/scripts/setup-rtc-2.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
### 4. Configuration options
|
||||||
|
|
||||||
todo
|
todo
|
||||||
|
|
||||||
### 4. Mount SSD
|
### 5. Mount SSD
|
||||||
|
|
||||||
todo
|
todo
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user