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?
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?