sbcshop / USB-RTC-Software

USB RTC is an open source real time clock device that comprises MCP2221, a USB-to-UART/I2C serial converter, which enables USB connectivity, in the processes that include a USB, UART(Serial), GPIO, and I2C interfaces.
GNU General Public License v3.0
11 stars 4 forks source link

Instructions aren't very helpful for non-coders. RTC on Ubuntu 20.04 Raspi. Please help? #5

Open Danrancan opened 2 years ago

Danrancan commented 2 years ago

I just bought this device online. I am running a lemp server on my raspberry pi. After restarting the pi and when it is offline, it's logs timestamps become innaccurate since the raspberry pi doesn't have an internal rtc. My goal was to buy this RTC in case my internet crashed, but I needed accurate timestamps on my Pi's log files. I am VERY confused by the instructions here. Is it possible to make ubuntu server 20.04 on raspberry pi use this as the default RTC, to keep accurate logs and timestamps while offline? And if so, how? What exactly must I do after installation? I am even having issues just setting the clock let alone forcing the pi to use this clock as the default rtc.

Please let me know where I can start in accomplishing this task. If you help me, I will certainly provide a contribution to your git repo in the form of a tutorial for other users of this product. Thank you!

p1r473 commented 2 years ago

What Ive done is first set the time from the internet with one of these

sudo date -s "$(wget -qSO- --max-redirect=0 google.com 2>&1 | grep Date: | cut -d' ' -f5-8)Z"
sudo date +"%d %b %Y %T %Z" -s "$(wget -qSO- --max-redirect=0 google.com 2>&1 | grep '^  Date:' | cut -d' ' -f 5-)"
sudo date +"%d %b %Y %T %Z" -s "$(curl -s --head google.com | grep '^Date:' | cut -d' ' -f 3-)"

then add this into crontab -e to set the time on every reboot @reboot /usr/bin/python3 /home/pi/USB-RTC/Set_Time_Boot.py