User avatar
HermannSW
Posts: 4839
Joined: Fri Jul 22, 2016 9:09 pm
Location: Eberbach, Germany
Contact: Website Twitter YouTube

Installing RTC into Pi400 inside

Sun Dec 06, 2020 5:16 pm

This is a followup on "RPi 400: Why oh why still no RTC?" thread:
viewtopic.php?f=140&t=293268

fanoush identified free space in neighborhood of GPIO headers.
I added image highlighting that area:
viewtopic.php?f=140&t=293268#p1772224
Image


There was a statement from cleverca22 on soldering DS3231 SDA/SCL to GPIO pins ̴4̴+̴ 3 and ̴6̴ 5:
viewtopic.php?f=140&t=293268#p1773641
but those 2 pins are now stuck in i2c mode, you cant use them as gpio anymore
I don't buy this, when not using for other stuff, RTC just works.

When disabling use of RTC in /boot/config.txt and /lib/udev/hwclock-set, then yes, RTC does not work and the pins ̴4̴+̴6̴ 3+5 can be used for something else. But the RTC clock keeps running from battery. So whenever changing back to using RTC and rebooting, magically the correct time will be there.
Also many people use pins ̴4̴+̴6̴ 3+5 for I2C anyway, so that is not a real problem for most.

In order to handle the not-use-as-I2C case, DS3231 VCC needs to be disconnectable from 3V3 from the Pi400 outside.


I have DS3231 modules at home since 4 years, but did not have one here in rehab hospital.
So I ordered one on Amazon, and it was delivered today:
https://www.amazon.de/-/en/gp/product/B ... le_o01_s00
I tested module outside of Pi400 first:
20201206_151914.15%.jpg
20201206_151914.15%.jpg
20201206_151914.15%.jpg (61.83 KiB) Viewed 4398 times

Before more on the tests, the zoomed bottom right part of module shows diode 102.
There is nothing wrong with that diode, it is part of recharging circuit of the module.
But in that case an LIR2032 rechargeable battery would have been needed on delivery.
That is more expensive than the CR2032 battery delivered together with the module.
All chargers state "don't charge normal batteries", and so I did fix the issue 4 years ago by cutting that diode:
https://forum.arduino.cc/index.php?topi ... msg3047461
Image
I will do same with new module, before it will finally disappear in Pi400 inside.

Module dimensions 38 mm x 22 mm x 14 mm might be too big for fitting into the Pi400 free space.
Therefore I did order another DS3231 form factor that will arrive on Monday:
https://www.amazon.de/-/en/gp/product/B ... le_o00_s00
It has dimensions 1.4 x 1.3 x 1.3 cm, where part of vertical 13mm can be reduced by desoldering the 5x1 female headers.


So next I will follow Jeff Gerlings teardown instructions and see whether current DS3231 fits or not:
https://www.jeffgeerling.com/blog/2020/ ... and-review


After connecting the module, I followed these instructions:
https://www.instructables.com/Raspberry-Pi-DS3231/

And it worked, I verified this by powering off the Pi400 and waiting some minutes.
Then I disconnected DS3231 module.
After powering on, Pi400 connects to unsecured Wifi AP, but gets no internet.
For getting internet, I will have to enter name and password into network login page.
Until I do that, the old and incorrect time gets displayed top right (I use "%D %T" clock format with seconds).

Then I connected DS3231 again, powered off the Pi400 and waited some minutes.
After powering on, immediately when Desktop shows up, the correct time appears on top right of display.


With the active i2c-rtc dtoverlay DS3231 shows up as UU:

Code: Select all

pi@raspberrypi400:~ $ !i2c
i2cdetect -y 1
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- 57 -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- UU -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --                         
pi@raspberrypi400:~ $ 

The python example pointed to from free ebook did not work (device busy):
https://github.com/Slaveche90/az-delivery-ds3231

After I did undo all changes and rebooted, DS3231 showed up as 68 and example "worked".
(funny, python code says that today is Monday, not Sunday)


The DS3231 has 32KHz output on module 32K pin:
https://datasheets.maximintegrated.com/ ... pdf#page=9

I measured 32695Hz with my 400Msps logic analyzer (100MHz over 10s).

Pigpio examples measure similar (I connected 32K pin to GPIO17):

Code: Select all

pi@raspberrypi400:~ $ sudo ./freq_count_1 17
Monitoring gpios 17
Sample rate 5 micros, refresh rate 10 deciseconds
g=17 -39 (32694/-830995011)
g=17 32698 (32714/1000495)
g=17 32698 (32701/1000100)
g=17 32698 (32690/999745)
^C2020-12-06 17:58:45 sigHandler: Unhandled signal 2, terminating

pi@raspberrypi400:~ $ 

Code: Select all

pi@raspberrypi400:~ $ sudo ./freq_count_2 17
Monitoring gpios 17
Sample rate 5 micros, refresh rate 5 deciseconds
 17=     0
 17= 32696
 17= 32698
 17= 32698
^C2020-12-06 17:59:47 sigHandler: Unhandled signal 2, terminating

pi@raspberrypi400:~ $ 

There is a "not(INT)/SQW" pin on DS3231 module as well, that can be programmed.

