Set system time using a .sh script and RTC.

Just about everything about Red Pitaya
Post Reply
Posts: 10
Joined: Thu Aug 20, 2020 9:00 pm

Set system time using a .sh script and RTC.

Post by earlforeal » Thu Oct 22, 2020 7:32 pm

I was able to connect a DS3221 RTC to the red pitaya's I2C (SDA/SCL) and can use terminal commands like

Code: Select all

Using i2cdump for a specific address(es) will read the seconds, minutes, hours, date, year (00h-06h) from the RTC.

Code: Select all

$ i2cdump -y -r 0x0-6 0 0x68
     0  1  2  3  4  5  6    
00: 51 51 21 01 14 01 17

//to read seconds only
$ i2cdump -y -r 0x0 0 0x68
$ 0x51

//read hour only
$ i2cdump -y -r 0x2 0 0x68
$ 0x21
I would like to set the RP's system time using the RTC, and was wondering if using a would work? For example (pseudo code)

Code: Select all


//create variable that is current RP system time and will be amended with correct RTC time
old = $(date)

// create string variable using RTC time
new = $(i2cdump -y -r 0x0-6 0 0x68)

//change 'old' to 'new'
date -s '$new'

I am new to programming in general and have tried my best to articulate the problem, and ideas or advice would be greatly appreciated.

Post Reply
jadalnie klasyczne ekskluzywne meble wypoczynkowe do salonu ekskluzywne meble tapicerowane ekskluzywne meble do sypialni ekskluzywne meble włoskie

Who is online

Users browsing this forum: No registered users and 1 guest