This tutorial is to fulfill the requirement of sending messages to the display from a web application. We learned how to create a webserver using python using the Flask framework in the previous article. Interfacing of LCD to Raspberry Pi is well discussed in AdaFruit website. Here is a simple yet interesting example of how to create a new web application that will interact with the Raspberry Pi and display the characters given by the Web application in the LCD interfaced with it.
Web Application based LCD Display using Raspberry Pi
Prerequisites & Equipment:
You are going to need the following:
A Raspberry Pi Model B or greater.
A USB WiFi Adapter (Edimax – Wireless 802.11b/g/n nano USB adapter is used here).
An SD Card flashed with the Raspbian OS (Here is a guide if you need)
Access to the Raspberry either via a keyboard and a monitor or remotely.
We will make a straightforward web application with a frame that permit a client to send a message to the Raspberry Pi utilizing Flask in a web browser. This will permit us to control the Raspberry Pi from a PC, tablet or smart phone. At the point when the form is submitted, it will send the message to the LCD by means of the Raspberry Pi’s GPIO ports. All the code, including the web application, is in Python and HTML.
Here we’ll be utilizing the modified AdaFruit_CharLCD.py library according to our connections in the circuit, so make sure you have everything up-and-running as per the AdaFruit tutorial except the connections. So we have to set up the folder structure that we need.
Create a folder web_lcd in the home directory:
Fig. 2: Creating Folder Web_lcd In Home Directory Similar To AdaFruit
And create two folders and python script file named lcd.py in the web_lcd directory.
Change the IP address to your’s Raspberry Pi. ( IP address of raspberry pi can be known by ifconfig command.
Fig. 3: Change The IP Address For Raspberry Pi
To change the pin numbers, navigate to Adafruit_CharLCD.py and edit the numbers.
Note: In GPIO.setmode(GPIO.BOARD), BOARD stands board specified numbers.
Fig. 4: Changing Pin Number In Raspberry PI Using Adafruit_CharLCD.py
Type the below command after navigating SSH to Web_lcd folder.
Sudo python lcd.py
Fig. 5: Restarting Server For LCD Display
This will start your Webserver and the characters which you type and submit will display on LCD.
Fig. 6: Web Control Panel Of LCD Display In Raspberrypi
Project Source Code
Project Source Code