We were unable to load Disqus. If you are a moderator please see our troubleshooting guide.

Join the discussion…

- ##### in this conversation

⬇ Drag and drop your images here to upload them.

- Attach

###### Log in with

###### or sign up with Disqus or pick a name

### Disqus is a discussion network

- Disqus never moderates or censors. The rules on this community are its own.
- Your email is safe with us. It's only used for moderation and optional notifications.
- Don't be a jerk or do anything illegal. Everything is easier that way.

Read full terms and conditions

By signing up, you agree to the Disqus Basic Rules, Terms of Service, and Privacy Policy.
By posting, you agree to the Disqus Basic Rules, Terms of Service, and Privacy Policy.
I'd rather post as a guest

- Ed • 3 years ago

  I have 3 of the RasClock modules. I install the software support using your prebuilt image (3.6.11 kernel) and the RTC functions flawlessly. However, After performing an "apt-get upgrade" or a "rpi-update" I notice that the startup message no longer displays "Linux SystemName 3.6.11-atsw-rtc#1 PREEMPT" but now displays "Linux SystemName 3.6.11+ #FirmwareRevision PREEMPT".
  The problem is now the call to "hwclock" returns the following "hwclock: Cannot access the Hardware Clock via any known method.". Yes, I am executing the procedures using "sudo" to elevate my privilige level.
  Is there a fix for this? Additionally, is there a 'clean' procedure for uninstalling the "dpkg" installation of the RasClock software? If so can you post or email it to me? Thanks for the help in advance...

  see more
  - Sigivald Ed • 3 years ago

    Both of those upgrade commands may (will) replace your OS kernel with one that doesn't have the special RTC drivers they talk about above.

    The fix is to either go back to their binary kernel as above, or compile the driver yourself against the kernel that apt-get or rpi-update installed.

    see more
- Remi Bergsma • 3 years ago

  Works great, thank you for sharing! Will write a blog post about this when I find the time.

  In addition to this post: I'd recommend removing the 'fake-hwclock' scripts, since we now have a RTC :-)

  # Disable fake-hwclock
  # remove package
  apt-get remove fake-hwclock
  # remove cronjob
  rm /etc/cron.hourly/fake-hwclock
  # disable and remove init script
  update-rc.d -f fake-hwclock remove
  rm /etc/init.d/fake-hwclock

  see more
