User Tools

Site Tools


setting_up_the_master_umd

Setting up the Master UMD




Master Raspberry Pi


The primary Raspberry Pi does a little more than the others. As well as writing to the LCD display, this unit has a web server (Apache) and PHP running. The web server hosts a text file (my_data.txt) that is hosted and is editable via a web interface and PHP.
For this to work we need the following installed and configured


Set Static IP Address


To set a static IP address, we need to login to the RPi via SSH and change the following file:

The default login is username: pi and password: raspberry (if this is an existing unit that is misbehaving, the login will be pi and Ericss0n)

  /etc/dhcpcd.conf


Enter the following

  sudo nano /etc/dhcpdc.conf
  
  Add these lines to the end of the file (default is dhcp) using your own IP Address details
  
  eth0
  static ip_address=192.168.1.11/24
  static routers=192.168.1.1
  static domain_name_servers=192.168.1.4


Use Ctrl-X to exit and Y to save, now reboot the pi and connect to the new address


Raspi Config


From the terminal, run:

  sudo raspi-config


You will see the following menu, there are several items we want to change here.

┌────────────────────┤ Raspberry Pi Software Configuration Tool (raspi-config) ├───────────────────────────┐
│                                                                                                          │
│     1 Expand Filesystem            Ensures that all of the SD card storage is available to the           │
│     2 Change User Password         Change password for the default user pi)                              │
│     3 Boot Options                 Choose whether to boot into a desktop environment or the command line │
│     4 Wait for Network at Boot     Choose whether to wait for network connection during boot             │
│     5 Internationalisation Options Set up language and regional settings to match your location          │
│     6 Enable Camera                Enable this Pi to work with the Raspberry Pi Camera                   │
│     7 Add to Rastrack              Add this Pi to the online Raspberry Pi Map (Rastrack)                 │
│     8 Overclock                    Configure overclocking for your Pi                                    │
│     9 Advanced Options             Configure advanced settings                                           │
│     0 About raspi-config           Information about this configuration tool                             │
│                                                                                                          │
│                                                                                                          │
│                             <Select>                                   <Finish>                          │
│                                                                                                          │
└──────────────────────────────────────────────────────────────────────────────────────────────────────────┘


Select Option 2 (Change User Password) - Change the password to Ericss0n
Select Option 3 (Boot Options) - Change to B2 Console Autologin Text console, automatically logged in as 'pi' user
Select Option 9 (Advanced) then A2 (HostNane) - Change the Hostname to UMD00n (where n is the display number)
Select Finish when asked to reboot select Yes


Update RPI


Even if you downloaded the latest version of Raspbian, chances are there are some updates. To update the RPi use the following command line:

  sudo apt-get update && sudo apt-get upgrade -y 


This will most likely take a few minutes on a new install.


Install PHP


We need to install PHP so that the web interface will function. To install PHP use the following command line:

  sudo apt-get install php5


There is no PHP7 for RPi yet, but version 5 will be fine.


Install Apache Webserver


Apache is the Web Server that will host our website.

  sudo apt-get install apache2


This may already exist, if so this will also update it.


Configure Apache Webserver


We have to configure Apache Webserver, mainly so that Apache knows where our site is located. There are two files we need to edit, and they are:

  • /etc/apache2/apache2.conf
  • /etc/apache2/sites-enabled/000-default.conf


Before we begin this process, create a folder in your home location called Python and give Apache rights:

  mkdir /home/pi/Python
  
  sudo chmown www-data /home/pi/Python
  sudo chmod 777 /home/pi/Python


We need to copy the website to the /home/pi/Python location, for the Mater there are five files:

  • bootstrap.min.css - This is a style sheet that controls the look of the site
  • index.php - The main site for entering text (this is what Apache will host)
  • launchUMD.sh - A script to auto start the UMD at boot
  • my_data.txt - This holds the LCD data text, and is edited by the index.php
  • UMDisplay01.py - The Python code that runs the LCD


These files need to be copied to the /home/pi/Python location

sudo chmod 777 /home/pi/Python/my_data.txt or Apache might have trouble writing to it.

sudo chmod 777 launchUMD.sh

sudo chmod 777 UMDisplay01.py

Apache2.conf


Open and edit the /etc/apache2/apache2.conf file and add these lines:

<Directory /home/pi/Python>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
</Directory>


Save the file and exit.

000-default.conf


Open /etc/apache2/sites-enabled/000-default.conf, locate the following lines and edit as follows

        ServerAdmin webmaster@localhost
        DocumentRoot /home/pi/Python
        DirectoryIndex index.php


Now reboot the RPi

  sudo reboot




Edit index.php


We need to change one line in the index.php, this is the IP Address. This address is the current IP your eth0 has (or the website will not format correctly).

  sudo nano /home/pi/Python/index.php
  
  look for these lines
  
  <link rel="stylesheet" type="text/css"
          href="http://ipaddress/bootstrap.min.css">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  
  Add your master PI IP address where is states ipaddress


Save and close this file.


Give Execute Permissions


There are two files that will be executed by the Pi, these are:

  • launchUMD.sh - Autorun at boot, this file launches the UMDisplay01.py
  • UMDisplay01.py - Runs the LCD


To make these files executable run the following from the command line:

  sudo chmod 777 /home/pi/Python/launchUMD.sh
  sudo chmod 777 /home/pi/Python/UMDisplay01.py


We should be in a position to test the Pi out now.


Test Web Server


To test the webserver, navigate to your RPi from another computer on the same network, you should see your webpage.
http://youripaddress/index.php

If all is well, you should see a website that looks a bit like the one above. Remember that the text comes from the file /home/pi/Python/my_data.txt so you can check that file if you are unsure.


Test LCD Code


Assuming that you have connected the LCD to the RPi (via the ribbon cable and driver board) then you can test the code that runs the LCD, on the master this file is the:

  UMDisplay01.py


This is a python script, you can run this script by entering at the command line:

  ./UMDisplay01.py


If you are lucky, you will see some text on the LCD, chances are however you will not. This is due to the Potentiometer settings on the driver board, you will need to change these to set the Backlight and LCD intensity.



Adjusting these two potentiometers will allow you to balance the text and backlight intensity to get the brightness level you require.


Making it Automatic


The last part is to automate the process of starting the UMD code. For this we need to add the launcher file to a system file on the RPi.

Edit the file /etc/rc.local to automate this process.

  sudo nano /etc/rc.local
  
  add this line at the end:
  sudo ./home/pi/Python/launchUMD.sh


To test this, reboot and the LCD should start up automatically (the LCD won't clear on boot, but wait for the “Waiting for 5 Seconds for Network Start” message).

setting_up_the_master_umd.txt · Last modified: 2023/03/09 22:35 by 127.0.0.1