Hi
I have installed Domoticz on Raspberry. I buy RTC module to my raspberry and i want to add it. But i want to this work as i describe:
1. when internet is connected time and date is sync from internet ( default)
2. When internet is down or to raspberry power OFF time and date should be read from RTC, but when internet come back raspberry shoulc again go to read from internet
Is anybody who tell me step by step how configure it and how i can test it...
Domoticz Raspberry - Add RTC Clock Topic is solved
Moderators: leecollings, remb0
-
pepijn
- Posts: 251
- Joined: Friday 12 July 2013 13:19
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: The Netherlands
- Contact:
Re: Domoticz Raspberry - Add RTC Clock
I don't think is is possible. Maybe if you unload the drivers for the RTC it will stop. But ... Why do you want this?
-
pepeEL
Re: Domoticz Raspberry - Add RTC Clock
To domoticz always have actual time also when i have not internet.
Wysłane z mojego SM-G920F przy użyciu Tapatalka
Wysłane z mojego SM-G920F przy użyciu Tapatalka
-
pepijn
- Posts: 251
- Joined: Friday 12 July 2013 13:19
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: The Netherlands
- Contact:
Re: Domoticz Raspberry - Add RTC Clock
I understand, but why do want to disable the RTC when online. You can keep the RTC running and update your time using ntp (what your pi is doing now)
-
pepeEL
Re: Domoticz Raspberry - Add RTC Clock
Ok but tell me write me step by step how configure it as you write....
Wysłane z mojego SM-G920F przy użyciu Tapatalka
Wysłane z mojego SM-G920F przy użyciu Tapatalka
- nayr
- Posts: 354
- Joined: Tuesday 11 November 2014 18:42
- Target OS: Linux
- Domoticz version: github
- Location: Denver, CO - USA
- Contact:
Re: Domoticz Raspberry - Add RTC Clock
Here is my bootscript called setup-rtc.sh, its also called once a day via Crontab to sync the External i2c RTC with the Internet Time.. requires ntpdate to be installed and works best with systemd, else you try putting it in your domoticz init scripts so you know it runs before starting domo.
create /usr/local/sbin/setup-rtc.sh
and if you use systemd create /etc/systemd/system/rtc.service
Finally:
At boot time if there is no internet it retrieves the time/date from the RTC and then continues on, if a network timeserver is reachable it simply writes the external RTC with system time so its accurate when it is needed. If the internet has gone down for an extended time it will sync the system with the external RTC daily just to keep drift minimal.
By default your system is using /dev/rtc0, and that dont have a battery backup so if you loose power its lost the clock.. with this configuration you rely on the external RTC for boot before the network has came up so logs are accurate and I know everything is starting with a good time and date. I dont need my automation systems to depend on internet connectivity for proper function. When I recover from a bad power outage domoticz is likely to load up long before the network comes fully back online, presuming it does. All sorts of messed up automations happen if they dont have accurate time. really dont need my fish tank going haywire and draining its self.
Also should mention having good time is critical with a x509/ssl setup, cert verification will fail with an erroneous date.
When network becomes avilable NTPd takes over and syncs all my domoticz slaves and ipcamera's clocks together.. but an battery backed RTC is critical for recovering and operating without network connectivity. I need high availability and for that you need a battery backed time source on a device so reliant on time to function.
create /usr/local/sbin/setup-rtc.sh
Code: Select all
#!/bin/bash
# Set Date from Internet and if fails load RTC
if [ ! -e "/dev/rtc1" ]; then
echo ds1307 0x68 > /sys/class/i2c-adapter/i2c-1/new_device
fi
/usr/sbin/ntpdate -b -s -u pool.ntp.org
if [ $? -ne 0 ];then
if [ -e "/dev/rtc1" ]; then
echo Setting system time from RTC
/sbin/hwclock --rtc /dev/rtc1 -s
exit 0
fi
else
if [ -e "/dev/rtc1" ]; then
echo Writing Internet time to RTC
/sbin/hwclock --rtc /dev/rtc1 -w
exit 0
fi
fi
exit 1Code: Select all
[Unit]
Description=external rtc service
After=local-fs.target
Before=network-pre.target
Wants=network-pre.target
[Service]
Type=simple
ExecStart=/usr/local/sbin/setup-rtc.sh
[Install]
WantedBy=multi-user.targetCode: Select all
systemctl enable rtc
service rtc start
ln -s /usr/local/sbin/setup-rtc.sh /etc/cron.daily/rtc
systemctl status rtcBy default your system is using /dev/rtc0, and that dont have a battery backup so if you loose power its lost the clock.. with this configuration you rely on the external RTC for boot before the network has came up so logs are accurate and I know everything is starting with a good time and date. I dont need my automation systems to depend on internet connectivity for proper function. When I recover from a bad power outage domoticz is likely to load up long before the network comes fully back online, presuming it does. All sorts of messed up automations happen if they dont have accurate time. really dont need my fish tank going haywire and draining its self.
Also should mention having good time is critical with a x509/ssl setup, cert verification will fail with an erroneous date.
When network becomes avilable NTPd takes over and syncs all my domoticz slaves and ipcamera's clocks together.. but an battery backed RTC is critical for recovering and operating without network connectivity. I need high availability and for that you need a battery backed time source on a device so reliant on time to function.
Debian Jessie: CuBox-i4 (Primary) w/Static Routed IP and x509 / BeagleBone with OpenSprinkler / BeagleBone Planted Aquarium / 3x Raspbery Pi2b GPIO Slaves
Elemental Theme - node-domoticz-mqtt - Home Theatre Controller - AndroidTV Simple OSD Remote - x509 TLS Auth
Elemental Theme - node-domoticz-mqtt - Home Theatre Controller - AndroidTV Simple OSD Remote - x509 TLS Auth
Who is online
Users browsing this forum: No registered users and 1 guest