When implanting DS3231 into Pi400, I will make SQW as well as 32K pins accessible outside.
Since I have my Dremel at home and not here, female header longer cables will show through kensington lock hole (yes, they will have to pass all the way from right to left inside Pi400).
Last edited by HermannSW on Sun Dec 06, 2020 5:53 pm, edited 1 time in total.
https://github.com/Hermann-SW/memrun
https://stamm-wilbrandt.de/2wheel_balancing_robot
https://stamm-wilbrandt.de/en#raspcatbot
https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://stamm-wilbrandt.de/en/Raspberry_camera.html

User avatar
rpdom
Posts: 19287
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Installing RTC into Pi400 inside

Sun Dec 06, 2020 5:28 pm

HermannSW wrote:
Sun Dec 06, 2020 5:16 pm
There was a statement from cleverca22 on soldering DS3231 SDA/SCL to GPIO pins 4 and 6:
viewtopic.php?f=140&t=293268#p1773641
but those 2 pins are now stuck in i2c mode, you cant use them as gpio anymore
I don't buy this, when not using for other stuff, RTC just works.

When disabling use of RTC in /boot/config.txt and /lib/udev/hwclock-set, then yes, RTC does not work and the pins 4+6 can be used for something else. But the RTC clock keeps running from battery. So whenever changing back to using RTC and rebooting, magically the correct time will be there.
Also many people use pins 4+6 for I2C anyway, so that is not a real problem for most.
I very much doubt that anyone uses pins 4 and 6 for i2c (other than for a ground on pin 6).

Pins 3 and 5 perhaps...
Unreadable squiggle

cleverca22
Posts: 4926
Joined: Sat Aug 18, 2012 2:33 pm

Re: Installing RTC into Pi400 inside

Sun Dec 06, 2020 5:37 pm

also, if you ignore the RTC and just use it for general gpio, you will risk sending random commands to the RTC, which may change the time
it may also try to reply (pull SDA low) and then that fights the pi trying to drive that pin high, potentially damaging either part, or just messing with your signals

User avatar
HermannSW
Posts: 4839
Joined: Fri Jul 22, 2016 9:09 pm
Location: Eberbach, Germany
Contact: Website Twitter YouTube

Re: Installing RTC into Pi400 inside

Sun Dec 06, 2020 5:54 pm

rpdom wrote:
Sun Dec 06, 2020 5:28 pm
I very much doubt that anyone uses pins 4 and 6 for i2c (other than for a ground on pin 6).

Pins 3 and 5 perhaps...
Thanks, you are right, I corrected in previous posting.
https://github.com/Hermann-SW/memrun
https://stamm-wilbrandt.de/2wheel_balancing_robot
https://stamm-wilbrandt.de/en#raspcatbot
https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://stamm-wilbrandt.de/en/Raspberry_camera.html

User avatar
HermannSW
Posts: 4839
Joined: Fri Jul 22, 2016 9:09 pm
Location: Eberbach, Germany
Contact: Website Twitter YouTube

Re: Installing RTC into Pi400 inside

Sun Dec 06, 2020 5:58 pm

cleverca22 wrote:
Sun Dec 06, 2020 5:37 pm
also, if you ignore the RTC and just use it for general gpio, you will risk sending random commands to the RTC, which may change the time
it may also try to reply (pull SDA low) and then that fights the pi trying to drive that pin high, potentially damaging either part, or just messing with your signals
That is what I thought to have addressed with this sentence from my posting:
In order to handle the not-use-as-I2C case, DS3231 VCC needs to be disconnectable from 3V3 from the Pi400 outside.
So there will be 5 female headers coming out of Kensington lock from inside:
  • 32K
  • SQW
  • GND
  • module VCC
  • Pi400 3.3V
Not connecting module VCC and Pi400 3.3V headers will completely disable the DS3231 module inside and avoid problems for non-I2C use of pins 3+5.
https://github.com/Hermann-SW/memrun
https://stamm-wilbrandt.de/2wheel_balancing_robot
https://stamm-wilbrandt.de/en#raspcatbot
https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://stamm-wilbrandt.de/en/Raspberry_camera.html

User avatar
HermannSW
Posts: 4839
Joined: Fri Jul 22, 2016 9:09 pm
Location: Eberbach, Germany
Contact: Website Twitter YouTube

Re: Installing RTC into Pi400 inside

Sun Dec 06, 2020 8:50 pm

I read Jeff's teardown instructions and thought this might be a show stopper for me:
To get it open, I used a plexiglass cutter, which is the only tool I have that's thin enough to get into the side clips that hold the white keyboard top to the red plastic shell underneath, but also rigid enough to un-pop the snaps. After working my way around the board, I could separate the keyboard top from the bottom half:


I only have a normal screw driver with me, and gave it a try. I started at rear side of left rear corner and made my way unpopping the snaps. The longer, the better, this photo showed when I was on front side:
20201206_201414.15%.jpg
20201206_201414.15%.jpg
20201206_201414.15%.jpg (21.6 KiB) Viewed 4275 times

Before telling more on the inside, after I was done, just pressing keyboard and bottom together snapped together so easily, I was really impressed. I assume that this was needed for a machine just pressing keyboard onto bottom. Cool.

After I connected mouse, power and HDMI cables again, I powered up -- Desktop appeared, keyboard worked, but mouse did not. I looked at the backside and saw that I plugged mouse cable into ethernet connector ;-) I was not aware that this was possible at all, replugging into USB2 board and mouse worked again.