- Tawanda Gwena • 3 years ago

  Here is a rough script to play with the PCF2127a registers and memory. (I'm sorry about the formatting, I have no idea how to force fixed width font)

  # Tawanda Gwena ( http://tgwena.blogspot.com )
  # (C) 2013
  # Script to read/write registers and memory on the PCF2127a (RasClock)
  # WARNING: No error checking is performed with this script
  # WARNING: Make sure the device is available otherwise it cannot be read
  import smbus
  import sys
  import getopt
  import time
  bus = smbus.SMBus(1) #For version 2 of the pi (512MB), change to 0 for version 1 (256MB)

  address = 0x51 # I2C address of PCF2127

  #read byte from register i
  def regreadbyte(i):
  j=bus.read_byte_data(address,i)
  return j

  #write byte to register i
  def regwritebyte(i,v):
  bus.write_byte_data(address,i,v)

  #subtract j before doing BCD. This is to take care of things like alarm which start with 1
  def regbytebcd(i,t=0):

  j=regreadbyte(i)-t
  k=(j>>4)*10+j&0xF
  return k

  # writes byte to RAM location 0<=addr<=511
  def writebyte(addr,v):
  hb=addr & 256 #high bit
  lb=addr & 255 #low bits
  regwritebyte(0x1A,hb)
  regwritebyte(0x1B,lb)
  regwritebyte(0x1C,v)

  # reads byte from RAM location 0<=addr<=511
  def readbyte(addr):
  hb=addr & 256
  lb=addr & 255
  regwritebyte(0x1A,hb)
  regwritebyte(0x1B,lb)
  return(regreadbyte(0x1D))

  #These addresses are from the PCF2127a datasheet
  #(http://www.nxp.com/documents/d... )

  print("time",regbytebcd(5),regbytebcd(4),regbytebcd(3))
  print("date",regbytebcd(9),regbytebcd(8),regbytebcd(6))
  print("alarm",regbytebcd(0x0C,128),regbytebcd(0x0B,128),regbytebcd(0x0A,128))

  print "Control1",bin(regreadbyte(0x00))
  print "Control2",bin(regreadbyte(0x01))
  print "Control3",bin(regreadbyte(0x02))
  print "CLKOUT",bin(regreadbyte(0x0F))
  print "Aging",bin(regreadbyte(0x19))
  print "Alarm",bin(regreadbyte(0x0A))

  #set all memory to 42
  for i in range(0,512):
  writebyte(i,42)

  for i in range(0,512):
  print(chr(readbyte(i)))

  see more
  - Magnus Olsson Tawanda Gwena • 2 years ago

    Thank you, just what i was looking for!

    Are there any way to read and write the ram memory after you do:
    echo pcf2127a 0x51 > /sys/class/i2c-adapter/i2c-1/new_device

    Or do i have to write the hwclock code myself if i want to write data to the ram?

    Hope someone can help me with this, thank you!

    see more
    - Tawanda Gwena Magnus Olsson • 2 years ago

      Were you able to resolve your problem? You can contact me at tgwena@gmail.com

      see more
- Luther Chaplin • 7 months ago

  I've found that on older Raspbian versions, after doing the lines:

  dpkg -i linux-image-3.2.27-atsw-rtc_1.0_armhf.deb
  cp /boot/vmlinuz-3.2.27-atsw-rtc+ /boot/kernel.img

  My RPi is prone to crashing when also using a usb to serial adapter. However, on upgraded raspbian
  with those commands not being necessary I can install the RTC successfully and use the adapter without
  crashing. Excuse my ignorance but for a setup where I have already done those two lines what are the
  commands to undo them and return all kernal stuff to how it was before?

  see more
- AfterthoughtSoftware Mod • 3 years ago

  We have just added a post to our blog on how to cross-compile a .deb package for a new kernel. http://afterthoughtsoftware.co...
  Hope this helps.

  see more
- Stefan Andersson • 3 years ago

  Hi,

  I'm very pleased with you product !

  What i'm wondering is, which of the SIX GPIO pins are used ?

  I'm "moving" the clock from the GPIO pin, and don't whant to connect unused PINs

  Br Stefan

  see more
  - LS Stefan Andersson • 2 years ago

    Have you found out meanwhile? Well, I'm new with the RTC module and if you check the PCB, I can see at least 3 pins connected, that is 3.3V, GPIO 0 and 1, and also GND, which is PIN#3 on the other side. This is also in the guide "It uses the 3.3V, GND SDA and SCL pins." SDA/SCL is for I2C. But I think it allows stacking up, using same pins if you have more I2C devices. Please correct me if that is wrong. BR

    see more
    - motocoder LS • 8 months ago

      Yes, I2C is designed to allow multiple slave devices on the same bus. As long as they don't use the same address as the clock (0x51) it should work fine.

      see more
- OE3SUW • 3 years ago

  Fast track for building the .ko on a running RPi without installing the Binary Bundle:

  --- START ---

  sudo apt-get update
  sudo apt-get –y dist-upgrade
  sudo apt-get -y install build-essential gcc make cmake i2c-tools
  mkdir devel
  cd devel
  wget https://github.com/raspberrypi...
  wget https://github.com/afterthough...
  tar xzf rpi-3.6.y.tar.gz
  cd linux-rpi-3.6.y/
  SUW=`pwd`
  patch -p1 < ../fd5ff2d88f470ed70ff58393eee61110b181816a.patch
  zcat /proc/config.gz > .config
  echo m | make oldconfig
  wget https://github.com/raspberrypi...
  make modules_prepare
  cd drivers/rtc
  make -C $SUW M=`pwd`
  sudo cp rtc-pcf2127a.ko /lib/modules/3.6.11+/kernel/drivers/rtc/
  sudo depmod

  --- END ---

  Unfortunateyl disqus.com shtortens the links so if you copy the script don't forget to use the real links and not the shortened ones!

  Then proceed with the changes in /etc/modules and /etc/rc.local

  Done... :-)

  see more
  - Hrothgir Ó Dómhnaill OE3SUW • 2 years ago

    I tried to run this but get a fail on

    patch -p1 < ../fd5ff2d88f470ed70ff58393eee61110b181816a.patch
    zcat /proc/config.gz > .config

    with the error
    patch **** Only garbage was found in the patch input.
    and .config contains
    patch unexpectedly ends in middle of line
    Any thoughts, since I'm a bit stumped.
    Thanks :)

    see more
  - LS OE3SUW • 2 years ago

    Hi OE3SUW,
    Basically script worked, I was running with rpi-3.10.y.tar.gz, BUT after rebooting, I get a hefty kernel panic. This panic comes right after loading the driver rtc-pcf2127a.ko.
    I'm recovering a backup now, a week old, and try to stay away from rpi-update.
    Is 3.6 Kernel a must have for that .ko? Thanks BR

    see more
    - LS LS • 2 years ago

      http://raspberrypi.stackexchan...

      see more
    - LS LS • 2 years ago

      Oh btw, it's a Null pointer panic, supposed to be really bad.

      see more
  - Scot OE3SUW • 3 years ago

    After echo m | make oldconfig

    I get the following:
    HOSTCC scripts/basic/fixdep
    /bin/sh: 1: scripts/basic/fixdep: Permission denied
    make[1]: *** [scripts/basic/fixdep] Error 126
    make: *** [script_basic] Error 2

    I also tried to execute with sudo to no avail. Any suggestions?

    see more
  - Jim OE3SUW • 3 years ago

    Thanks for posting this. I get a tiny error at the end:

    [jim@alarmpi rtc]$ make -C $SUW M=`pwd`

    make: *** pwd: No such file or directory. Stop.

    Any idea?

    see more
    - OE3SUW Jim • 3 years ago

      Hi Jim,
      are you sure that you used the grave accent around pwd?
      It must look like `pwd`. That means the Program pwd should be executed and the output is the value for the parameter M. If you use the Apostrophe ( ' ) it means the string pwd should be the the value for M...

      see more
  - Remi Bergsma OE3SUW • 3 years ago

    Thanks for sharing!

    I found I needed to edit the .config you create on the 'zcat ...' line, because in the running kernel 'CONFIG_RTC_DRV_PCF2127A' is still turned off, so it will not build the module, hence the copy of the .ko file fails.

    To fix it, just edit the file, or run this one-liner:

    sed -i 's/# CONFIG_RTC_DRV_PCF2127A is not set/CONFIG_RTC_DRV_PCF2127A=m/g' .config

    Then it will build the rtc-pcf2127a.ko module just fine.

    Kind regards,
    Remi

    see more
- Daniel • 3 years ago

  I need to make a soft-float "armel" version of linux with the PCF2127 built in so I can use the Afterthought RasClock. (I am using it with some other software that requires this.) Do I download everything in the repository to my Pi and then type "make install" ? Will this work? How does one build the kernel from source?

  see more
  - AfterthoughtSoftware Mod Daniel • 3 years ago

    The Embedded Linux Wiki has instructions on building the kernel from source (http://elinux.org/RPi_Kernel_C.... You'll have to adjust this for your particular compiler and kernel version and I'd recommend you build your kernel with your necessary compiler first and check that works.

    You can then get the changes to support the RasClock from our repository on GitHub (https://github.com/afterthough.... The only patch you need is https://github.com/afterthough... which can be applied from your kernel source directory with `patch -p1 < /path/to/fd5ff2d88f470ed70ff58393eee61110b181816a.patch`

    see more
    - mitchelln AfterthoughtSoftware • a year ago

      I've just got a V4 for my Pi 2. Does it still connect at the end corner of the 40 pin GPIO connector?

      see more
      - AfterthoughtSoftware Mod mitchelln • a year ago

        Yes, connects to the corner end of the 40-pin connector. You can see it connected to the Raspberry Pi 2 at http://afterthoughtsoftware.co...

        see more
        - mitchelln AfterthoughtSoftware • a year ago

          Brilliant! Thanks for such a fast reply.

          see more
    - Keld Norman AfterthoughtSoftware • 2 years ago

      Here is a guide for adding the realtimeclock module to the rpi-3.12.y.tar.gz - or even later versions:

      The links are to be copied manually - sorry for that - that's how this page works..

      --------------------------------------- CUT HERE ----------------

      #!/bin/bash

      clear

      CURRENT_KERNEL="$(uname -a|awk '{print $3}')"

      GET_THIS_KERNEL="`echo ${CURRENT_KERNEL}|cut -d '.' -f-2`.y"

      echo "----------------------------------------------"

      echo " SCRIPT TO UPGRADING THE REALTIME CLOCK MODULE"

      echo "----------------------------------------------"

      echo ""

      echo " Preparing to install the realtime clock module (this will take about 15 min).."

      echo ""

      echo " Module: rtc-pcf2127a.ko"

      echo " Homepage: http://afterthoughtsoftware.co..."

      echo " Your kernel: ${CURRENT_KERNEL:-error}"

      echo ""

      echo " INFO: This module will be included in Kernel 3.11.1-2"

      echo " (info from blog on homepage listed above)"

      echo ""

      echo " Press enter to continue or CTRL+C to exit this script.."

      read -n 1 dummy

      echo "---------------------------------------------------------------------------------"

      echo " `date` Starting script"

      echo "---------------------------------------------------------------------------------"

      echo ""

      echo "---------------------------------------------------------------------------------"

      echo " STEP 01 - Adding dynamic temporary iptables to allow updates"

      echo "---------------------------------------------------------------------------------"

      echo " iptables -I OUTPUT 1 -o eth0 -j ACCEPT"

      /sbin/iptables -I OUTPUT 1 -o eth0 -j ACCEPT

      echo ""

      echo "---------------------------------------------------------------------------------"

      echo " STEP 02 - Installing build-essentials..."

      echo "---------------------------------------------------------------------------------"

      echo ""

      # This will install:

      #--------------------------------------------------------------------------------------------

      # ca-certificates cmake cmake-data emacsen-common i2c-tools libarchive12 libcurl3

      # libcurl3-gnutls libnettle4 librtmp0 libssh2-1 libxml2 libxmlrpc-core-c3 sgml-base xml-core

      #--------------------------------------------------------------------------------------------

      apt-get update && apt-get dist-upgrade -y && apt-get install -y build-essential gcc make cmake i2c-tools

      if [ $? -ne 0 ]; then

      echo ""

      echo "### ERROR - Cant update repo and install the build essentials.."

      echo ""

      exit

      fi

      #

      if [ -d ./devel ]; then

      echo ""

      echo "### INFO - Found an existing ./devel directory - deleting it.."

      rm -Rf ./devel

      fi

      #

      echo ""

      echo "---------------------------------------------------------------------------------"

      echo " STEP 03 - Creating ./devel directory & downloading the kernel source+rtc patch.."

      echo "---------------------------------------------------------------------------------"

      mkdir devel && cd devel && wget https://github.com/raspberrypi...{GET_THIS_KERNEL}.tar.gz && wget https://github.com/afterthough...

      if [ $? -ne 0 ]; then

      echo ""

      echo "### ERROR - Cant get the kernel souce and realtimeclock patch.."

      echo ""

      exit

      fi

      echo ""

      echo "---------------------------------------------------------------------------------"

      echo " STEP 04 - Extracting the kernel tar.gz.."

      echo "---------------------------------------------------------------------------------"

      tar xzf rpi-${GET_THIS_KERNEL}.tar.gz && cd linux-rpi-${GET_THIS_KERNEL}/

      if [ $? -ne 0 ]; then

      echo ""

      echo "### ERROR - Cant get the kernel souce and realtimeclock patch.."

      echo ""

      exit

      fi

      echo ""

      echo "---------------------------------------------------------------------------------"

      echo " STEP 05 - Patching the kernel with the realtime patch"

      echo "---------------------------------------------------------------------------------"

      SUW=`pwd`

      patch -p1 < ../fd5ff2d88f470ed70ff58393eee61110b181816a.patch

      if [ $? -ne 0 ]; then

      echo ""

      echo "### ERROR - Patching of the kernel failed.."

      echo ""

      exit

      fi

      echo ""

      echo "---------------------------------------------------------------------------------"

      echo " STEP 06 - Extracting current kernel compile options from /proc/config.gz.."

      echo "---------------------------------------------------------------------------------"

      /bin/zcat /proc/config.gz > .config

      if [ $? -ne 0 ]; then

      echo ""

      echo "### ERROR - Extract of the /proc/config.gz failed.."

      echo ""

      exit

      fi

      #

      echo ""

      echo "---------------------------------------------------------------------------------"

      echo " STEP 07 - Making a new .config from the original .config of the running kernel.. "

      echo "---------------------------------------------------------------------------------"

      echo m | make oldconfig

      if [ $? -ne 0 ]; then

      echo ""

      echo "### ERROR - Make oldconfig failed.."

      echo ""

      exit

      fi

      echo ""

      echo "---------------------------------------------------------------------------------"

      echo " STEP 08 - Enabling build of the RTC_DRV_PCF2127A module in the .config file.."

      echo "---------------------------------------------------------------------------------"

      sed -i 's/# CONFIG_RTC_DRV_PCF2127A is not set/CONFIG_RTC_DRV_PCF2127A=m/g' .config

      if [ $? -ne 0 ]; then

      echo ""

      echo "### ERROR - Altering of the CONFIG_RTC_DRV_PCF2127A to =m failed in .config gile failed.."

      echo ""

      exit

      fi

      echo ""

      echo "---------------------------------------------------------------------------------"

      echo " STEP 09 - Getting the Module.symvers file.."

      echo "---------------------------------------------------------------------------------"

      wget https://github.com/raspberrypi...

      if [ $? -ne 0 ]; then

      echo ""

      echo "### ERROR - Wget of the Module.symvers failed.."

      echo ""

      exit

      fi

      #

      # Delete the old module (rename it) if it already exist..

      #

      if [ -f /lib/modules/$(uname -a|awk '{print $3}')/kernel/drivers/rtc/rtc-pcf2127a.ko ]; then

      echo "### WARNING - Found an old rtc-pcf2127a.ko in /lib/modules/$(uname -a|awk '{print $3}')/kernel/drivers/rtc/ - saving it as .old"

      mv /lib/modules/$(uname -a|awk '{print $3}')/kernel/drivers/rtc/rtc-pcf2127a.ko /lib/modules/$(uname -a|awk '{print $3}')/kernel/drivers/rtc/rtc-pcf2127a.ko.org

      fi

      #

      echo ""

      echo "---------------------------------------------------------------------------------"

      echo " STEP 10 - Compile modules_prepare.."

      echo "---------------------------------------------------------------------------------"

      make modules_prepare

      if [ $? -ne 0 ]; then

      echo ""

      echo "### ERROR - Make modules_prepare failed.."

      echo ""

      exit

      fi

      echo ""

      echo "---------------------------------------------------------------------------------"

      echo " STEP 11 - Compile the modules.."

      echo "---------------------------------------------------------------------------------"

      cd drivers/rtc && make -C ${SUW} M=`pwd`

      if [ $? -ne 0 ]; then

      echo ""

      echo "### ERROR - Make -C ${SUW} M=`pwd` failed.."

      echo ""

      exit

      fi

      echo ""

      echo "---------------------------------------------------------------------------------"

      echo " STEP 12 - Copying rtc-pcf2127a.ko module to /lib/modules/$(uname -a|awk '{print $3}')/kernel/drivers/rtc/"

      echo "---------------------------------------------------------------------------------"

      cp rtc-pcf2127a.ko /lib/modules/$(uname -a|awk '{print $3}')/kernel/drivers/rtc/

      if [ $? -ne 0 ]; then

      echo ""

      echo "### ERROR - Copy of the module rtc-pcf2127a.ko to /lib/modules/$(uname -a|awk '{print $3}')/kernel/drivers/rtc/ failed.."

      echo ""

      exit

      fi

      echo ""

      echo "---------------------------------------------------------------------------------"

      echo " STEP 13 - Deleting ./devel directory.."

      echo "---------------------------------------------------------------------------------"

      rm -Rf ./devel

      echo ""

      echo "---------------------------------------------------------------------------------"

      echo " STEP 14 - Running depmod.."

      echo "---------------------------------------------------------------------------------"

      depmod

      echo ""

      echo "---------------------------------------------------------------------------------"

      echo " STEP 15 - Removing dynamic iptables rule again.."

      echo "---------------------------------------------------------------------------------"

      echo "/sbin/iptables -D OUTPUT -o eth0 -j ACCEPT"

      /sbin/iptables -D OUTPUT -o eth0 -j ACCEPT

      echo ""

      echo "---------------------------------------------------------------------------------"

      echo " STEP 16 - The manual step.."

      echo "---------------------------------------------------------------------------------"

      echo " Now - You must add this to /etc/rc.local to ensure the module loads..: "

      echo ' Add the following to /etc/rc.local before exit 0

      # Referring to http://www.raspberrypi-spy.co....

      # to get the RasPi board version:

      REV=$(cat /proc/cpuinfo|grep Revision)

      # Extract revision

      REV=${REV##*: }

      # Make it readable as hex

      REV=0x$REV

      # Convert hex to dec

      REV=$((REV))

      if [ $REV -lt 4 ]

      then

      echo pcf2127a 0x51 > /sys/class/i2c-adapter/i2c-0/new_device

      echo setting rtc to i2c-0

      else

      echo pcf2127a 0x51 > /sys/class/i2c-adapter/i2c-1/new_device

      echo setting rtc to i2c-1

      fi

      ( sleep 2; hwclock -s ) &

      '

      echo "---------------------------------------------------------------------------------"

      echo " `date` end of script"

      echo "---------------------------------------------------------------------------------"

      see more
      - Keld Norman Keld Norman • 2 years ago

        PS _ i have not testet it yet.. it might not work - but it is a help to get the module build done :)

        see more
        - florin.c Keld Norman • 2 years ago

          not working for me

          # insmod /lib/modules/3.10.25+/kernel/drivers/rtc/rtc-pcf2127a.ko
          Error: could not insert module /lib/modules/3.10.25+/kernel/drivers/rtc/rtc-pcf2127a.ko: Invalid module format

          # modprobe rtc-pcf2127a
          ERROR: could not insert 'rtc_pcf2127a': Exec format error

          on dmesg got
          rtc_pcf2127a: disagrees about version of symbol module_layout

          where do i find Module.symvers for 3.10.25+ ?

          ------------------------------------------------------
          GOOD NEWS
          is pasing depmod with a rpi-update befor script wich bring me on 3.10.33+ so i can use Module.symvers: wget --no-check-certificate https://raw.github.com/raspber...

          but now in modprobe is crash the system

          see more
        - David Jagoš Keld Norman • 2 years ago

          Works great on Raspbian except I had to add --no-check-certificate to all wgets.

          For Raspbmc, add
          sed -i 's/^CONFIG_CROSS_COMPILE.*/CONFIG_CROSS_COMPILE=""/' .config
          after creating .config file, get corresponding Module.symvers (https://www.dropbox.com/s/c3dr...
          for Raspbian kernel 3.10.24) and create an upstart task script (start on started dbus) instead of running the commands in rc.local.

          see more
          - florin.c David Jagoš • 2 years ago

            i try 3.10.24 and i got:
            ERROR: could not insert 'rtc_pcf2127a': Exec format error
            rtc_pcf2127a: disagrees about version of symbol module_layout
            i try 3.10.25 and got hang at modprobe rtc-pcf2127a

            see more
            - David Jagoš florin.c • 2 years ago

              Well you need to compile it against the same verion of kernel that you're running. That means the right version of source and the right Module.symvers. The Module.symvers I linked in my post works for Raspbian kernel 3.10.24. If you try to use it with anything else, it's going to fail.

              see more
- Daniel • a month ago

  How do I get this to work on Raspberry Pi 3?

  see more
- muffin sk • 2 months ago

  Will it cover the heat sink [http://www.amazon.com/dp/B00HP...] of the CPU on Raspberry Pi 3 Model B?

  see more
- Bart • 3 months ago

  my rasclock resets after a reboot.... how can I fix this? (There is no issue with the hardware, it has a battery with 2.8V)

  see more
- CLPettigrew • 4 months ago

  Is it possible to move the pins that the clock is plugged in to? I already have stuff plugged into the first GPIO pins.

  see more
- pauljoanss • 5 months ago

  Trying to install the RasClock and really struggling, very new to all this stuff and had to look up all the change directory and edit commands.
  Using Raspbian Wheezy (I think) with a Raspberry Pi old rev 1 B, have followed instructions to Update, Upgrade, modify config file, modify hwclock-set, rebooted.
  But when using the sudo hwclock -w command I get back "cannot access the hwclock by any known method."
  Help appreciated.

  see more
  - pauljoanss pauljoanss • 5 months ago

    Very sorry, please ignore, hwclock now working ok, finger trouble when adding line to config.txt file.

    see more
- George R. Blake • 6 months ago

  We have a couple of RaspClocks we use at a University. When we turn it off, sometimes it loses time and reverts to Dec. 1969.

  Do you have a real fix for this?

  Also, I notice other clock boards have a chip that also charges the battery. Does this chip / board do this as well? If so, I will get a rechargeable battery.

  Is there a schematic I can download somewhere?

  see more
- Pedro Moutinho • 8 months ago

  When I use date command in raspberry system return correct time if it is connected to network.
  I write to RasClock using hwclock -w and read with hwclock -r and I get the correct time.
  After I reboot when I use hwclock -r command I get Thu Jan 1 00:00:05 1970.
  I use Linux raspberrypi 3.18.11+ #781 PREEMPT Tue Apr 21 18:02:18 BST 2015 armv6l.
  Any clew?

  Pedro

  see more
  - AfterthoughtSoftware Mod Pedro Moutinho • 8 months ago

    Hi Pedro,

    Could you make sure that you have done the following:

    "With Raspbian Wheezy (Release 2015-02-16 and perhaps others) you will also have to edit the file /lib/udev/hwclock-set to change the two occurrences of --systz to --hctosys"

    Thanks,
    Andy

    see more
- MartinMarty • 8 months ago

  Here I am asking for help once again. I just did an apt-get update and then upgrade on my RPi 2 running Raspbian. The Rasclock had been working fine on release 3.18.11-v7+ since the last time I posted.

  The upgrade took me to 4.1.6-v7+ and the Rasclock is inaccessible again, for example, in response to "sudo hwclock -r" I get "hwclock: cannot access the Hardware Clock via any known method" etc etc.

  Compared to before the upgrade, one thing I notice is that in the "gpio i2cd" output, on the old release the clock used to show up at address 51 as "UU" and on the new release it shows up as "51" - but it shows up - that's the important thing, right?

  I have been reviewing the doc (above on this page) at:
  http://afterthoughtsoftware.co...

  My /boot/config.txt includes the lines:

  dtparam=i2c1=on
  dtparam=i2c_arm=on
  dtparam=i2c1_baudrate=100000
  dtoverlay=pcf2127-rtc
  # device_tree=

  QUESTION: I don't seem to have the overlay file that the doc refers to, /boot/overlays/pcf2127-rtc-overlay.dtb:

  root@magpi:~# ls /boot/overlays
  ads7846-overlay.dtb piscreen-overlay.dtb
  bmp085_i2c-sensor-overlay.dtb pitft28-resistive-overlay.dtb
  dht11-overlay.dtb pps-gpio-overlay.dtb
  enc28j60-overlay.dtb pwm-2chan-overlay.dtb
  gpio-poweroff-overlay.dtb pwm-overlay.dtb
  hifiberry-amp-overlay.dtb README
  hifiberry-dac-overlay.dtb rpi-dac-overlay.dtb
  hifiberry-dacplus-overlay.dtb rpi-display-overlay.dtb
  hifiberry-digi-overlay.dtb rpi-ft5406-overlay.dtb
  hy28a-overlay.dtb rpi-proto-overlay.dtb
  hy28b-overlay.dtb rpi-sense-overlay.dtb
  i2c-rtc-overlay.dtb sdhost-overlay.dtb
  i2s-mmap-overlay.dtb spi-bcm2708-overlay.dtb
  iqaudio-dac-overlay.dtb spi-bcm2835-overlay.dtb
  iqaudio-dacplus-overlay.dtb spi-dma-overlay.dtb
  lirc-rpi-overlay.dtb tinylcd35-overlay.dtb
  mcp2515-can0-overlay.dtb uart1-overlay.dtb
  mcp2515-can1-overlay.dtb vga666-overlay.dtb
  mmc-overlay.dtb w1-gpio-overlay.dtb
  mz61581-overlay.dtb w1-gpio-pullup-overlay.dtb
  root@magpi:~#

  root@magpi:~# gpio i2cd
  0 1 2 3 4 5 6 7 8 9 a b c d e f
  00: -- -- -- -- -- -- -- -- -- -- -- -- --
  10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  20: 20 -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  50: -- 51 -- -- -- -- -- -- -- -- -- -- -- -- -- --
  60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  70: -- -- -- -- -- -- -- --
  root@magpi:~#

  Note: the device at addr 20 is an Adafruit PiPlate LCD display and 5-button module (which works fine).

  As always, all help appreciated!

  THANKS in advance,

  -Marty

  see more
  - MartinMarty MartinMarty • 8 months ago

    I don't want you people to think that the first thing I do at a hint of trouble is to post out here hollering for help. I swear I had a whole night and day into working the problem before I posted. Well, at least "worrying about" if not actually "working" the problem... ;-)

    Anyway, my solution was two config changes:

    1) In /etc/modules, comment out the line for rtc-pcf2127.

    The key to this was Afterthought's statement in http://afterthoughtsoftware.co...
    that "only a single line needs to be added to /boot/config.txt to start using it."

    2) The single line to be added to /boot/config.txt is:

    dtoverlay=i2c-rtc,pcf2127

    In looking at my files in /boot/overlays, I did not see the one that Afterthought named but I did see "i2c-rtc-overlay.dtb". Apparently they are now using a single overlay that works with a number of real-time clocks. I got this info from /boot/overlays/README (last resort, RTFM).

    I am of the opinion (i.e. did not test the theory) that these lines are still needed in /boot/config.txt to enable i2c support, but they are to enable i2c and not specific to just Rasclock:

    dtparam=i2c1=on
    dtparam=i2c_arm=on

    After making these changes and rebooting, my Rasclock is accessible again. Also the output from "gpio i2cd" changed back to "UU" for the RTC module at address 51.

    see more
    - AfterthoughtSoftware Mod MartinMarty • 8 months ago

      Hi Marty,

      Thanks for the information, I wasn't aware of the generic rtc overlay file. I've added this to our page above.
      Thanks again,
      Andy

      see more
- MartinMarty • a year ago

  Is the Rasclock supposed to work with other devices on the i2c bus concurrently? i.e. I have the Adafruit Pi Plate LCD display module #1115 https://www.adafruit.com/produ... connected via i2c and it works fine until I connect the rasclock, at which point it is no longer accessible (and it no longer appears in response to "gpio i2cd"). Without the display connected, the clock seems to work (I can do hwclock -r) but it does not appear in "gpio i2cd". I am on a RPi 2 running Raspbian kernel 3.18.11-v7+.

  I thought I could have multiple i2c devices attached as long as they were on their own address, but the Rasclock not showing up in "gpio i2cd" raises a red flag.

  Advice appreciated.
  THANKS!
  -Marty

  p.s. Physically, I have the SDA and SCL lines connected to the display and clock in parallel. Is this correct?

  see more
  - MartinMarty MartinMarty • a year ago

    Sorry, my mistake once again. I still had some "hacks" in place from my resolution to the problem I had with the 3.18.7+ kernel that I posted about a few months ago. These were apparently messing me up. I have it "pretty much" working now, Rasclock AND Adafruit LCD display. Here is what I ended up with:

    1) In /boot/config.txt, removed my device_tree= line (now we want to use device tree) and added:
    dtparam=i2c1=on
    dtparam=i2c_arm=on
    dtoverlay=pcf2127-rtc
    # device_tree=

    2) In /lib/udev/hwclock-set: edited 2 occurrences of "--systz" to "--hctosys"

    3) In /etc/rc.local, commented OUT the three RTC-related lines I was using previously:
    # echo pcf2127 0x51 > /sys/class/i2c-adapter/i2c-1/new_device
    # sleep 2
    # hwclock -s

    4) In /etc/modules. added i2c-dev, giving:
    i2c-bcm2708
    i2c-dev
    rtc-pcf2127

    5) In /etc/modprobe.d/raspi-blacklist.conf, commented OUT:
    # blacklist spi-bcm2708
    # blacklist i2c-bcm2708

    After rebooting, my i2c devices now show up as follows, x20 is the display and x51 is the clock:

    root@mypi:~# gpio i2cd
    ...... 0 1 2 3 4 5 6 7 8 9 a b c d e f
    00: -- -- -- -- -- -- -- -- -- -- -- -- --
    10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
    20: 20 -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
    30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
    40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
    50: -- UU -- -- -- -- -- -- -- -- -- -- -- -- -- --
    60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
    70: -- -- -- -- -- -- -- --

    The reason I said "pretty much" working is because I am still having a heck of a time with the display behaving badly but I think it is because of my wiring. I am using a 40-pin ribbon cable to a cobbler to a solderless breadboard and then jumper wires to the clock and another set to the display. Bad corruption frequently occurs on the display. If I hold the SCL wires tightly together with my fingers rather than run them through the breadboard, the corruption lessens. I'm hoping that if everything were soldered the problem would go away. I suspect that because the serial communication is so fast, that the slightest imperfection is interfering with it. At least that is my current theory.

    References:
    https://learn.adafruit.com/ada...
    http://afterthoughtsoftware.co...

    see more
    - AfterthoughtSoftware Mod MartinMarty • a year ago

      Hi Marty,
      Glad you've sorted it out. You're correct that the "old" way of setting up RasClock in rc.local should be removed when using the device tree method.
      All the best,
      Andy

      see more
