Merge pull request #3 from nordic-dev-net/real-time-clock
Add setup of the RTC module, fixes to setup and start scripts
This commit is contained in:
commit
81b83f2a14
@ -97,7 +97,7 @@ pub fn get_wav_spec(default_config: &SupportedStreamConfig, user_config: &Stream
|
||||
pub fn get_date_time_string() -> String {
|
||||
let now: DateTime<Local> = Local::now();
|
||||
format!(
|
||||
"{}-{}-{}_{}:{}:{:02}",
|
||||
"{:02}-{:02}-{:02}_{:02}:{:02}:{:02}",
|
||||
now.year(), now.month(), now.day(),
|
||||
now.hour(), now.minute(), now.second(),
|
||||
)
|
||||
|
@ -27,7 +27,7 @@ echo
|
||||
echo "### Install some developer tools"
|
||||
echo
|
||||
|
||||
sudo apt-get update && sudo apt-get install -y build-essential
|
||||
sudo apt-get update && sudo apt-get install -y build-essential python3-pip
|
||||
|
||||
# Setup audio
|
||||
echo
|
||||
|
@ -1,5 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
CONFIG_FILE=$1
|
||||
CONFIG_FILE=/boot/hydrophonitor/configuration/hydrophonitor-config.txt
|
||||
|
||||
export $(grep -v '^#' $CONFIG_FILE | tr -d '[:space:]' | xargs -d '\n')
|
||||
|
@ -1,5 +1,7 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -ex
|
||||
|
||||
echo "Setting up audio recording"
|
||||
|
||||
# Install packages
|
||||
|
@ -1,9 +1,10 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -ex
|
||||
|
||||
echo "Setting up GPS recording"
|
||||
|
||||
sudo apt-get update && sudo apt-get install -y \
|
||||
gpsd gpsd-clients
|
||||
sudo apt-get update && sudo apt-get install -y gpsd gpsd-clients
|
||||
|
||||
sudo pip install -r /home/pi/hydrophonitor/gps-logger/requirements.txt
|
||||
|
||||
|
@ -1,5 +1,7 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -ex
|
||||
|
||||
echo "Setting up depth recording"
|
||||
|
||||
# Enable i2c bus on Raspberry Pi
|
||||
|
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
|
@ -1,5 +1,7 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -x
|
||||
|
||||
# Export the configuration values
|
||||
/home/pi/hydrophonitor/scripts/export-config-values.sh
|
||||
|
||||
|
@ -1,5 +1,7 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -x
|
||||
|
||||
# Export the configuration values
|
||||
/home/pi/hydrophonitor/scripts/export-config-values.sh
|
||||
|
||||
|
@ -1,5 +1,7 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -x
|
||||
|
||||
# Export the configuration values
|
||||
/home/pi/hydrophonitor/scripts/export-config-values.sh
|
||||
|
||||
|
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.
|
||||
|
||||
### 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
|
||||
|
||||
### 4. Mount SSD
|
||||
### 5. Mount SSD
|
||||
|
||||
todo
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user