Page 1 of 1

Configuration of a RTC-MCP79410 with Raspberry PI 3

Posted: Wed Jul 25, 2018 3:33 pm
by LinuxKoku
Hello,

I just configured a RTC (MCP79410) with a Raspberry PI 3, I made the recommended configurations, then I do the command sudo hwclock -r and in fact, I always have the default time (2001-1- 1 01:00: ....) but when I do sudo hwclock -w, the system takes the internet time, and the clock works by cutting the wifi, if I do a reboot without connection, I always the right time, so until everything works fine! But, when I turn off the Raspberry PI, and then I turn on, I have the date and time that come back by default (01/01/2001 - 01:00), and the clock starts counting of this hour (default)! so I have to turn on the wifi then make a hwclock -w for it to work!

Anyone have an idea about this problem?

:?: Here is what this command line i2cdetect -y 1 displays:

Code: Select all

[email protected]:~ $ 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: -- -- -- -- -- -- -- --
At startup I noticed that it shows me an error, and I think it is the RTC, here is a picture of the error displayed:

Re: Configuration of a RTC-MCP79410 with Raspberry PI 3

Posted: Wed Jul 25, 2018 3:43 pm
by ericcooper
What MCP79410 module are you using? Does it have a battery, and if so have you checked that the battery is good? Without a battery, most RTC chips will lose their settings when the power goes off.

Re: Configuration of a RTC-MCP79410 with Raspberry PI 3

Posted: Wed Jul 25, 2018 3:48 pm
by DirkS
LinuxKoku wrote:
Wed Jul 25, 2018 3:33 pm
I made the recommended configurations
Which recommended modifications?
Please show exact steps (or at least a link to it)

Re: Configuration of a RTC-MCP79410 with Raspberry PI 3

Posted: Thu Jul 26, 2018 8:01 am
by LinuxKoku
Hello,

I do not think it's a battery problem, becauseI tried several RTC and it's the same thing, I think it's a problem of configuration, the configurations I made are so numerous that I do not know which ones I I did, but it's the same that I find everywhere (see (https://www.open-electronics.org/a-rtc- ... cond-part/ , https://raspberrypi.stackexchange.com/q ... time-clock ) ), I am going to see the datasheet of the RTC(http://ww1.microchip.com/downloads/en/D ... 02266J.pdf) and something to challenge me! it's bit 3:

:idea: Page 19 of the datasheet:

bit 3 VBATEN: External Battery Backup Supply (VBAT) Enable bit
1 = VBAT input is enabled
0 = VBAT input is disabled


I think in my configuration this bit is 0! but i do not know how to do the test nor find the relevant configuration file. If this bit is 1 then you'll be right ericcooper , it's hardware problem

:?: Someone would have an idea about this bit 3, and how to configure it?

Re: Configuration of a RTC-MCP79410 with Raspberry PI 3

Posted: Thu Jul 26, 2018 12:59 pm
by LinuxKoku
Hello,

If you know safe source configurations, suggest them to me, I will uninstall my configurations, and redo what you offer me.
I completely block, so any idea is welcome

Thank you all

Re: Configuration of a RTC-MCP79410 with Raspberry PI 3

Posted: Fri Jul 27, 2018 7:37 am
by LinuxKoku
Hello,

:idea: Possibility: If the RTC is no longer powered, it loses the time so when I turn my system back on, I go back to the default time, while the RTC has an external battery that allows it to be autonomous, so it should not come back by default, looking on the RTC datasheet, I find a bit that allows to activate this battery (bit => VBAT) , I think this bit = 0 , as shown on page 19 of the datasheet!

:?: What do you think of my suggestion?

Re: Configuration of a RTC-MCP79410 with Raspberry PI 3

Posted: Sat Jul 28, 2018 6:03 pm
by TimWJ
I don't know if this will help. I have been using the MCP79410 for several years on various Pi.

I am running piCore as an Operating system not Raspbian but the kernel and modules are the same.

Here is by boot code

Code: Select all

/sbin/modprobe i2c-dev
/sbin/modprobe rtc-ds1307
echo "mcp7941x 0x6f" > /sys/bus/i2c/devices/i2c-1/new_device
sleep 1
/sbin/hwclock -s
I am sure that it would be better to do all this in config.txt but I did not know when I started and the above works for me.

I may help if you can say how you currently have set it up.

Tim

Re: Configuration of a RTC-MCP79410 with Raspberry PI 3

Posted: Sat Jul 28, 2018 6:12 pm
by DirkS
TimWJ wrote:
Sat Jul 28, 2018 6:03 pm

Code: Select all

/sbin/modprobe i2c-dev
/sbin/modprobe rtc-ds1307
echo "mcp7941x 0x6f" > /sys/bus/i2c/devices/i2c-1/new_device
sleep 1
/sbin/hwclock -s
I am sure that it would be better to do all this in config.txt but I did not know when I started and the above works for me.

I may help if you can say how you currently have set it up.

Tim
That's 'old style', don't use it

Use device tree (with settings in config.txt)
And OP already mentioned he did exactly that

Re: Configuration of a RTC-MCP79410 with Raspberry PI 3

Posted: Sat Jul 28, 2018 10:12 pm
by TimWJ
I agree as I said it is better to use device tree via config.txt.
I still cannot see the OP's configuration.
I did post a configuration that has been running for a couple of years on around 30 systems with the exact chip the OP is using.
Using "if it is not broken don't fix it", I have left them using modprobe. Your preference may well differ.

The OP could use i2cget to read the configuration registers and check how the driver/configuration has setup the device.

The only Pi I currently have here does not have an RTC connected.

Tim