Raspberry Pi with RTC installed

all about Meteohub on the new Raspberry PI platform

Moderator: Mattk

Post Reply
User avatar
MJC55
Junior Boarder
Junior Boarder
Posts: 29
Joined: Fri Mar 27, 2009 6:24 am
Location: Washington State

Raspberry Pi with RTC installed

Post by MJC55 »

I have a new Raspberry Pi 3 that I am planning on using for my meteohub setup. My aging ALIX.3D2 is starting to give me problems so I think it's time to retire it. When I installed the RTC Raspian-Jessie had to be configured for the RTC to work on the Pi. If I use the Pi for meteohub will it detect the RTC and support it? Also my weather station (Vantage Pro2 Plus) has a serial RS-232 which in I will be using a serial-usb adapter. Does meteohub have drivers which will support the adapter? Thank you.
User avatar
admin
Platinum Boarder
Platinum Boarder
Posts: 7854
Joined: Mon Oct 01, 2007 10:51 pm

Re: Raspberry Pi with RTC installed

Post by admin »

no, will need some scripting on your own.
BigAlT
Gold Boarder
Gold Boarder
Posts: 198
Joined: Tue Jul 04, 2017 8:41 pm
Location: Washington State

Re: Raspberry Pi with RTC installed

Post by BigAlT »

I successfully installed an RTC on my Raspberry PI 2 with Meteohub loaded ( I've also installed it on an RPI 3B with Meteohub loaded and it also works fine ) by doing the following. As usual YMMV so backup every thing before trying.

Login to your Meteohub ( which you've already loaded and installed on the micro SD card in your RPi ) using an ssh client. Login is root@ip address of your Meteohub on your network. Password is meteohub .
Then enter apt-get update <return>
Then enter apt-get install dist-upgrade <return>
Then enter apt-get install sudo <return>
Then enter sudo nano /etc/modules <return>
add these two lines to the end of the file:
i2c-bcm2708
I2c-dev
Then save the file with Control-X then Y <return>
you will also need to update the /boot/config.txt file. Edit it by entering sudo nano /boot/config.txt <return> and add this text at the end of the file :
dtparam=i2c1=on
dtparam=i2c_arm=on
note that the "1" in "i2c1" is a one not an L!
You also need to add the text of whichever matches your RTC chip:

dtoverlay=i2c-rtc,ds1307

Or

dtoverlay=i2c-rtc,pcf8523

Or

dtoverlay=i2c-rtc,ds3231

to the end of the file

Then save the file with Control-X then Y <return>

Then enter sudo apt-get install python-smbus i2c-tools<return>

Then enter sudo nano /lib/udev/hwclock-set <return>and comment out these three lines by adding a # in front so that they look like this:

#if [ -e /run/systemd/system ] ; then

#exit 0

#fi

Then save the file with Control-X then Y <return>

Then enter sudo reboot < return>

After the reboot login again to your meteohub via ssh as before.

You can check that your rtc is running and has the correct time by entering the command sudo hwclock -r <return>

If all looks good exit ssh by entering exit <return>
RickNY
Junior Boarder
Junior Boarder
Posts: 30
Joined: Tue Aug 13, 2013 9:11 pm

Re: Raspberry Pi with RTC installed

Post by RickNY »

BigAlT wrote: Tue Jul 04, 2017 8:54 pm I successfully installed an RTC on my Raspberry PI 2 with Meteohub loaded ( I've also installed it on an RPI 3B with Meteohub loaded and it also works fine ) by doing the following. As usual YMMV so backup every thing before trying.
Out of curiosity -- does this survive Meteohub updates, or does it have to be added each time?

Thanks,
Rick
BigAlT
Gold Boarder
Gold Boarder
Posts: 198
Joined: Tue Jul 04, 2017 8:41 pm
Location: Washington State

Re: Raspberry Pi with RTC installed

Post by BigAlT »

It does survive as it modifies the OS rather than the Meteohub program itself.
RickNY
Junior Boarder
Junior Boarder
Posts: 30
Joined: Tue Aug 13, 2013 9:11 pm

Re: Raspberry Pi with RTC installed

Post by RickNY »

BigAlT wrote: Tue Jul 04, 2017 8:54 pm( I've also installed it on an RPI 3B with Meteohub loaded and it also works fine
I had zero luck with this with the RPI 3B I received today along with a DS3231 RTC module.. With a fresh Meteohub install from image and then updated to 5.0v..

The first thing that failed was apt-get install dist-upgrade....

Also - the lines you mentioned in /lib/udev/hwclock-set did not exist on my Meteohub install
RickNY
Junior Boarder
Junior Boarder
Posts: 30
Joined: Tue Aug 13, 2013 9:11 pm

Re: Raspberry Pi with RTC installed

Post by RickNY »

OK... I have it working.. There were only two things I had to do.. I have a DS3231... This is what I did:

1) SSH in to Pi.. root/meteohub
2) nano /boot/config.txt
3) Added dtoverlay=i2c-rtc,ds3231 to end of file, CTRL-X - Yes to save
4) nano /etc/adjtime
5) There is a Debian bug here where there is a missing CR after UTC at the end of the file. Hit enter after UTC, then save the file
6) Reboot


