Home‎ > ‎Home Alarm System project‎ > ‎Installation‎ > ‎

Install the LCD Software

Project Description

In this project you will learn how to connect an LCD panel to your PrivateEyePi system. The software we supply for this project currently has the following features:

  • Real time display of sensor activity
  • Real time display of temperature and humidity. All temperature sensors are supported (DS18B20, DHT22 and all wireless temperature and humidity sensors). There are two modes for this:
    1. Temperature readings are displayed for 10 seconds each in a rotating loop
    2. Temperature readings are displayed whenever a reading is taken
  • The LCD can be connected to a remote Raspberry Pi so you can put the LCD panel anywhere where there is a network connection (including wifi). You can have as many LCD panels (1 per Raspberry Pi) as you want. 

What you need

  • A working LCD panel connected to your Raspberry Pi. If you don't have an LCD connected to your Raspberry Pi then follow this tutorial first.

Build instructions

1. Upgrade or install to the latest PrivateEyePi software by following this tutorial. If you are going to use multiple Raspberry Pi's then install the software on all Raspberry Pi's.

2. Edit globals.py on the Raspberry Pi that is connected to your sensors:
At the Raspberry Pi command prompt type:

cd /home
sudo nano globals.py

Page down until you see the following section:
#Configure an LCD panel here
LCDTemperature=False
LCDAlarmActivity=False
LCDChime=False
lcd_ip="127.0.0.1"

Set LCDTemperature=True if you want the LCD to display temperature and humidity readings.

Set 
LCDAlarmActivity=True if you want the LCD to display alarm activity.

The LCDChime function is future functionality where you can have a remote chime.

Save and exit globals.py by pressing
ctrl-x, followed by y followed by enter.
      
3. Now you need to install some messaging software that will allow the various sensor programs (e.g. alarm.py, dallas.py,rfsensor.py and dht22.py etc..) to send messages to be displayed on the LCD panel.

If you are going to use multiple Raspberry Pi's then you need to run these commands on all the Raspberry Pi's. At command prompt enter the following commands:

sudo apt-get install python-pip
sudo apt-get install mosquitto
pip install paho-mqtt

4. The last step is to configure a python program subscribe.py that will receive the LCD messages and control the LCD display. Edit subscribe.py and configure the IP Address of the Raspberry Pi connected to your sensors.

sudo nano subscribe.py

Close to the top of the program you will see these lines:

broker_ip="127.0.0.1"
cycle_temperature = True
PrintToScreen = False
button_gpio=4 
num_saved_logs = 10
lcd_type=1 # 1=HD44780, 2=Nokia

broker_ip="127.0.0.1" is the IP address of the Raspberry Pi that is connected to your sensors. If you have your sensors and LCD connected to the same Raspberry Pi then leave this setting at 127.0.0.1, otherwise change it to the IP address of the Raspberry Pi connected to your sensors.

TIP: If you don't know the IP address then use the 
ifconfig command on the Raspberry Pi connected to your sensors and look for it under either the WLAN or ETH0 sections.

cycle_temperature=true means that any temperature readings sent to the LCD will be displayed in a cycle at 10 seconds per reading.  If you want to change the interval to something else them look for this line towards the bottom of subscribe.py:

if (elapsed_time > 10 and cycle_temperature):

You can configure the display interval for temperature readings by changing the 10 in the above line which is in seconds. 

button_gpio=4 is the BCM Format GPIO pin that the button is connected to. You will need to install a button to scroll through the log. The log contains alarm activity (e.g. door open/door close), alarm armed/disarmed, and any alarms that occurred. 

num_saved_logs = 10 are the number of logs you want the LCD to display.

lcd_type=1 is for the HD44780 LCD. Set it to lcd_type=2 if you are using the Nokia LCD.

Save and exit subscribe.py by pressing 
ctrl-x, followed by y followed by enter.

Now make sure subscribe.py runs OK.

sudo python subscribe.py

It will not do anything other than sit at the command prompt. If you see any errors then check preceding steps. Once it is running OK you can press ctrl-c to exit the program. 

subscribe.py needs to run as a background service. For users that have configured the alarm system or temperature sensors you would have done this before, but if this is your first build then make sure you have completed this tutorial first.

Edit globals.py and look for this section:

        #Auto restart settings
        auto_dallas = False
        auto_alarm = False
        auto_dht22 = False
        auto_rfsensor = False
        auto_lcd = False
        install_directory = "/home" #The PrivateEyePi software directory


Set the 
auto_lcd setting to auto_lcd = True

Save and exit globals.py by pressing ctrl-x, followed by y followed by enter.

Make sure cron is running:

sudo service cron start

Check to make sure subscribe.py is running as  background service by typing 
ps ax. subscribe.py should appear somewhere toward the end of the service listing. It may take a minute or two before it appears depending on where you are in the cron cycle.

5. Test subscribe.py by using a test application called publish.py. From the Raspberry Pi that is connected to your sensors type the following at the command prompt:

sudo python publish.py

It will send a series of messages to the LCD panel, with 5 seconds interval between messages. 

If you are using the Nokia screen and need to adjust the contrast of the screen then edit lcd_nokia.py and look for the following line:

    con=40

6. Now you are ready to test your alarm system and temperature sensors. You should see open and close messages appearing on the LCD panel as doors and motions sensors are opened and closed. Temperature readings will also start appearing on the LCD panel as they get transmitted from dallas.py, dht22.py and rfsensor.py. 


Comments