Real Time Clock Script for Raspberry Pi
HTML-код
- Опубликовано: 11 сен 2024
- No need to modify multiple files just to install a real time clock on your pi. With a one line command we can have the real time clock installed and configured on your pi in less than 60 seconds. :-)
🔹Links mentioned in the video
Buy the real time clock - amzn.to/31G37Td
thepihut.com/b...
github.com/km4ack
🔹Commands used in the video
cd ~/Downloads
wget raw.githubuser... && bash rtc
🔹Raspberry Pi Build Guide - tiny.cc/pi4guide
🔹Weekly Newsletter - mailchi.mp/40d...
🔹Follow Me
Instagram @km4ack
Twitter @twitter
🔹FREE Get Started Guide - tiny.cc/getstar...
🔹Cool Ham Gear - km4ack.com
🔹Support the channel through Patreon - / km4ack
🔹Did you just get a raspberry pi and want to hook it up to your radio? Start here • Where to start? Raspbe...
Want your raspberry pi to play nice with your ham radio? Are you into digital modes like FT8, JS8Call, FLDIGI, Winlink, APRS, Digipeaters and others? Each week I put out new content showing you exactly what steps to take to get the latest ham radio software on your raspberry pi. Whether you just want to ragchew or are seriously into emergency preparedness, emcomm, or ARES and want to learn all you can about using the raspberry pi to drive your ham radio, this channel has something for you. Be sure to click the subscribe button and ring the bell before heading off. That way you will get notified of all future videos.
🔹My Shack🔹
Yaesu 857D - amzn.to/2MOAZtx
Yaesu FT65R - amzn.to/2XsOQq5
Raspberry Pi - amzn.to/2WjLzIk
Signalink Soundcard - amzn.to/2EZjxMx
🔹🔹🔹🔹🔹
As an Amazon Associate I earn from qualifying purchases
KM4ACK you did it again! Thank you so much for what you have done for the ham radio and pi community. I just bought an rtc thinking I would have to do it the hard way.
very good script !
i have a small improvement.
if someone has the same problem as me with mulitple connected devices, you can just alter the first query of the script to "contains" instead of "matches"
if error message says "Please enable I2C interface in the Raspberry Pi Configuration and try again", this means the returned string can be emtpy OR multiple outputs like (example): /dev/i2c-0 /dev/i2c-1 /dev/i2c-10 /dev/i2c-20 /dev/i2c-21 /dev/i2c-22
so change this:
if [ $IC2ACTIVE = "/dev/i2c-1" ]
to this:
if [[ $IC2ACTIVE == *"/dev/i2c-1"* ]]
so it asks for "contains"
have fun :)
Jason, just got my real time clock today in the mail and installed it the easy way. It is working perfectly. My GPS dongle is in the mail to me, should have it in a few days. I know I have said it before, but you are a lifesaver!!! I had all but given up trying to use my Raspberry Pi. I had issues trying to use a 3.5 inch touch screen, then I got a 5 inch HDMI screen, still issues but after watching your videos and doing the VNC connect and now with the Pi Build I have a working Pi for amateur radio. So far I haven't had any issues using the V2 (got the link from the email) on my Pi. I have worked several stations using FT8, ran JS8Call and did a @autocall and got a few stations reply. Haven't had a QSO on JS8Call yet. I have used Ardop and got Winlink working. Played around with the SSTV, but I don't have any pictures on my Pi, yet! Saw your email today and now I am going to look for a USB drive small enough to fit the USB ports once the radio, Signalink and GPS is hooked up. You are doing the amateur radio a great service my friend, especially those looking for portable operations and emergency in the field comms. Keep up the good work!! Juddie WD8WV
WOW! Congrats. Glad you have it all working. Success stories like this drive me to do the next video. 73, de KM4ACK
Grab the same real time clock I use here amzn.to/2OYdwo1
Hello, I'm having trouble. I activate i2c in raspberry pi configuration, however when squeetling the script appears a message stating "Please enable IC2 interface in the Raspberry Pi Configuration and try again.
Please help me! :(
Genius!!! Installing a RTC module was quick and easy. Thank you for your help
Can't wait to see what a difference this makes on my SbitX! Thank you for the easy to follow video.
Trying to figure out why I keep getting instructions to enable IC2 interface when the interface has it listed as I2C. I've enabled it yet I keep getting the error to enable when I follow the instructions
My Raspberry Pi 3b refuses to run Jason's rtc script. The error msg "Please enable I2C interface in the Raspberry Pi Configuration and try again" . I've checked the i2c interface configuration was set to enable and tried to Reboot, then Shutdown and Boot but get the same error.
I had same error. I installed older version of raspberry os and it worked.
Thanks! I'm trying to get a modded Pokemon game to run on RetroPie and needed a real-time clock. Didn't even know these were available.
Yes, let me definitely complement you for this excellent video and script you have given to us. Thank You!
Super video KM4ACK, i bought 2 of them a while back and forgot how to install, your video made it easier.. I see that it is even added to the build a pi script. 73 Martin PA0KGB
I bought one many years ago and revisiting this project. Connecting I noticed it's not detecting. The onboard battery is dead by now. So I resoldered a button batt to replace it.. Still not detecting. I wonder if the onboard batt matters or just needed when power is comp. off
Good stuff Jason! Another useful tool !
Amazing. Got it working in one line. Thanks
Great 👍
Jason, I've been out of the hobby for many years but getting back in now. Just got a Pi4 but I know nothing about it. How do you use a 5V fan and the RTC clock at the same time? Do they share the same pins?
The RTC connects to the inside row of pins for the GPIO and the fan connects to the outside row 5V & ground. 73, de KM4ACK
@@KM4ACK my clock uses the first 3 pins on both rows. :(
Drones In SC not familiar with that style
@@KM4ACK I ordered some pin connectors. I think I can piggyback on the backside of the PCB for the fan power. :)
Drones In SC - I was about to ask the same question... thank you for beating me to it.👍
Hi can i add rtc ds1302 or rtc ds 3231 on gpio while dac hat has already plugged in?
Adding the RTC took the first five pins. What happens if I need those pins for something else?
I have a DS-3231 rtc module. I see you are using a DS-1307 rtc module. What must I do/change to install this rtc version? Thx!
Sorry to ask but having 1 issue and I'm not sure what I've missed. The RTC is not updating the system time, When i check the rtc has the correct time its just not passing it over to the pi. I also have a gps plugged in and when it gets a lock then that updates the system time ok. Does the rtc work as well as the GPS or do i just use one or the other. Thanks for any pointers
Brian
G0WZB
Hi, tnx very much. Easy install and working 100% in a Pi 4. 73 and DX de XE1E
Great information again Jason as usual!! I am getting ready to order the real time clock and the GPS dongle today for my Raspberry Pi!! I sat in the living room last night and ran the Pi again with my 817ND and Signalink in my radio room and worked some FT8 in the comfort of my loveseat!! Haven't been able to connect to a station using Ardop yet. Winlink has been setup on the website, I just can't seem to connect to a station anywhere close to me on 40 Meters. It could be because I am only running 5 watts into a tuned 80 Meter dipole up 25 feet. Juddie WD8WV
5 watts will limit you a bit but maybe try the auto pat feature in Pat Menu.
Do you need to turn off I2c port after install? Or do you leave open for pi to sync RTC from standardized source?
You want to leave it enabled as this is the way the pi communicates with the RTC. 73, de KM4ACK
Question : Does selecting RTC on 2023 BAP menu do the same thing as this script? tnx ... Tom VE3NY
Enabled "i2c" and rebooted and it's asking me to enable it
I am wondering, what is pin 4 on RTC connected to Pin 7 (GPIO4) on RPI used for?
You cant get PIs any more but you can get the $30 AML-S905X-CC (Le Potato) clone. Any help in installing the RTC on it would help. Overlays have to be installed
I got a question is there anywhere else to plug up the clock because the spot where you say to plug it up is already tucking
You keep writing these scripts about 3 weeks after I did it the hard way. I'm putting my field pi in a drawer for 3 weeks.
😂🤣😂 Sorry not sorry. Hang around for 3 weeks and I’m sure it will change again. Build-a-Pi 2 is coming soon!
This works only until I reboot - then my Pi4 forgets how to access the RTC. Any ideas?
I ran this script and went as planed til I answered Y for both questions. which at time did show correct info. now when I check time & date its off ALOT. I did do this manually the long way anf after running the script after the sudo bash, I noticed the correct time that showed has changed from 2024 to 1999. I am wondering if this is due to the RTC chip is ds3231 not ds1307.
I got it to work, turns out quality control on these modules isn't up to spec. LUL
These are back in supply now but there is a one month waiting period for delivery. Don't know if the Convirus is affecting this. I ordered mine last week and was given a April 7 delivery date.
Jason, thanks for the great video. I will add the RTC to my RPi4. May I know how to install that information frame on the right hand side of the video? There is a bunch of valuable info within the frame.
Keep up the good videos!
The info on the right is produced by Conky. I did a video on it a while back ruclips.net/video/K4ZdWxuHT-8/видео.html 73, de KM4ACK
Hi jason, I am really struggling to get an RTC module working with Ubuntu server on a raspberry pi, do you have a guide for this?
Hi, i can't see the Number 68, can someone help me pls?
Any video on a combined RTC and GPS for timekeeping along with a nice installation script? I’ve been trying to use a USB GPS receiver with the Pi4B for a long time and only been able to see the NMEA data, no time syncing. Even an acquaintance with far more Linux and Raspberry Pi experience than me has failed at it.
Just tried to install the RTC and the autospot update, but now I have zero audio out via HDMI or headphones. It seems like I spend more time jacking around with this pi than being able to use it.
Check you volume levels and default sound card using the speaker icon in upper right corner of desktop. Alternatively, run ‘alsamixer’ from terminal. Neither of the scripts should have any bearing on sound. 73, de KM4ACK
does pi get it's fake-time when pi is close to known wifi ? Or do we need to log on with ssh to sync pi fake-time clock? when I write fake-time I mean no rtc?
If the pi connects to the internet, it will pull the time from the internet. It would have to be connected to the wifi to get the time.
Forgot to ask Jason. My GPS from amazon has not come yet , should I wait till it does before installing the RTC ?
No. Just make sure you have the pi connected to internet. 73, de KM4ACK
thank You Very Much!
You are amazing. thanks for all you do.
Thank you!!! With love from Russia!!!!!
Thank you for the video.
Question if I may.... What is the point/benefit of installing the clock? Let’s say the only thing you use the pi is JS8CALL... will the clock now synch JS8CALL to the correct time? What if you power down the pi, do you have to reset again when powering it back up?
Sorry if these questions are mundane... but I’m a NOOB. 🥳
Great questions! The pi doesn't have a RTC on the main board. So if you power the pi down and fire it back up a week later without an internet connection, the time will be off by a week. We can overcome this in one of two ways. 1. Add a GPS dongle connected to the pi. When the GPS gets a lock on satellites, it will also download the time and sync with the pi. 2. Install a RTC like in the video. This is an actual RTC that will keep accurate time even when the pi is powered off since it has a battery built into the RTC. When the pi is booted up, it will get the current time from the RTC and sync it to the pi's time. Either way will give you accurate time for apps like JS8Call or WSJTX. A third option is to add both the GPS and the RTC for redundancy. 73, de KM4ACK
KM4ACK thank you, Jason. As always, I appreciate your expertise and willingness to share.
Great video & tutorial!!
Say I want to time a relay to go off and one a couple times a day with a raspberry pi. Do I need one of these RTC modules or can I just use the existing time modules from within the pis libraries? Secondly would it be better to use the rtc module if I plan on using an arduino mini?
You won't need the RTC provided you are connected to the internet. The Pi will pull correct time from the internet on boot. The RTC is needed if you don't have internet since the Pi doesn't have a RTC on board.
@@KM4ACK ok thank you. My only concern is if the internet were to go out I'm hoping to keep my greenhouse automated so that's why I'm so set on using an RTC. Hoping to take this design to an arduino nano next to use RTC to control just a couple relays to go off a few times a week to power a couple water pumps. (One pump from a nutrients tank and one pump from a water tank set to go off at different intervals) at this point I'm willing to pay someone to help me figure it out.
It looks like it’s a Raspberry Pi-3B+ shown in the video. Will this RTC module and this script work equally good on the latest Pi-4 and Buster OS? Thanks! Linas LY2H
Yes. It works with the pi 4.
Almost plug & play .... Many many thanks
Hmmm... seems I have a choice of a case with fans or RTC. Any cases with fans that allow access to the RTC pins? I'm sure there's some.
As soon as I posted, I recalled I had some header extenders. While I had already passed the Build-a-Pi V2 script section on the RTC, I just swapped the header in and put the RTC on. I'll see how it goes once the BaPv2 script completes.
Jason I am wondering the BEST way to Shut off or on Hotspot to Wifi internet .As your system I do like, HotSpot for the field ,and when in the shack a switch over to Shack Wifi internet. I am getting My amazon GPS usb like yours today so be covered in RTC in the field, along with the RTC here.So could you guide me into commands to use in switching that you may do when your switching that fast and quick . 73's Jason
To force the hotspot to check for known SSID run ‘sudo /use/bin/autohotspotN’ it will only shut off if a known WiFi SSID is in range. Otherwise it defaults back to the hotspot.
Excellent video, any chance you could show us a similar tutorial for the Raspberry pi PICO?
Thanks Jason for an awesome channel!
I've downloaded the Build-a-Pi, but I want to uninstall some of the programs I installed. I am first-timer to Pi and Linux. How do I do this?
Uninstall isn't currently a feature of build a pi. You will need to do that manually or do a clean build from scratch.
How long the super capacitor can keep the time if no power is applied, are we talking months or days,
The RTC takes a small watch battery. I am guessing that you should be able to get a year out of it.
@@KM4ACK thank you so much for response, the modules that I ordered came with super capacitors soldered like a tiny battery, not sure what would be the backup time on those guys, the modules looks the same just like the one you have used here. Cheers
Is there any way with this rtc to correct the time with Daylight Saving offset automatically?
Why you need a rtc¿? for what do you use it?
The raspberry pi doesn't have a RTC built in. If you power down the pi, it will not keep correct time. On reboot, the time will be the same as when you powered it down last. If you are connected to the internet, the pi will obtain the correct time from a time server over the internet. However, if you are working portable without internet, you need a RTC added to your pi that is able to keep time even when the pi is powered down.
Quick and efficient.👍
Hello KM4ACK thank you very much for this easy install script! LOVE IT!
I have only one Question, when the battery is fully discharged and i have to replace ist, how do i set the right time again?
Connect the pi to the internet or GPS to get accurate time and the run *sudo hwclock -w* to write the system time to the RTC board.
@@KM4ACK perfect! Thank you!
It all works nice now!
Thank you KM4ACK only one question, is there a away to switch automatically between European Summer and Wintertime?
Thanks a lot
What timing. I was ready to run the pi build script for the first time this morning, and I saw this.
Using the first method, "./rtc" game me a bash permission denied error. The second method worked. Should it be run with sudo?
Did you make the rtc file executable with 'chmod +x rtc' ? 73, de KM4ACK
KM4ACK yes. The ls command showed rtc in green.
Ed, run the script with 'bash rtc' An error was found in the original script that can prevent it from running. It has since been resolved. Sorry for the confusion. 73, de KM4ACK
KM4ACK Too late. :) You provided a second method and that worked fine. So no trouble for me. Worked like a charm.
What it is for? Aren't the os already have clock?
No. The raspberry pi doesn't have a native real time clock
Jason, great video. On Amazon, would other DS3231 clocks work? There listed one was out on Amazon, so I found one described as DEVMO DS3231 AT24c32. But it seems to have 6 pins. Starting at one end they are labeled, GND, Vcc, SDA, SCL, SQW, 32k. Let us know what you think. Thanks!
I updated the link in the pinned comment on this video to a suitable replacement. amzn.to/3bFN3Fx Grab in now though. There is only 10 of them in stock as I type this. 73, de KM4ACK
@@KM4ACK Jason, will your script work with other real time clocks? I purchased one a while back from Amason (5 pin DS3231) that OH8STN had recommended in one of his videos and had not yet gotten around to installing it. Or do I have to use the one you set up in this video? Gerald - KG0VA
Gerald, I suspect it will work with any of the DS3231 variants. The one I linked to is the one I purchased and tested with. Please report back after you try it. 73, de KM4ACK
The DS3231 all work fine, except some have some additional features. If I recall correctly the DS3231M chips do not have the temperature sensor on, which can result in a higher clock drift due to the crystal changing behavior in different temperatures. The DS3231SN does have a temperature sensor, so allows for accurate adjustment because of it. That said, if you're connecting to NTP or GPS, the RTC can be updated as necessary when those are available as clock sources.
As for the extra pins, the SQW is programmable square wave generator, and the 32k is a 32khz square wave generator. Unless you really want to dig into them, chances are you won't use them, like most people won't use the calendaring and alarm functionality that is built into the chip. Just don't plug them in.
Jonathan Angliss thanks for the detailed explanation! I learned a few things. 😃👍 73, de KM4ACK
Thanks
The "RTC Clock Module DS3231 High Precision Real Time RTC Clock Module Memory Module for Raspberry Pi 4 Pcs" from Amazon is "Currently unavailable. We don't know when or if this item will be back in stock." I found this on Amazon's website FYI Jason.
It seems like you guys have bought them out. Hopefully we see them return in a few day. Look at the very first comment on this video. I put a link there but there is only 2 left in stock as I type this.
Talk about influencing sales, its difficult to find any available devices for sale except Ebay.
Looks like there is a few of these available - amzn.to/2OYdwo1
Hey Jason, do you know how using baofeng with raspberry to create an aprs?
Easiest way is to use a signalink as your soundcard. Signalink makes a cable for the baofeng. Then you should be able to follow my APRS digipeater video. 73, de KM4ACK
@@KM4ACK can i use sound card stick or alternate sound card? Because signalink its very difficult to find in my country.
Abdul Azzam Ajhari you can but PTT will be more difficult. Keep in mind that VOX doesn’t work well on the Baofeng because of long hang time.
@@KM4ACK ah i see. Thanks for the info jason
would this work with retropie?
I want to use it for the day night cycle in the ds pokemon games
I would think so but I haven't tested it with retropi
@@KM4ACK thanks for replying
this works on arduino?
This was written for the pi
@@KM4ACK well i found this, there is a method to program DS3231 pi on the arduino, hope are usefull, ruclips.net/video/iIknekXJ62M/видео.html
Hot Digg'ie Dog Just what the Doctor ordered.So with info on paper and video on hand,Jason you won't mine if I skat to the Pi , Another Learning Ecersise well explain , whats nice if I goof just listen again closely .. Now My Digi'e Pgm's be happy lol lol 73's Jason
Clear the screen with *CTRL-L*
Great tutorial and good script. Unfortunately i received this from hwclock:
$ sudo hwclock -v -r
hwclock from util-linux 2.36.1
System Time: 1717737020.287812
Trying to open: /dev/rtc0
Trying to open: /dev/rtc
Trying to open: /dev/misc/rtc
No usable clock interface found.
hwclock: Cannot access the Hardware Clock via any known method.
Rebooting and disconnecting from internet the clock is not updated, any reason ? Thank you.