- Bob • a year ago

  I just tested this with RPi 2, with a fresh 2015-05-05-raspbian-wheezy image.
  It booted into the RPi setup tool.
  In the advanced settings I enabled Device Tree and I2C.
  After reboot, I added "dtoverlay=pcf2127-rtc" to the end of /boot/config.txt like it says above.
  I rebooted again and typed sudo hwclock and it showed the correct time.
  I unplugged the Ethernet cable and powered down. When I rebooted the Raspberry desktop showed the correct time and sudo hwclock showed the correct time too.
  nice work!

  see more
- CanAssist • a year ago

  Hi,

  I bought the RasClock and tried to install on the Raspberry Pi 2 running Raspbian. I followed all the instructions under `Latest kernel support` (updated on 22nd October 2013) but something weird occurs every time I reboot the system.

  When I reboot the RPi 2 with the RasClock, it does not matter which date I have written on it, it resets the date and time to the beginning of Epoch Time (Thu, Jan 1 00:00:00 UTC 1970).
  If I reboot the RPi 2 without the RasClock, sometimes it says nothing, and other times it keeps generating error messages until I place the RasClock on the board again.

  The one time it said nothing, I plugged the RasClock on the board and I could `hwclock -r` the correct time which I've had previously set (proving the RasClock is working properly) but the 'date' on the system was still Jan 1st 1970.

  On the other hand, whenever I place the RasClock while generating error messages, the RasClock date and time are reset to the Epoch time again.

  The error messages always come in pair, the first one always being `set_datetime`. These are some examples (usually starting at [20.000000] ):

  [60.726771] rtc-pcf2127 1-0051: pcf2127_set_datetime: err=-5
  [60.744870] rtc-pcf2127 1-0051: pcf2127_get_datetime: read error
  [61.726753] rtc-pcf2127 1-0051: pcf2127_set_datetime: err=-5
  [61.745305] rtc-pcf2127 1-0051: pcf2127_get_datetime: read error

  The weird thing is that the `set_datetime` is always called before the `get_datetime`.

  Does anyone knows what is happening there and how to solve it?

  Obs: I do not have fake-hwclock.

  Thank you

  see more
