2.8" TFT + Touch Shield + DS1307 RTC
Posted: Sun Feb 09, 2014 9:20 am
Setup instructions for this new design based on my 2.8" TFT, but with a DS1307 RTC option.

First, setup the screen and touch panel by following the instructions here :
http://www.raspberrypi.org/phpBB3/viewt ... 45&t=64993
Then to setup the RTC :
If possible ensure a valid internet connection is made on the Pi to get an accurate time and date. Also fit a CR2032 lithium battery in order to maintain correct time and date on power loss to the Pi.
The DS1307 is an I2C device, so that bus needs to be enabled. Edit the /etc/modules file
Add
before the
line.
Then remove the i2c-bcm2708 line from the blacklist file
put a # in front of the
line and save it.
Install the python-smbus package
This will also install the i2ctools package as a dependency.
At this point reboot the pi
After the restart check the pi can see the ds1307
for Rev 2 Pi's
or for Rev 1 Pi's
and the following should be reported
Note the '68' detected is the ds1307.
Now that the i2c bus is set up, we need to load the driver for the ds1307
We need to be root to do the next bit
then
If you then
again you should see
Notice the 'UU' at address 68 - this means that the ds1307 is under control of the driver. To test this use
If there is no valid internet connection to the Pi, the time may not be correct and it will need to be set manually.
Once the system time is correct it can be written to the ds1307 with
You should then get the correct time and date with
In order to load the ds1307 module upon a reboot of the Pi you'll need to add it to /etc/modules
and enter
after the i2c-dev line you entered earlier.
Then the ds1307 device needs creating by adding it to the /etc/rc.local file
and adding
for a Rev 2 Pi, or
for a Rev 1 Pi before the
Power off the Pi, leave it off for a while, then repower it and check the time and date are still correct.
Texy

First, setup the screen and touch panel by following the instructions here :
http://www.raspberrypi.org/phpBB3/viewt ... 45&t=64993
Then to setup the RTC :
If possible ensure a valid internet connection is made on the Pi to get an accurate time and date. Also fit a CR2032 lithium battery in order to maintain correct time and date on power loss to the Pi.
The DS1307 is an I2C device, so that bus needs to be enabled. Edit the /etc/modules file
Code: Select all
sudo nano /etc/modules
Code: Select all
i2c-bcm2708
i2c-dev
Code: Select all
ads7846_device swap_xy=1 gpio_pendown=17 x_plate_ohms=100 pressure_max=255
Then remove the i2c-bcm2708 line from the blacklist file
Code: Select all
sudo nano /etc/modprobe.d/raspi-blacklist.conf
Code: Select all
blacklist i2c-bcm2708
Install the python-smbus package
Code: Select all
sudo apt-get install python-smbus -y
At this point reboot the pi
Code: Select all
sudo reboot
Code: Select all
sudo i2cdetect -y 1
or
Code: Select all
sudo i2cdetect -y 0
and the following should be reported
Code: Select all
[email protected] ~ $ sudo i2cdetect -y 1
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- UU -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- 68 -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
Now that the i2c bus is set up, we need to load the driver for the ds1307
Code: Select all
sudo modprobe rtc-ds1307
Code: Select all
sudo bash
Code: Select all
echo ds1307 0x68 > /sys/class/i2c-adapter/i2c-1/new_device
exit
Code: Select all
sudo i2cdetect -y 1
Code: Select all
[email protected] ~ $ sudo i2cdetect -y 1
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- UU -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- UU -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
Code: Select all
sudo hwclock -r
Once the system time is correct it can be written to the ds1307 with
Code: Select all
sudo hwclock -w
Code: Select all
sudo hwclock -r
Code: Select all
sudo nano /etc/modules
Code: Select all
rtc-ds1307
Then the ds1307 device needs creating by adding it to the /etc/rc.local file
Code: Select all
sudo nano /etc/rc.local
Code: Select all
echo ds1307 0x68 > /sys/class/i2c-adapter/i2c-1/new_device
sudo hwclock -s
Code: Select all
echo ds1307 0x68 > /sys/class/i2c-adapter/i2c-0/new_device (v2 raspberry pi)
sudo hwclock -s
line.exit 0
Power off the Pi, leave it off for a while, then repower it and check the time and date are still correct.
Texy