RTC with battery add to Joggler

Everything relating to hacking, expanding and modifying the Joggler hardware.
Post Reply
User avatar
pete
Posts: 2526
Joined: Mon Aug 01, 2011 6:33 am
Location: Time Traveler

RTC with battery add to Joggler

Post by pete » Sun Jan 24, 2016 8:49 pm

Credit to said endeavor goes to Graham Marshall at sunspot dot co dot uk specifically relating to:

Connect to the i2c bus on the Joggler main board located here: http://www.sunspot.co.uk/Projects/Joggler/i2c.html

WHY?
Create push button inputs, light external LED's, measure analog voltages,
run an LCD panel, control a servo motor, control the world . . . .

HOW?
Use standard i2c chips or connect to a PIC16F877A programmed as i2c slave.

The clue to finding the bus was the ICS UMS9001 clock chip U13 - see the chip manifest (thanks)
Pin 5 is SDA (data) and pin 6 is SCL (clock)


Image


Hardware required:

1 - Tiny RTC DS1307 i2C module with LIR2032 battery (NOT CR2032) - note these are available just about anyplace for around $1.00 USD
NOTE: the Tiny RTC i2C module has a charging circuit and that can blow up the CR2032 if it is utilized. The drawing below indicates what needs to be cut out relating to the charging circuit. Easier just to install an LIR2032 battery.
tinyrtc.jpg
tinyrtc-2.jpg
schematic.gif
ds18b20.gif
2 - Wire - 22 guage or less stranded (I used 4 colors - black, red, white and yellow).

Soldering required:

4 wires wired to the left side of the board labeled P2

SCL Wire ==> White
SDA Wire ==> Yellow
VCC Wire ==> Red
GND Wire ===> Black

I un stranded the stranded wire for the SCL and SDA using one strand for each connection and covered it with a drop of hot melt glue.

Picture of the USB 5VDC (red) and ground (black) connections.
USB-VCCGROUND.jpg
USB-VCCGROUND.jpg (27.06 KiB) Viewed 3353 times
Picture of wiring to SDL and SDA.
SCLSDA-1.jpg
SCLSDA-2.jpg
Picture of placement of RTC inside of Joggler and back of Openpeak motherboard. Note the wires are a bit thick. RTC will not fit in little cubby under motherboard. I used a lot of hot melt glue to keep the wires down.
RTC-Board-1.jpg
RTC-InsideofJoggler.jpg

Testing Connection. SSH to your Joggler or utilize a keyboard in a terminal session. Do not connect the wires from the RTC to the Joggler yet.

1 - sudo apt-get install i2c-tools
2 - modprobe i2c-dev
3 - i2cdetect -y 0

You will see this:

Code: Select all

     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- UU -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- 34 -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- UU -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- 69 -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --            
Shut down the Joggler and connect all of the RTC wires.

SSH to the Joggler and again type i2cdetect -y 0 . You will see this:

Code: Select all

     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- UU -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- 34 -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- UU -- -- -- 
50: 50 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- 68 69 -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --
50 = AT24C32 4KB EEPROM
68 = DS1307
UU = just means the memory location is being utilized.

Set up the RTC DS1307 hardware clock:

~# echo ds1307 0x68 > /sys/class/i2c-adapter/i2c-0/new_device

Set the RTC1 clock:

Read it first:

hwclock -r -f /dev/rtc1

Write system time to RTC1

hwclock -f /dev/rtc1 --systohc

Read RTC1 time again.

hwclock -r -f /dev/rtc1


~# hwclock -r
Fri 22 Jan 2016 11:49:19 AM CST -0.581011 seconds


Set up the hardware clock for boot time:

nano /etc/rc.local

Put this line before end.

echo ds1307 0x68 > /sys/class/i2c-adapter/i2c-0/new_device

Do a cold boot: (shut down Joggler and unplug the power supply).

Check again with i2ctools. You will see the following:

i2cdetect -y 0

Code: Select all

0   1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- UU -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- 34 -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- UU -- -- --
50: UU -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- UU 69 -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
Set hardware clock RTC1 booting up to the network.

hwclock -f /dev/rtc1 --systohc

Write a UDEV rule to make RTC1 RTC0

Check first:

udevadm info -a -p /sys/class/rtc/rtc1

Write the rule.

nano /etc/udev/rules.d/99-rtc1.rules

Put this line in the rule.

KERNEL=="rtc1", SUBSYSTEM=="rtc", DRIVER=="", ATTR{name}=="ds1307", SYMLINK="rtc", MODE="0666"

Save

Reboot. Now RTC is coming from RTC1.

Test it by shutting down the Joggler. Unplugging the NIC and power cord. Plug in power cord and time should be fine without the network cable plugged in.

