Pi 4b and Teensy 4.1 sharing same RTC

Status
Not open for further replies.

Markos

New member
I'm working on a project that involves a Teensy 4.1 and a Raspberry Pi 4b, and the Teensy is the main controller that would also serve as the Pi's switch/keypad/etc.

One of the things that I'm looking at is for the two devices to share a common RTC, so that the system only needs one battery/etc. The Pi does its thing in updating the clock every time it connects to the Internet, but the Teensy should read the time for other uses it doesn't need the Pi for.

I basically have two options, which are either to use the Teensy's RTC or use a dedicated one.

I've tried both options but I've run into problems:

- Using a dedicated RTC - I've tried setting up the I2C. The Pi can read the 0x68 address but cannot seem to do anything to it. I've also tried setting up the RTC board with the Teensy and all it seems to do is reset itself every few seconds. I've wired up the I2C bus using the Teensy's 3.3v rail, SDA and SCL on pins 18 and 19 respectively, 4.7k resistors from both data pins to the 3.3v rail and only connecting the Pi's SDA, SCL and GND pins to the ground. The Teensy also seems to ignore the DS3231 RTC breakout board and revert to its own.

- Using the Teensy's RTC - It seems that every time I upload code to the Teensy using PlatformIO, it writes my computer's time and date to the RTC, which unsurprisingly resets itself once disconnected as I don't have a battery attached to it. How would I access the RTC from the Pi and read/write to it? The Teensy will be connected to the Pi via USB regardless so is that another way they can communicate?

Which way should I do this and how should I do it?
 
- A reset is a indication for a bug in your program.
- It does not ignore the DS3231, its a bug in your program or wrong usage.
- You can send the time from the PI to the Teensy.
- With the RTC on the Teensy, transfer the time to the PI and write a program that uses it.
- Third option, and the easiest - Use two batteries or connect both boards to the same battery. Do a resync after a few days.
Which way should I do this and how should I do it?
The third. The "problem" is not a problem, its over-engeneering.
 
Given a battery the builtin T_4.x RTC will usably store and track time. It can be shared to the Pi or updated form the Pi.

Without a battery the time is lost and on upload a new time will be installed if the build does that. On T_3.x the RTC time was only set when seen as invalid, not recalling the procedure on T_4.x but that time can be pushed during upload - not sure if it is absolute when commanded or selective based on a time seen as invalid.

Pushing the time on Upload shouldn't be an issue as it comes from the computer doing that at the time, though is a problem when the timezone is not where the upload occurs.

With proper code the external RTC should be usable as well and won't be subject to change during upload.
 
Status
Not open for further replies.
Back
Top