Before showing the photos of both free spaces, the DS3231 module I received today will never fit there, neither left (BOURNS) nor right (RPI-RM0) free space. The battery holder of the current module does not fit between backside and Pi400 heatsink! On the other hand I am pretty sure that the DS3231 with different form factor I will receive on Monday will fit ...


OK, this is the right free space, here is full resolution smartphone photo for details:
https://stamm-wilbrandt.de/en/forum/RPI-RM0.jpg
Here is same photo scaled to 25% for forum attachment:
RPI-RM0.50%.50%.jpg
RPI-RM0.50%.50%.jpg
RPI-RM0.50%.50%.jpg (27.84 KiB) Viewed 4275 times

I saw QR code and tried QR code scanner of my smartphone. It gave me a long integer number, with no hit on DuckDuckGo nor on google. But searching for RPI-RM0 immediately showed that it is the WIFI module of Pi400. This free space is maybe 2-3mm longer than the space on left side, but there is more motherboard, so space is not that deep as on left side. Maybe it is not a good idea to bring electronic stuff directly into the near of RPI-RM0, so my new favorite free space is the left space. Yes, if something needs to be soldered to GPIO pins from there, a long cable is needed inside Pi400 from left to GPIO right. But the free space is directly at Kensington lock hole, and cables can be easily brought to outside through Kensington lock.


Here is right side near BOURNS SM51625L LAN adapter, again with full smartphone resolution for details:
https://stamm-wilbrandt.de/en/forum/BOURNS.jpg
Here scaled to 25% for forum attachment:
BOURNS.50%.50%.jpg
BOURNS.50%.50%.jpg
BOURNS.50%.50%.jpg (28.02 KiB) Viewed 4275 times

I have no ruler here, but from BOURNS datasheet the smaller side from top is 12.2mm. The height of free space where there is no motherboard below is more than 1cm.

Perhaps the whole DS3231 module I will receive on Monday will fit into the space without need to desolder 5x1 female headers. The instructables instruction I mentioned for setting up Pi RTC have image of the module I will get:
https://www.instructables.com/Raspberry-Pi-DS3231/
Image
https://github.com/Hermann-SW/memrun
https://stamm-wilbrandt.de/2wheel_balancing_robot
https://stamm-wilbrandt.de/en#raspcatbot
https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://stamm-wilbrandt.de/en/Raspberry_camera.html

User avatar
HermannSW
Posts: 4839
Joined: Fri Jul 22, 2016 9:09 pm
Location: Eberbach, Germany
Contact: Website Twitter YouTube

Re: Installing RTC into Pi400 inside

Mon Dec 07, 2020 12:25 pm

The new module arrived, and it is so small(!).
I tried to plug it onto pins 1,3,5,7,9 of GPIO, but that did not work.
Reason is that the battery cell between PCB and Pi400 back avoids good connectivity.
So I tested with 5 female/male cables in between, and RTC works nicely:
20201207_130823.15%.jpg
20201207_130823.15%.jpg
20201207_130823.15%.jpg (29.19 KiB) Viewed 4190 times