- Junin Mascarenhas • a year ago

  Hi guys from Afterthought. Recently I was trying to develop a code in java to work with some sensors, e.g. DHT11 but I could'n get any data, because this sensor needs to wait microseconds (TimeUnit.MICROSECONDS.sleep(40)) and as I saw here (http://docs.oracle.com/javase/... "sleep and join are dependent on the OS for timing, so you should NOT assume that sleep will wait exactly as long as you specify". here (http://en.wikipedia.org/wiki/R... says that RPI does not come with a real-time clock. My question is, with RasClock will I be able to get it work?

  If yes, just I neet to install and setup it, following this guide ad I'll be able to get data from the sensor?

  Thanks for the attention.

  see more
  - AfterthoughtSoftware Mod Junin Mascarenhas • a year ago

    A real time clock is used to keep track of the wall-clock time and remember it when the device is powered off, it won't help with high accuracy timing requirements. The Raspberry Pi should work with the DHT11 without an RTC, e.g. https://learn.adafruit.com/dht...

    see more

Load more comments

## Also on Afterthought Software

- ### Storing media URIs using Android SQLite

  - 1 comment
  - 2 years ago

  shubham — can u provide source code for this if yes then please send it to shubhamsharma1318@gmail.com

- ### Combe Clock

  - 2 comments
  - 3 years ago

  GTFOBigGovt — No black and white is better for older people especially with macular degeneration.

- ### Afterthought Software

  - 8 comments
  - 4 years ago

  Vishal Mehta — Still not working! I detailed the question here, just in case you can help find the solution …

- ### Using adb with Wileyfox Swift

  - 2 comments
  - 7 months ago

  AfterthoughtSoftware — Hi Steve, My first assumption is that you are using Linux. If you run "lsusb" you should …