In conclusion the installation of the tiny RTC DS1307 with a battery was sort of easy. Knowledgebase mostly came from OpenWRT microrouter modifications (well soldering stuff to the microrouter. I also did this to two Rasberry Pi 2 devices. It was much easier and involved no soldering using the PiFace RTC shim and running one doo all script.

Note that the listing said it was a LIR2032 and I got a CR2012 battery. Must be an issue now relating to delivery.

1 - You are adding a new Joggler clock referred to as RTC1 and based on the DS1307. The built in Joggler clock known as RTC0.
2 - Involves a tiny bit of bit banging.
3 - fits nicely inside of the Joggler
4 - most difficult was soldering tiny wires then hot melt gluing them in place (really not a DIY thing unless you have tiny wire, tiny soldering tip and hot melt glue.
5 - Best way for me to get it to run was to create a script that runs after the Joggler has booted in Ubuntu.
6 - well and now you have a battery backed up RTC clock that doesn't lose time after you disconnect the power from the device.
7 - only tested here with Buzz's Ubuntu.
8 - tested Mevi's EFI boot XP and I see a new device with an IRQ error - see picture
- Pete

Auto mater

User avatar
BuZz
Site Admin
Posts: 1441
Joined: Fri Mar 04, 2011 1:15 am

Re: RTC with battery add to Joggler

Post by BuZz » Wed Jan 27, 2016 6:18 pm

Nice Hack! :)

User avatar
pete
Posts: 2526
Joined: Mon Aug 01, 2011 6:33 am
Location: Time Traveler

Re: RTC with battery add to Joggler

Post by pete » Wed Jan 27, 2016 10:38 pm

Thank you BuZz!
- Pete

Auto mater

User avatar
pete
Posts: 2526
Joined: Mon Aug 01, 2011 6:33 am
Location: Time Traveler

Re: RTC with battery add to Joggler

Post by pete » Sat Jan 30, 2016 9:16 pm

Just asking for comments on what I have written above.

Those trying to do this DIY...did I miss anything?
- Pete

Auto mater

User avatar
hawsey
Posts: 1864
Joined: Sun May 22, 2011 11:23 pm
Location: Northumberland

Re: RTC with battery add to Joggler

Post by hawsey » Sat Jan 30, 2016 10:19 pm

Pete I have not tried this out but it looks like a great write up , i think I need to get retired to try out all this stuff , not enough hours in the day..
I think this would be worth putting in the Wiki Pete , together with the Realtek nic Mac address stuff , would you be interested in doing that ?
Happy Joggling

User avatar
pete
Posts: 2526
Joined: Mon Aug 01, 2011 6:33 am
Location: Time Traveler

Re: RTC with battery add to Joggler

Post by pete » Sun Jan 31, 2016 8:08 pm

Thank you hawsey.

Yeah I wouldn't mind installing this stuff in to the Joggler Wiki.

I am searching for a smaller RTC / battery combo as while the one I used is small; it is not small enough.

It is spare time tinkering using a tiny tip on my soldering iron, hot air machine and hot melt glue....baby steps and much on my part guessing per Graham Marshall's documentation on the i2C bus stuff.
- Pete

Auto mater

User avatar
pete
Posts: 2526
Joined: Mon Aug 01, 2011 6:33 am
Location: Time Traveler

Re: RTC with battery add to Joggler

Post by pete » Wed Feb 03, 2016 2:29 pm

I closed up the Joggler as I got the Lithium rechargeable battery for it on the Linux Joggler. I had to flip up upside to fit and remove the wireless USB stick. That said this specific Joggler has a small USB hub on the back of it for use with another USB stick.

It doesn't work with Wintel. So I am looking now to see and build one of those mini USB stick RTC clocks for a Wintel based Joggler. One of these devices would be easier to wire up if attached to one USB port (there are many) on the Joggler.

Really what it is is an i2c converter.

USB ==> i2C ==> RTC

By default it is recognized by either Linux or Wintel.

Only thing is most of them are just too big. Parts are very reasonable in price.

IE: maybe $2 USD for the two pieces unless purchasing them from Amazon.
USB-RTC-3.jpg
USB-RTC-2.jpg
USB-RTC-1.jpg
USB-RTC-1.jpg (7.28 KiB) Viewed 3195 times
Initial search will be for one of these. Ideally one with USB pins only would make it smaller. Initially though just plugging it in to the internal USB port would suffice.
USBtoi2Cboard.jpg
USBtoi2Cboard.jpg (9.62 KiB) Viewed 3193 times
- Pete

Auto mater

User avatar
pete
Posts: 2526
Joined: Mon Aug 01, 2011 6:33 am
Location: Time Traveler

Re: RTC with battery add to Joggler

Post by pete » Mon Jul 04, 2016 12:22 am

Ordered a smaller RTC clock with battery today.
SmallRTC.jpg
- Pete

Auto mater

User avatar
hawsey
Posts: 1864
Joined: Sun May 22, 2011 11:23 pm
Location: Northumberland

Re: RTC with battery add to Joggler

Post by hawsey » Mon Jul 04, 2016 8:10 pm

Looks neat ..

Sent from my Smart Ultra 6 using Tapatalk
Happy Joggling

User avatar
pete
Posts: 2526
Joined: Mon Aug 01, 2011 6:33 am
Location: Time Traveler

Re: RTC with battery add to Joggler

Post by pete » Mon Jul 04, 2016 8:45 pm

It is smaller than the one pictured here. The hot melt glue came off a bit so I put that Kaflon tape on it instead.

Image

and should fit fine under the left side of the main motherboard right next to the speaker. The battery is too big on the old RTC and it makes for too tight of a fit with the SSD card and wireless stick.

I was able to close and snap the case shut though but couldn't fit the wireless stick in there.
- Pete

Auto mater

User avatar
BuZz
Site Admin
Posts: 1441
Joined: Fri Mar 04, 2011 1:15 am

Re: RTC with battery add to Joggler

Post by BuZz » Tue Jul 05, 2016 3:20 pm

nice! :)