There seem to be two differences to the previous DS3231 module:
  • no recharge circuit (good, I don't have to cut a diode)
  • no 32K eeprom on 0x57 which the other module had

    Code: Select all

    pi@raspberrypi400:~ $ i2cdetect -y 1
         0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
    00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
    10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
    20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
    30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
    40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
    50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
    60: -- -- -- -- -- -- -- -- UU -- -- -- -- -- -- -- 
    70: -- -- -- -- -- -- -- --                         
    pi@raspberrypi400:~ $ 
    

Besides VCC/GND/SDA and SCL only one other module header is connected to GPIO4(pin7).
It is not the 32K pin of DS3231:

Code: Select all

pi@raspberrypi400:~ $ sudo ./freq_count_1 4
Monitoring gpios 4
Sample rate 5 micros, refresh rate 10 deciseconds
g=4 0 (0/1)
g=4 0 (0/1)
g=4 0 (0/1)
g=4 0 (0/1)
^C2020-12-07 13:23:29 sigHandler: Unhandled signal 2, terminating

pi@raspberrypi400:~ $ 

So I assume that it is the "not(INT)/SQW" pin of module.
I will find out how to enable 1Hz rectangle signal on SQW and test whether that can be seen on GPIO4.
Only if so, that pin will be made externally available (through Kensington lock hole).


P.S:
Nice, the 20cm long cables are long enough to connect GPIO with left free space inside Pi400.
Of course the GPIO side headers of the cables need to be cut in order to solder to GPIO pins from Pi400 inside.
20201207_153051.15%.jpg
20201207_153051.15%.jpg
20201207_153051.15%.jpg (37.51 KiB) Viewed 4150 times
https://github.com/Hermann-SW/memrun
https://stamm-wilbrandt.de/2wheel_balancing_robot
https://stamm-wilbrandt.de/en#raspcatbot
https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://stamm-wilbrandt.de/en/Raspberry_camera.html

User avatar
HermannSW
Posts: 4839
Joined: Fri Jul 22, 2016 9:09 pm
Location: Eberbach, Germany
Contact: Website Twitter YouTube

Re: Installing RTC into Pi400 inside

Mon Dec 07, 2020 4:44 pm

I did measure to which of the 16 DS3231 IC pins GPIO4 header is connected.
Unfortunately it is connected to DS3231 pin12, and that is one of the N.C. pins:
https://datasheets.maximintegrated.com/ ... pdf#page=9

If somebody with this DS3231 module wants to have access to not(INT)/SQW (DS3231 pin3) or 32K (DS3231 pin1), then soldering to the 1.27mm spaced pins is possible with good soldering skills.

So this is the connection plan:
  1. male headers into DS3231 module female headers
  2. soldered to Pi400 GPIO pins inside
  3. headers outside Kensington lock (later to on/off switch outside)

Code: Select all

DS3231  Pi400  outside
VCC            H1
        3V3    H2
SDA     SDA
SCK     SCK
GND     GND

Without H1 and H2 being connected, the RTC module is inactive and does not hurt non-I2C usage of Pi400 GPIO3+GPIO5. With H1 and H2 connected, DS3231 module gets powered from Pi400 3V3 and RTC module just works.


Next step is to Implant DS3231 module into left free space:
BOURNS.50%.50%.90°.jpg
BOURNS.50%.50%.90°.jpg
BOURNS.50%.50%.90°.jpg (27.86 KiB) Viewed 4113 times
https://github.com/Hermann-SW/memrun
https://stamm-wilbrandt.de/2wheel_balancing_robot
https://stamm-wilbrandt.de/en#raspcatbot
https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://stamm-wilbrandt.de/en/Raspberry_camera.html

User avatar
Imperf3kt
Posts: 4665
Joined: Tue Jun 20, 2017 12:16 am
Location: Australia
Contact: Twitter

Re: Installing RTC into Pi400 inside

Mon Dec 07, 2020 8:46 pm

Out of curiosity, about how many hours did this take you to design and build. Do you have any formal training?
(Trying to get an idea of approximate cost involved in designing this modification)
55:55:44:44:4C
52:4C:52:42:41

Rose tinted glasses are difficult to see through.

User avatar
HermannSW
Posts: 4839
Joined: Fri Jul 22, 2016 9:09 pm
Location: Eberbach, Germany
Contact: Website Twitter YouTube

Re: Installing RTC into Pi400 inside

Mon Dec 07, 2020 10:24 pm

Imperf3kt wrote:
Mon Dec 07, 2020 8:46 pm
Out of curiosity, about how many hours did this take you to design and build.
Many, but currently I am in physical rehab after operations in hospital, leaving quite some time to do fun stuff like this.
Do you have any formal training?
No, I am a software developer in day job.
But since years I do all kind of hardware stuff and am surprised myself that things can be just done.
Like my raspcatbot caterpillar Pi3A+ robot from signature, or building diy highspeed flashes for v1 camera global external shutter work.
I am doing quite some stuff with stepper motors as well, for Pi and/or Arduinos:
https://forum.arduino.cc/index.php?topic=649769.0
(Trying to get an idea of approximate cost involved in designing this modification)
I am doing this for fun, and especially this project because I really love my 3rd keyboard computer (after ZX81 and C64 in early 80s). I think this project is similar to open source development, just with hardware. Somebody has to do it once and provide description (code for software projects), then everybody liking it can do it the same way, or with modifications.


I have opened the Pi400 again and found a 1st feasible position for the new DS3231 RTC module inside left free space. Before cutting the cables on right side for soldering to GPIO inside, I will play around a bit more on whether there is a better position. The cables from left to right have completely free way, as if RP[FT] engineers have let that space free for what I want to do ;-) I did let the keyboard back half snap in again in order to see whether module as well as cables fit, and they do! More to come ...

Full resolution smartphone photo for details:
https://stamm-wilbrandt.de/en/forum/20201207_225512.jpg
Scaled to 15% for forum attachment:
20201207_225512.15%.jpg
20201207_225512.15%.jpg
20201207_225512.15%.jpg (33.97 KiB) Viewed 4033 times
https://github.com/Hermann-SW/memrun
https://stamm-wilbrandt.de/2wheel_balancing_robot
https://stamm-wilbrandt.de/en#raspcatbot
https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://stamm-wilbrandt.de/en/Raspberry_camera.html

User avatar
HermannSW
Posts: 4839
Joined: Fri Jul 22, 2016 9:09 pm
Location: Eberbach, Germany
Contact: Website Twitter YouTube

Re: Installing RTC into Pi400 inside

Mon Dec 07, 2020 10:53 pm

HermannSW wrote:
Mon Dec 07, 2020 10:24 pm
Before cutting the cables on right side for soldering to GPIO inside, I will play around a bit more on whether there is a better position.
I found a better position, turned DS3231 module by 180° and then moving it a bit sloped to make it fit under keyboard.
This time white cable that will be soldered to GPIO 3V3 is fed through Kensington lock hole to Pi400 outside.
Cable from module VCC is fed through that hole as well.
If both are connected outside, RTC is "on" and working.
Not connecting both cables outside of Pi400 disables RTC as if there is no change to Pi400 (for non-I2C use of GPIO pins 3+5).
When back at home next week I will dremel a hole into keyboard top and let a small on/off switch look out, leaving all cables inside Pi400 -- or perhaps attach it to Kensington lock hole, so that cables will be inside Pi400 only as well:
20201207_233752.15%.jpg
20201207_233752.15%.jpg
20201207_233752.15%.jpg (30.13 KiB) Viewed 4011 times

