OpenSprinkler › Forums › Hardware Questions › OpenSprinkler Beagle (OSBo) › NOOB needs help with RTC service
- This topic has 10 replies, 5 voices, and was last updated 9 years, 2 months ago by Mike.
-
AuthorPosts
-
December 23, 2013 at 9:41 pm #22715
iDougParticipantAm having a problem getting the hardware real time clock (RTC) to work. Also, the BeagleBone Black does not set it’s clock on start up. According to the Adafruit link to use the service that sets the RTC, I need to use the command “systemctl”, but am getting the error “command not found”. As Adafruit is using Angstrom and OpenSprinkler is using Ubuntu, am assuming there is a different way to start this service.
How do I get the “rtc-ds1307.service” to work? Should I change everything to be a Cron job?
December 26, 2013 at 6:38 am #25856
RayKeymasterI thought the OSBo image is configured to use RTC . I could be wrong since the RTC part has not been thoroughly tested. Note that the RTC initially needs to be set with the current time. Otherwise it will always go back to 2000 Jan 1. Once set, the clock will start running and it should keep up with current time.
December 31, 2013 at 9:11 pm #25857
iDougParticipantI can set system time:
ntpdate -b -s -u pool.ntp.org
Set the hardware clock from the current system time.
sudo hwclock -w
Reading system time.
date
Reading hardware clock
sudo hwclock -r
Everything but enabling and starting the service.
When I run:
which systemctl
there is no response. I am guessing systemctl is not a part of Ubuntu in the OSBo image.
It does appear that systemctl is NOT a part of Ubuntu. Several people have told me that “upstart” has replaced it.
http://upstart.ubuntu.com/cookbook/Anyone know a conversion from systemctl to upstart?
January 5, 2014 at 2:49 pm #25858
RayKeymasterYou are right, systemctl is not part of Ubuntu. I haven’t done much research on this and I am tempted to think you can create a init.d or use rc.local script to perform what you were able to do manually. If you check the Adafruit tutorial on RTC for Raspberry Pi:
http://learn.adafruit.com/adding-a-real-time-clock-to-raspberry-pi/set-rtc-time
towards the end there are descriptions about adding a few lines in rc.local to read from RTC automatically on startup. I will check if this can be done on the Bone with Ubuntu.January 6, 2014 at 9:00 pm #25859
iDougParticipantHere is my addition to the /etc/rc.local file:
# Get date-time from Internet (Write to BeagleBone Black BBB).
ntpdate -b -s -u pool.ntp.org
# Write date-time to the RTC on OpenSprinkler OSBo.
sudo hwclock -w
# Write the date-time from the OSBo to BBB.
# (Just in case the Internet is not available and the battery
# is working.)
echo ds1307 0x68 > /sys/class/i2c-adapter/i2c-1/new_device
sudo hwclock -s
exit 0Please, let me know if you see any potential issues. This does seem to work, even on a OSBo that does not have the date-time initially.
January 11, 2014 at 3:22 am #25860
RayKeymasterThe script looks fine to me. Glad to hear that you tried it and it seems to be working.
April 1, 2014 at 11:24 pm #25861
nayrParticipantMessing about it seems there’s 2 RTC’s on the OSBo, there is a built on one that I am not sure the details on but when you load the OpenSprinkler one it comes up as /dev/rtc1, as a result you will have to manually tell hwclock to use the OSBo RTC with the –rtc /dev/rtc1 switch.
[32426.321034] rtc-ds1307 1-0068: SET TIME!
[32426.339351] rtc-ds1307 1-0068: rtc core: registered ds1307 as rtc1
[32426.362582] rtc-ds1307 1-0068: 56 bytes nvram
[32426.376331] i2c i2c-1: new_device: Instantiated device ds1307 at 0x68here is my /etc/rc.local, it tries to set time via internet and if that fails it loads time from RTC.
echo ds1307 0x68 > /sys/class/i2c-adapter/i2c-1/new_device
ntpdate -b -s -u pool.ntp.org
if [ $? -ne 0 ];then
echo Setting system time from OSBo RTC
hwclock --rtc /dev/rtc1 -s
hwclock --rtc /dev/rtc0 -w
else
echo Updating Internet time on OSBo RTC
hwclock --rtc /dev/rtc1 -w
fiI went ahead and created us beagle users a setup page on the wiki: http://rayshobby.net/mediawiki/index.php?title=Set_Up_BBB
April 2, 2014 at 4:28 am #25862
RayKeymasterCool. Thanks for the tip and the contribution to the Wiki.
April 5, 2014 at 11:47 pm #25863
nayrParticipantwell today about an hour before my watering schedule went off I went out and yanked power to the beagle and removed ethernet; then 50mins later I plugged the beagle back in leaving ethernet disconnected and the sprinklers turned on right on time.
I’d say the RTC works just fine; my only suggestion is look at replacing the battery with a supercap.. a big supercap should keep time for at least a week and unlike a battery it will handle all temperature extremes and will still be running strong in 10 years.. it wont last the winter w/out power but do you really want to start in spring with a weak battery? A Supercap is also cheaper than a brand name lithium CR battery.
Edit, another tip: add: allow-hotplug eth0 to your /etc/network/interfaces so you dont have to reboot when u plug the network back in 🙂
July 18, 2015 at 5:10 am #39355
noskiParticipantI have tried the instruction in the wiki and all the commands worked, but when I disconnected from the internet and rebooted, the time doesn’t get set properly.
ubuntu@arm:~$ date Fri Jul 17 21:58:17 EST 2015 ubuntu@arm:~$ sudo hwclock --rtc /dev/rtc1 -r [sudo] password for ubuntu: Sat 18 Jul 2015 08:05:48 PM EST -0.714392 seconds
Where do I see the output from the echo commands in /etc/rc.local to confirm what it is doing?
July 20, 2015 at 11:27 am #39372
MikeParticipantI found them in one of the /var/log files. I’m not in front of my setup right now but I think it was in /var/log/boot
-
AuthorPosts
- You must be logged in to reply to this topic.
OpenSprinkler › Forums › Hardware Questions › OpenSprinkler Beagle (OSBo) › NOOB needs help with RTC service