User avatar
pete
Posts: 2526
Joined: Mon Aug 01, 2011 6:33 am
Location: Time Traveler

Re: RTC with battery add to Joggler

Post by pete » Tue Jul 05, 2016 4:18 pm

Updated above typo errors and showing that only two changes need to be made.

1 - nano /etc/rc.local

Put this line before end.

echo ds1307 0x68 > /sys/class/i2c-adapter/i2c-0/new_device

2 - nano /etc/udev/rules.d/99-rtc1.rules

Put this line in the rule.

KERNEL=="rtc1", SUBSYSTEM=="rtc", DRIVER=="", ATTR{name}=="ds1307", SYMLINK="rtc", MODE="0666"

Test it.

Shut down, disconnect NIC cable and start up again. Time should be correct as it is loaded from RTC which is RTC1
- Pete

Auto mater

User avatar
pete
Posts: 2526
Joined: Mon Aug 01, 2011 6:33 am
Location: Time Traveler

Re: RTC with battery add to Joggler

Post by pete » Sun Jul 10, 2016 8:16 pm

10th of July, 2016 2:00 AM

Received new tiny RTC yesterday and installed it this morning at 2:00 AM.
Joggler-New-Mini-RTC.jpg
There is a little story here. We had a BBQ / birthday party yesterday. It started around 3:00 PM. All the guests left by around 10 PM except for the neighbor and their dog. Conversations started to drift around midnight and all of us were falling asleep in the middle of conversations while sitting outside. It was the dog wanting to go home that woke us up.

So neighbors left and we cleaned up a bit.

Wife and I sat down to maybe watch television. We both fell asleep.

I got up to put something away and ended up soldering the RTC to the Joggler in my work room.

Tested it to work great. The new miniature with battery RTC is the perfect size for the Joggler.

I was wired I guess and probably wouldn't have gone to sleep until I did this.

Then went back upstairs at around 3:00 AM, woke up wife and we went to sleep. (officially).
- Pete

Auto mater

User avatar
mickchip
Posts: 388
Joined: Thu Apr 14, 2011 7:06 am
Location: Handforth, Cheshire, UK

Re: RTC with battery add to Joggler

Post by mickchip » Tue Mar 07, 2017 8:28 pm

Pete
Have you got a link to the smaller RTC, the last one pictured
Jogglermaniac

User avatar
pete
Posts: 2526
Joined: Mon Aug 01, 2011 6:33 am
Location: Time Traveler

Re: RTC with battery add to Joggler

Post by pete » Wed Mar 08, 2017 2:14 pm

Looked at my purchases here from 2016 and still see it.

Search DS3231 High precision I2C Real Time Clock Module for Arduino UNO MEGA2560
RTC.jpg
It is $6.50 USD with free shipping here.

The PITA part is to wire / solder to the Pin 5 is SDA (data) and pin 6 is SCL of the aforementioned chip.

I soldered then put a drop of hot melt glue on the solder joints to keep the tiny wires in place.

The clock works great for the Linux builds but never was able to get it seen by the Wintel builds.

The RTC and SSD fit fine on the left side of the inside of the Joggler. That and you can utilize a mini wireless stick with this combo.

Here I also added a small 5 port USB hub to the back of the Joggler wired internally to a USB 2.0 connection.

One of the issues here was to boot straight from the SSD as it kept wanting to boot from the MMC (via EFI) for Linux. If Buzz's Linux worked with the Seabios boot then it would boot fine from the SSD drive.

Mods that worked here on my test Joggler were:

1 - base EFI Buzz's Ubuntu
2 - booted from MMC then went to SSD
3 - RTC clock mod - modded OS to tickle clock and use it as a time source (was thinking maybe of a USB connected RTC for Wintel here).
4 - 5 port USB 2.0 attached to back of Joggler
5 - 16Gb main drive SSD via ZIF cable

Other mods that I was never able to get going were:
1 - using the DECT stuff - most of the information relating to this was pulled off the internet so I couldn't play with it.
I could get Openpeak DECT phones to pair just fine with original OS installed. I can today pair up the Openpeak DECT phones with my VOIP box but they are a bit disfunctional.
2 - using the Zigbee chip for automation.

I wanted to try this on the Openpeak with the soldered in MMC but never was able to get it to boot from a ZIF drive (messed up the soldering on the motherboard).
- Pete

Auto mater

Post Reply