P.S.
Before soldering, I did fixate DS3231 module with my favorite connection method:
Little bit of superglue on module underside for connection to Pi400 underside, and on left side for glueing to red standoff.
Pi400_DS3231_superglued.jpg
Pi400_DS3231_superglued.jpg
Pi400_DS3231_superglued.jpg (34.95 KiB) Viewed 3999 times
https://github.com/Hermann-SW/memrun
https://stamm-wilbrandt.de/2wheel_balancing_robot
https://stamm-wilbrandt.de/en#raspcatbot
https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://stamm-wilbrandt.de/en/Raspberry_camera.html

User avatar
HermannSW
Posts: 4839
Joined: Fri Jul 22, 2016 9:09 pm
Location: Eberbach, Germany
Contact: Website Twitter YouTube

Re: Installing RTC into Pi400 inside

Tue Dec 08, 2020 1:48 am

Done!
But its 2:30am here in Germany and I need some sleep.

Just this, remainder will be documented after sleep and breakfast.
I wanted to test new RTC inside Pi400 before closing keyboard.
Interestingly Pi400 just boots without keyboard (I did disconnect keyboard by accident, not planned).
I took a video of the whole boot.
It ends in showing correct time in Desktop top right corner while (wireless) Network was still not available:
https://www.youtube.com/watch?v=LlcFfBo ... e=youtu.be
Pi400_DS3231_youtube.jpg
Pi400_DS3231_youtube.jpg
Pi400_DS3231_youtube.jpg (60.6 KiB) Viewed 3966 times

This is booted Pi400 without keyboard, photo scaled to 15% for forum attachment:
20201208_021410.15%.jpg
20201208_021410.15%.jpg
20201208_021410.15%.jpg (35.3 KiB) Viewed 3966 times

Remainder will follow after sleep and breakfast.
https://github.com/Hermann-SW/memrun
https://stamm-wilbrandt.de/2wheel_balancing_robot
https://stamm-wilbrandt.de/en#raspcatbot
https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://stamm-wilbrandt.de/en/Raspberry_camera.html

User avatar
HermannSW
Posts: 4839
Joined: Fri Jul 22, 2016 9:09 pm
Location: Eberbach, Germany
Contact: Website Twitter YouTube

Re: Installing RTC into Pi400 inside

Tue Dec 08, 2020 8:21 am

On aliexpress the module I bought (on local amazon) is available for 2.50$ incl. shipping.
Few cables, some solder, I would say total cost less than 3$ (without work).

This is full resolution 12MP (16:9) smartphone photo, allowing to zoom into details:
https://stamm-wilbrandt.de/en/forum/20201208_021410.jpg
Same photo scaled to 15%:
Image
The cabling is done according connection diagram detailed 7 postings ago.
There was an unused header of 5x1 female header of RTC module (that would connect to Pi400 pin7).
I did stick a male header with completely cut cable into it in order to have all 5 female headers filled (more stable).


I am not good at soldering, but finally made it. It is good that the GPIO headers have quite some space in between. After all was soldered, I did put some drops of superglue onto heatsink near GPIO and pressed all 4 cables into for some time. Superglueing the cables there acts as strain relief:
20201208_013759.15%.jpg
20201208_013759.15%.jpg
20201208_013759.15%.jpg (28.31 KiB) Viewed 3893 times

After successful boot without keyboard (youtube video pointed to in previous posting), I did plug keyboard cable into connector again and closed the Pi400. Again it all snapped in so easy, nice. The only change outside to before are the two cables that feed through Kensington lock, acting as on/off switch for the RTC. They will be replaced by a real on/off switch when back at home:
20201208_021859.15%.jpg
20201208_021859.15%.jpg
20201208_021859.15%.jpg (33.23 KiB) Viewed 3893 times

I did put a drop of superglue onto right (male header) cable and pressed it against back of Pi400 just above Kensington lock. That way all keeps its place until being replaced by on/off switch:
20201208_084536.15%.jpg
20201208_084536.15%.jpg
20201208_084536.15%.jpg (20.85 KiB) Viewed 3893 times
https://github.com/Hermann-SW/memrun
https://stamm-wilbrandt.de/2wheel_balancing_robot
https://stamm-wilbrandt.de/en#raspcatbot
https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://stamm-wilbrandt.de/en/Raspberry_camera.html

paulie
Posts: 276
Joined: Thu Jan 19, 2012 6:51 pm

Re: Installing RTC into Pi400 inside

Tue Dec 08, 2020 11:50 am

HermannSW wrote:
Tue Dec 08, 2020 8:21 am

...They will be replaced by a real on/off switch when back at home....
Suggestion: to avoid putting a switch through the casing, would a magnetically triggered reed switch be feasible? Could be either NO or NC depending on your use case.
It has been my custom to use Xeyes

User avatar
HermannSW
Posts: 4839
Joined: Fri Jul 22, 2016 9:09 pm
Location: Eberbach, Germany
Contact: Website Twitter YouTube

Re: Installing RTC into Pi400 inside

Tue Dec 08, 2020 7:54 pm

paulie wrote:
Tue Dec 08, 2020 11:50 am
Suggestion: to avoid putting a switch through the casing, would a magnetically triggered reed switch be feasible? Could be either NO or NC depending on your use case.
Interesting idea, but reed switches seem to be more expensive than others.


