Display Time & IP on Every Boot

It's all fine and dandy to have a script which we can manually run, but wouldn't it be nice to have the time and ip address pop up on the display when the Raspberry Pi boots up? This is done using an init script which runs our Python code every time your Raspberry Pi boots up. 

Download the service file

The following command will allow you to download the lcd.service file directly to your Pi.

Download: file
$ wget https://raw.githubusercontent.com/adafruit/Adafruit_Learning_System_Guides/master/Drive_a_16x2_LCD_with_the_Raspberry_Pi/lcd.service
[Unit]
Description=LCD date|time|ip
Requires=network-online.target
After=network-online.target

[Service]
ExecStart=/usr/bin/python3 Drive_a_16x2_LCD_with_the_Raspberry_Pi.py
WorkingDirectory=/home/pi
StandardOutput=inherit
StandardError=inherit
Restart=always
User=pi

[Install]
WantedBy=network-online.target

Place the lcd.service file

The lcd.service file needs to be copied into the correct location and the systemctl command can be used to start | stop | enable the service. It is a good idea to test this before enabling as there might be a minor path difference on your system. 

Download: file
$ sudo cp lcd.service /etc/systemd/system

Test the lcd.service

Download: file
$ sudo systemctl daemon-reload
$ sudo systemctl start lcd.service
$ ps auxww | grep -i 16x2

The following commands read the updates to the service file, start the lcd.service and confirm that the process is running. If the script shows up in the 'ps' command output you have done everything correctly and can now enable the service and reboot. The service should activate upon bootup automatically.

Enable lcd.service

Download: file
$ sudo systemctl enable lcd.service

Now on each boot the LCD will automatically show the date/time/ip address on startup. This means you will know when the Pi is reachable and what the ip address is without having to plug a monitor in.

This guide was first published on Aug 17, 2012. It was last updated on Aug 17, 2012. This page (Display Time & IP on Every Boot) was last updated on Jul 17, 2019.