root@METEOHUB:~# hwclock -r
Tue Jul 25 21:06:35 2017 -0.711947 seconds

Dmesg shows:
[ 3.381371] rtc-ds1307 1-0068: rtc core: registered ds3231 as rtc0

I did not mess with upgrading anything at the core OS level with apt-get.. Just the Meteohub RPI image, and then updated through its GUI to 5.0v.
BigAlT
Gold Boarder
Gold Boarder
Posts: 198
Joined: Tue Jul 04, 2017 8:41 pm
Location: Washington State

Re: Raspberry Pi with RTC installed

Post by BigAlT »

I installed a DS3231 module on 2 seperate 3B's. On one, the first time I tried the apt-get install dist upgrade it failed. I tried it again and it worked. When I first did the mod on the 2B I first tried to install sudo ( which is needed to make the mods ) and got an error message that I needed to do an update. That's why I did the update and then the upgrade. I never tried installing sudo after doing the update but not then doing the upgrade first. The lines that are in the hwclock file may have been added during the upgrade.
RickNY
Junior Boarder
Junior Boarder
Posts: 30
Joined: Tue Aug 13, 2013 9:11 pm

Re: Raspberry Pi with RTC installed

Post by RickNY »

I toyed around some more with this.. Eventually got the dist-upgrade to work (after doing an update and upgrade, followed by reboot)

Curious about the need for sudo -- youre logging in as root, why do you need sudo?

I did discover that on boot, the RTC is reporting an invalid date and not retaining the time so I'm not fully done yet..

I made the mistake of messing with this remotely from work, without a console serial cable and instead using the Ethernet connection to the pi.. Naturally at some point, a reboot took down the network and wont recover until I get back home to see whats going on.
BigAlT
Gold Boarder
Gold Boarder
Posts: 198
Joined: Tue Jul 04, 2017 8:41 pm
Location: Washington State

Re: Raspberry Pi with RTC installed

Post by BigAlT »

I got the info on how to do the mods from the adafruit instructions on installing i2c support manually ( since the version of Wheezy used by Meteohub doesn't have raspi-config installed ) and then their Instructions on adding an RTC. They used the sudo command so I thought it was necessary. I never tried it without sudo.
RickNY
Junior Boarder
Junior Boarder
Posts: 30
Joined: Tue Aug 13, 2013 9:11 pm

Re: Raspberry Pi with RTC installed

Post by RickNY »

OK... Now, I have it working right... This is on RPI 3.. This is what I ended up doing.. Ended up having to start from scratch from a new image.

1) Login as root via SSH and run apt-get update && apt-get upgrade
2) At some point, a screen will apear regarding smbd.conf -- I chose to keep existing configuration
3) After that was done, issued reboot
4) When it came back up, ran apt-get dist-upgrade -- this found nothing
5) Did not need to change anything with /etc/modules
6) Added the following to /boot/config.txt:

Code: Select all

dtparam=i2c_arm=on
dtoverlay=i2c-rtc,ds3231
7) Needed to edit /etc/init.d/hwclock.sh to comment out the below lines:

Code: Select all

#           if [ -d /run/udev ] || [ -d /dev/.udev ]; then
#               return 0
#           fi
8) Performed apt-get install python-smbus i2c-tools
9) Rebooted

To test, I performed a shutdown of the RPI... Created a firewall rule to disable external internet access to it.. Removed the power plug and waited about 10 minutes.. Plugged it back in, logged in via SSH as root and performed hwclock -r and the clock was still set to the proper time, and there were no warnings in Meteohub logs complaining of invalid date format.

Rick
Post Reply