I walked away from the idea to drill a hole into Pi400 enclosure for slide switch.
Instead I will try to use the Kensington security slot, because I do not plan to
  • use that hole for Kensington lock
  • feed other stuff through that hole from inside to outside of Pi400

I do not have ruler here, and therefore have to assume that Pi400 Kensington security slot has same 7mm x 3mm dimensions as standard Kensington security slot:
Kensington_security_slot.jpg
Kensington_security_slot.jpg
Kensington_security_slot.jpg (8.4 KiB) Viewed 3778 times

I ordered this (less than 1$) micro slide switch which should arrive here in next few days:
micro_slide_switch.jpg
micro_slide_switch.jpg
micro_slide_switch.jpg (8.35 KiB) Viewed 3778 times

The 1.5mm x 1.5mm fits into 7mm x 3mm, since operational range is 2.1mm only.
The 4mm height of slide will make it come out of Pi400 slot for easy moving.
The switch 8.5mm x 3.5mm should allow easy superglueing from inside of Pi400 against security slot.
(bigger than 7mm x 3mm slot)



I did the test on using GPIO2+GPIO3 in a non-I2C scenario, the reason why I added the RTC on/off switch at all.
I used my setup of sending data fast over 26 GPIOs between Pi0 and Pi400 (for allowing to use Raspberry camera attached to Pi0 with the Pi400). 3 bytes of data get written per cycle over GPIO4..27, and GPIO2 is CLK and GPIO3 is ACK signal line. The copy file code from this posting does not work when RTC is "on":
viewtopic.php?f=29&t=290470&p=1771211#p1771193
20201201_213751.15%.50%.jpg
20201201_213751.15%.50%.jpg
20201201_213751.15%.50%.jpg (15.6 KiB) Viewed 3765 times

I did remove the RTC cable connection to turn RTC off, but copy file code did not work then as well.
After rebooting with RTC off, file copy code did work reliably.

So this is needed to allow for non-I2C use if GPIO2+3:
  • switch RTC off
  • reboot
It is not needed to undo the RTC changes in /boot/config.txt nor in /lib/udev/hwclock-set.


This is needed to go back to normal RTC use:
  • remove 38pin connection between Pi400 and Pi0 (RTC does not work otherwise)
  • switch RTC on
  • reboot (to activate rtc dtoverlay)
https://github.com/Hermann-SW/memrun
https://stamm-wilbrandt.de/2wheel_balancing_robot
https://stamm-wilbrandt.de/en#raspcatbot
https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://stamm-wilbrandt.de/en/Raspberry_camera.html

User avatar
HermannSW
Posts: 4839
Joined: Fri Jul 22, 2016 9:09 pm
Location: Eberbach, Germany
Contact: Website Twitter YouTube

Re: Installing RTC into Pi400 inside

Wed Dec 09, 2020 2:11 pm

TIL on adjtimex tool, that computes drift between kernel time and RTC time:

I disabled Wifi, and then rebooted Pi400.
After Desktop showed up, I opened terminal and started trend command for drift graph:
viewtopic.php?f=66&t=293560&p=1776207#p1776207

Drift shown is in 0.002..0.004 second range then.
After 30 seconds I enabled Wifi, you can see this by the big jump when kernel did network time update.
After that there is a roughly -0.5 second drift, because DS3231 RTC stores time only with second resolution:
https://datasheets.maximintegrated.com/ ... df#page=11
trend-v.rtc_drift.png
trend-v.rtc_drift.png
trend-v.rtc_drift.png (2.67 KiB) Viewed 3681 times
https://github.com/Hermann-SW/memrun
https://stamm-wilbrandt.de/2wheel_balancing_robot
https://stamm-wilbrandt.de/en#raspcatbot
https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://stamm-wilbrandt.de/en/Raspberry_camera.html

trejan
Posts: 3866
Joined: Tue Jul 02, 2019 2:28 pm

Re: Installing RTC into Pi400 inside

Wed Dec 09, 2020 3:33 pm

HermannSW wrote:
Sun Dec 06, 2020 5:58 pm
Not connecting module VCC and Pi400 3.3V headers will completely disable the DS3231 module inside and avoid problems for non-I2C use of pins 3+5.
It is better to isolate the SCL pin. Most ICs don't like voltages on their I/O pins that are higher than Vcc which would be 0V in your situation. The ESD diodes start conducting and partially backpowering the IC from the I/O pins which may cause problems with the RTC. The DS3231 datasheet says maximum voltage for SDA/SCL is Vcc + 0.3V.

User avatar
HermannSW
Posts: 4839
Joined: Fri Jul 22, 2016 9:09 pm
Location: Eberbach, Germany
Contact: Website Twitter YouTube

Re: Installing RTC into Pi400 inside

Thu Dec 10, 2020 7:48 pm

trejan wrote:
Wed Dec 09, 2020 3:33 pm
It is better to isolate the SCL pin. Most ICs don't like voltages on their I/O pins that are higher than Vcc which would be 0V in your situation. The ESD diodes start conducting and partially backpowering the IC from the I/O pins which may cause problems with the RTC. The DS3231 datasheet says maximum voltage for SDA/SCL is Vcc + 0.3V.
Thanks for that warning, I just tested again, rebooting with cables disconnected -- and immediately after reboot correct time showed up. It happened what you described, although there was no 3.3V on RTC VCC pin, real time clock did work.

