There are plenty of articles on the installation of a DS1307 RTC module.

There are equally as many articles listing various installation/configuration problems.

The basic hardware issues relates to signal voltage difference on I2C bus, the Pi uses 3.3V whereas the DS1307 module uses 5V. You may decide to remove the pulp resistors from the DS1307.
Same DS1307 modules cater for both, a CR2032 battery and a rechargeable battery. You may have to remove the charge resistor if you are using a non-rechargeable battery. 

The article describes the configuration steps for systemd based Raspbian (not Wheezy or anything earlier)
Thanks to KD8TWG and Adafruit for some of the information shown on this page.

Step 1 - edit /boot/config.txt and add


You should also ensure that the I2C bus is enabled (dtparam=i2c_arm=on) in config.txt.

Step 2 - execute "i2cdetect -y 1"

You should see "UU" at address 0x68. you may also see "50" if the RTC module contains an EEPROM chip.

Step 3 - disable fake hwclock

apt-get -y remove fake-hwclock
update-rc.d -f fake-hwclock remove
systemctl disable fake-hwclock

Step 4 - change /lib/udev/hwclock-set by commenting out the following lines:

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

also comment out these lines: 

#/sbin/hwclock --rtc=$dev --systz --badyear
#/sbin/hwclock --rtc=$dev --systz 

Step 5 - timesyncd service which must be disabled or the system clock will not be synced to RTC module on boot.

systemctl stop systemd-timesyncd.service
systemctl disable systemd-timesyncd.service

To set the correct time:

Sync system time (e.g. via ntp)
then use "hwclock -w" to write system time to RTC module

The RTC clock can be read at any time with "hwclock -r" and the system time can be synced to the RTC time with "hwclock -s".

For more information on the hwclock command: "man hwclock"



The Official Raspberry Pi 7" Touchscreen is very cost effective device which can turn a RaPi into a very sophisticated GUI for all sorts of home projects.

This article is about using the touchscreen as a dedicated interface to home-brew code on a head-less RaPi, that is, a Pi which does not utilise the X-Windows GUI.

A ready-to-compile repository is available here.

After a bit of research I have found a great library which provides elegant user interface objects, it's called LittlevGL and comes free of charge. The library is written in C and designed to work with embedded devices. Here is a link to the library website.

The library comes with pretty good install instructions and it's easy to get the demo graphics to display.

The documentation is located here.

The LCD interface of the screen is connected to the onboard DSI connector and the driver is already part of Raspbian. LittlevGL uses the frame buffer device /dev/fb0 to drive the screen. 
The touch interface is connected to the RaPi via I2C interface but Raspbian provides the hardware level interface and presents the touch events at /dev/input/event0.

The config files need the following changes:

Near the top of the various config files you will need to change:

#if 0


#if 1

This will step is required in each of the config files.


#define LV_HOR_RES (800)
#define LV_VER_RES (480)
#define LV_COLOR_DEPTH 32 

lv_drv_config.h add the following lines somewhere near the top of the file:

#define USE_FBDEV 1
#define USE_EVDEV 1


#define USE_LV_DEMO 1

Since the upgrade to LVGL V7 you will also need to configure and initialise the display buffer:

#define DISP_BUF_SIZE 384000;   // 480x800
static lv_disp_buf_t dispatch_buf;
static lv_color_t buf1[DISP_BUF_SIZE];
static lv_color_t buf2[DISP_BUF_SIZE];
lv_disp_buf_init(&disp_buf, buf1, buf2, DISP_BUF_SIZE];

It is important that the buffer is fully initialised before display driver initialisation.

lv_disp_drv_t disp_drv;
disp_drv.buffer = &disp_drv;
disp_drv.flush_cb = fbdev_flush;
lv_disp_t *disp;
disp = lv_disp_drv_register(&disp_drv);

This should sufficient to get the screen output working. First with the "Hello World" example and then with the demo_create() function. 
To get touch input working add the following lines after lv_init() in main().

lv_indev_drv_t indev_drv;
indev_drv.type = LV_INDEV_TYPE_POINTER; = evdev_read;

The porting guide provides some information on adding touch input.

With those modifications the touch screen should now be functional.

One final step is required to eliminate the blinking cursor which keep re-appearing on the screen:

add the following into /boot/cmdline.txt



Many of my RaPi's are configured for a daily reboot to increase reliability. Despite many precautions and care being taken during coding some programs (including mine) suffer from [minor] memory leaks. Whilst these leaks don't cause any immediate issues, if the are run for months/years without restarting they have the potential to bring the system down or compromise functionality/security.

There are a number of different ways to configure cron for a reboot, I have found this method the neatest and cleanest:

Create a file named "mycron" (or whatever your like) in the /etc/cron.d/ folder. 

sudo nano /etc/cron.d/mycron

Paste the following lines in the file:

# m h dom mon dow user command
15  2 * * * root /sbin/shutdown -r now

Save the file with Ctrl-O and then exit with Ctrl-X.

There is no need to reboot or restart cron, the new file will be picked up automatically on the next cron run.
Reboot will occur daily at 2:15AM.

A selection of commands to manage services from Raspian/Debian Jessie onwards:

Print active services:

sudo systemctl list-units -t service

Print all services:

sudo systemctl list-units -t service --all

Print status of a single service:

sudo systemctl status cron

Start/Stop/Restart/Reload service:

sudo systemctl start ssh
sudo systemctl stop ssh
sudo systemctl restart ssh
sudo systemctl reload ssh

Enable/Disable service:

sudo systemctl enable ssh
sudo systemctl disable ssh

Help is available via man systemctl

Note: Pre Jessie (e.g. Wheezy) was using "service myservice start", "service myservice stop", "update-rc.d myservice defaults", etc.


Credit to Milosz Galazka

Git code repository is required by other installation procedures:

sudo apt-get install git

Apple File Protocol to provide file access via network:

sudo apt-get install netatalk