I did another test with VCC and SCL disconnected, and after reboot the old time showed up. Also i2cdetect does not show UU for 0x68 anymore. Just to avoid any other issues I will diconnect SDA as well to turn off RTC, leaving only GND connected.

Luckily I had ordered 3 position dip switches that arrived today.
There was a perhaps 1mm high ring of plastic around Kensington slot on the inside of Pi400.
At home my Dremel would have removed it quickly, here I was able to get rid of it with just screw driver and sandpaper.
Removal was necessary in order to finally superglue the dip switch to Pi400 (see photo) allowing to change positions from outside.
That way VCC/SDA/SCL could be turned on/off separately, but I will use either all on or all off.
With dip switch in place as shown in photo, there is no place for RTC module as mounted last time.
I did bend the female headers by 90°, and functional test afterwards confirmed that RTC still works.
RTC will just be superglued on dip switch, before dip switch will be superglued to Pi400 back, but before that cables will be soldered to 6 dip switch contacts, and function test will be done with that; 12MP smartphone photo of current Pi400 state:
https://stamm-wilbrandt.de/en/forum/20201210_201158.jpg
Scaled to 15% for forum attachment:
20201210_201158.15%.jpg
20201210_201158.15%.jpg
20201210_201158.15%.jpg (35.68 KiB) Viewed 3575 times
https://github.com/Hermann-SW/memrun
https://stamm-wilbrandt.de/2wheel_balancing_robot
https://stamm-wilbrandt.de/en#raspcatbot
https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://stamm-wilbrandt.de/en/Raspberry_camera.html

User avatar
HermannSW
Posts: 4839
Joined: Fri Jul 22, 2016 9:09 pm
Location: Eberbach, Germany
Contact: Website Twitter YouTube

Re: Installing RTC into Pi400 inside

Fri Dec 11, 2020 4:31 pm

I did try to superglue the 3-position dip switch, after I enlarged the Kensington slot with screw driver a bit. Enlarging was not really necessary, but in order to get behind the switches it was better. This is how the inside looked:
20201211_140827.15%.part.jpg
20201211_140827.15%.part.jpg
20201211_140827.15%.part.jpg (29.11 KiB) Viewed 3380 times

I did solder 6 cables to the dip switch and then tried to superglue it against Pi400 backside from inside again and again, without success. It was just too difficult to glue it there with cables soldered. Then I realized that middle switch got lost to superglue, it was not possible to move it anymore.

So I used the 2nd of two 3-position dip switches I bought. I was able to superglue it safely, but in the end it was not glued firm enough. So I followed a new plan:
Cut out square in Pi400 backside so that the whole switch fits and can be superglued with its sides instead of its front.

That plan would be easy to follow with my Dremel at home, but I wanted to do it now. So I used screw driver with a lot of force, and more than 1 hour time to get the square cut out. It did cost some small scratches on my hand as well:
20201211_160422.15%.jpg
20201211_160422.15%.jpg
20201211_160422.15%.jpg (25.93 KiB) Viewed 3380 times

Before glueing switch into Pi400 back I realized that its switches had caught some superglue as well and are unusable. I will order new 3-position switches, but Amazon prime is not able to deliver tomorrow, so I will have to wait to complete this until back home on Monday.
https://github.com/Hermann-SW/memrun
https://stamm-wilbrandt.de/2wheel_balancing_robot
https://stamm-wilbrandt.de/en#raspcatbot
https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://stamm-wilbrandt.de/en/Raspberry_camera.html

User avatar
HermannSW
Posts: 4839
Joined: Fri Jul 22, 2016 9:09 pm
Location: Eberbach, Germany
Contact: Website Twitter YouTube

Re: Installing RTC into Pi400 inside

Sat Dec 12, 2020 4:38 pm

I learned that Amazon prime 1-day delivery depends of delivery location.
I was not able to get it here today where I am, but the order from yesterday already arrived at home where I will be on Monday.
I ordered ten 3-position slide switches for nearly the same price of the two I ordered last time -- but they are blue ;-)
blue.3-position.slide.switch.jpg
blue.3-position.slide.switch.jpg
blue.3-position.slide.switch.jpg (4.69 KiB) Viewed 3241 times
https://github.com/Hermann-SW/memrun
https://stamm-wilbrandt.de/2wheel_balancing_robot
https://stamm-wilbrandt.de/en#raspcatbot
https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://stamm-wilbrandt.de/en/Raspberry_camera.html

User avatar
HermannSW
Posts: 4839
Joined: Fri Jul 22, 2016 9:09 pm
Location: Eberbach, Germany
Contact: Website Twitter YouTube

Re: Installing RTC into Pi400 inside

Mon Dec 14, 2020 8:38 pm

Today I did install RTC finally into my Pi400 inside.

I did solder GPIO 3V3/SDA/SCL connected cables to top 3 pins of 3-position slide switch.
I did solder 3 short cables to bottom 3 pins of 3-position slide switch.
Then I did move 3-position slide switch into the big square I had cut into Pi400 enclosure, from inside.
Finally I connected the 3 soldered short cables to DS3231 VCC/SDA/SCL and Pi400 GPIO GND cable to DS3231 GND.

Without supergluing, I did reconnect keyboard flat ribbon cable and tested that RTC works after rebot with all 3 switches "on", and that RTC did not work with all 3 switches "off".

After successful test I powered off, removed keyboard again and pressed slide switch as far out of Pi400 hole in case as possible while keeping it firm in that hole. I added drops of superglue to all 4 (now visible blue sides of slide switch, and then slowly moved it into Pi400 enclosure again. Then I gave superglue some minutes.

This is photo just before glueing insulation tape onto tops of connectors and battery cell (the leftmost connector in DS3231 VCC was superglued with one drop onto Pi400 heatsink to keep everything in place):
20201214_204748.15%.jpg
20201214_204748.15%.jpg
20201214_204748.15%.jpg (32.25 KiB) Viewed 3090 times

After reconnecting keyboard flat ribbon cable and snapping keyboard into Pi400 ground form, Pi400 RTC now looks really nice to me (okay, perhaps a red 3-position slide switch would better fit the Pi400 colors, on the other hand blue is my favorite color, and without a mirror behind Pi400 the slide switch cannot be seen in normal use of Pi400):
20201214_210954.15%.jpg
20201214_210954.15%.jpg
20201214_210954.15%.jpg (25.53 KiB) Viewed 3090 times

Finally I did test again that RTC can be disabled and enabled by changing the 3 slide switches together. So my Pi400 is done with topic of this thread ...


P.S:
I just see on the photo that the two USB3 ports have blue inside as well ...
https://github.com/Hermann-SW/memrun
https://stamm-wilbrandt.de/2wheel_balancing_robot
https://stamm-wilbrandt.de/en#raspcatbot
https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://stamm-wilbrandt.de/en/Raspberry_camera.html

User avatar
HermannSW
Posts: 4839
Joined: Fri Jul 22, 2016 9:09 pm
Location: Eberbach, Germany
Contact: Website Twitter YouTube

Re: Installing RTC into Pi400 inside

Tue Dec 15, 2020 7:49 pm

I forgot to provide the promised bill of material.

The 3-position slide switch is only needed with all on or all off, and a 3-position toggle switch is cheaper to get.
DS3231.bom.png
DS3231.bom.png
DS3231.bom.png (44.85 KiB) Viewed 2992 times
  1. DS3231 RTC as shown in photo
  2. 3-position toggle switch
  3. four 20cm cables
  4. 3 short cables
  5. some solder
DS3231 does cost 1.76$ inclusive shipping:
https://www.aliexpress.com/item/32464558997.html

3-position toggle switch does cost 0.83$ inclusive shipping:
https://www.aliexpress.com/item/4000302033146.html

Therefore an RTC inside Pi400 does cost less than 3$ (and some work).
x.anim.gif
x.anim.gif
x.anim.gif (83.05 KiB) Viewed 2992 times
https://github.com/Hermann-SW/memrun
https://stamm-wilbrandt.de/2wheel_balancing_robot
https://stamm-wilbrandt.de/en#raspcatbot
https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://stamm-wilbrandt.de/en/Raspberry_camera.html

BMS Doug
Posts: 4423
Joined: Thu Mar 27, 2014 2:42 pm
Location: London, UK

Re: Installing RTC into Pi400 inside

Tue Dec 15, 2020 9:29 pm

Unfortunately that toggle switch is unsuitable as it is on-off-on for two sets of contacts, you need on-off for three sets of contacts.

this one is suitable.

You want a 3PST (Three Pole Single Throw) or 3PDT (Three Pole Double Throw) switch.
Doug.
Building Management Systems Engineer.

User avatar
HermannSW
Posts: 4839
Joined: Fri Jul 22, 2016 9:09 pm
Location: Eberbach, Germany
Contact: Website Twitter YouTube

Re: Installing RTC into Pi400 inside

Wed Dec 16, 2020 4:31 am

Thanks for correcting.
These switches are more expensive.
And thinking again, I would prefer dip switches as I used, because they keep close to Pi400 case.

I had wrong currency for DS3231, so here are prices inclusive shipping and links:
2.09$ https://www.aliexpress.com/item/32464558997.html
1.73$ https://www.aliexpress.com/item/10000004737395.html ("3 PIN red" this time)

In total less than 4$ for RTC inside Pi400.
DS3231.bom2.png
DS3231.bom2.png
DS3231.bom2.png (41.61 KiB) Viewed 2922 times
https://github.com/Hermann-SW/memrun
https://stamm-wilbrandt.de/2wheel_balancing_robot
https://stamm-wilbrandt.de/en#raspcatbot
https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://stamm-wilbrandt.de/en/Raspberry_camera.html

BMS Doug
Posts: 4423
Joined: Thu Mar 27, 2014 2:42 pm
Location: London, UK

Re: Installing RTC into Pi400 inside

Mon Dec 21, 2020 6:39 pm

HermannSW wrote:
Thu Dec 10, 2020 7:48 pm

That way VCC/SDA/SCL could be turned on/off separately, but I will use either all on or all off.
I understand that the original plan was to switch off VCC but you discovered this didn't work to properly isolate the SDA/SCL.

I'm wondering if there remains any need to isolate the VCC once SDA and SCL are isolated? Leaving VCC connected would reduce the battery usage and allow for using cheaper 2 pole switches instead of needing 3 pole.
Doug.
Building Management Systems Engineer.

Return to “Raspberry Pi 400”