The purpose of the project is to make easier way of teaching. It embeds most important functions that is required in school teaching normals into a web, a server and a Raspberry Pi. These functions includes:
Using different tools to accomplish different goals in daily life usually causes a lot of trouble. In universities the problem could be obvious. Take Cornell University as an example:
To solve the problem, this project embeds all the mentioned functions into ONE SYSTEM. It mainly includes:
For teacher use, including account operations (login/ logout/ signup). Teachers can publish announce- ments, conducting Y/N surveys, view the responses of surveys, view the latest attendance conditions (numbers and absent namelist), view the historical attendance conditions.
Operating on a Raspberry Pi. It employs Django framework for developement. It also includes the database.
Operating on a Raspberry Pi. It is a portable and easy-using GUI system written in pygame. It can view the timetables, view the teacher's announcements, response teacher's surveys, as well as taking attendence. A teacher's RPi is used to take attendance for the students.
The overall design is shown in the figure below: The core is the server and the database which is managed with Django. All the three end systems go through Django to communicate, including posting and responsing.
Two RPi are used in the design. The server and the teacher's UI runs on one Raspberry Pi, while the student UI operates on another Raspberry Pi. A laptop is also used to present the website for the teacher. The Raspberry Pi UI is designed with Pygame while the website is designed with HTML, JS, CSS and D3. The server structure is developed based on Django. The database of the server is SQLite3. To transmit information, we use TCP protocol.
Tools been used in the project:
Pygame; Django; Ajax; SQL; Raspberry Pi & PiTFT; TCP; Nginx; HTML; Apache; JS; D3; CSS
All the testing procedures are conducted by connecting with the back-end system. All the post data can be logged into the SQLite database and all the required data can be shown on the webpages.
The kernel of RaspberryPi runs the Linux operating system, which is the largest open source operating system and can fully support the operation of servers and programming scripts. In this project, we choose python and the corresponding Django framework because it is open source and stable . In terms of databases, SQLite3 and SQLite3 are embedded databases in Django. When receiving a request from the client, Django will extract the corresponding data from the database or store the submitted data, and feed the corresponding information back to the front end or client of the student management system.
installed in RPi in advanced, so we just need to install Django. Before installing
it. We can set up virtualenv at first, virtualenv creates a virtual environment
separated from the system environment so that any operation here will not affect the
To install Django systemwide, use this command:
pip3 install Django
This command will start a new project:
django-admin startproject Management_system
When we run here for the first time, the system prompts "command not found: django-admin". The reason for the error is that django-admin did not join the system path. This can be done by symbolically linking the django-admin in the python.path/site-packages/django/bin/ folder to the /usr/local/bin file . Or use the absolute path to run the command to create the project.
After completing the above operations, we have created a Django project. A folder with the same name will appear under this directory, which contains the server configuration file settng.py, and the routing configuration file urls.py. Then, we can create an application that actually runs the server:
python3 manage.py startapp mysystem
This will create another folder dedicated to storing project-related configuration files. For example, models.py defines the structure of the database . Here, you can customize the tables and their attributes that you need to use. In this project, we created a total of six tables to store the corresponding data. Whenever a new table is created or form properties are updated, we need to connect the database to the backend. After connection, the changed content will be combined in the back-end processing model. The connection code is as follows:
python3 manage.py makemigrations
python3 manage.py migrate
In the Django framework, different functions defined in the View.py script will process all requests according to different request destination addresses. When the web front end or RPi client sends a request, the requested data is packaged into a json file, encoded in utf-8. This file will send data to the corresponding url through the POST method, and call the corresponding function in view.py. We encountered two problems when processing POST requests. The first one is that Django always displays the error: Forbidden (403) at the beginning. The cause of the problem is the lack of CSRF token. But this application does not actually need a token, so this error can be avoided by simply placing a @csrf_exempt before the function that processes the request. The second problem is that sending json data must be passed in the form of a dictionary, otherwise an error will be reported
The server can be launched using this command:
python3 manage.py runserver &
This will allow the server to run in the background so that it can make room for the teacher user interface in the foreground.
We choose TCP for the communication between the two processes to achieve real-time updates of the database and avoid process conflicts.
Then we use:
python3 manage.py runserver 0.0.0.0:8000
This command will become the accessible address of the server on port 8000 of each ip address of the host, so that the server can be accessed by the external network. At the same time, we modify the corresponding settings in setting.py.
In this project, we chose a Raspberry Pi with a 320x240 piTFT touch screen as the user terminal. In order to achieve visualization and graphical user interface, the Python library PyGame is used. For better code maintenance and debugging, we use object-oriented programming to create classes for different functions.
First of all, a home interface appears after the Raspberry Pi starts. Figure.x demonstrates the view of the home page. The home page will show the current time, date and user's login name. After clicking the open button in the lower right corner of the homepage, you will enter the function list. The list contains three functions: viewing class schedules, viewing notifications, and completing real-time surveys. These functions are realized by the requests library of python . In addition, bring the student’s Raspberry Pi close to the teacher’s terminal to automatically complete the Bluetooth sign-in function. At the same time, we set the physical button 27 on piTFT as a forced exit function.
In the end, we put these two lines in the .bashrc file so that the service runs
when the system is booted:
python3 manage.py runserver 0.0.0.0:8000 &
Function1: Take attendance
The function works well, from bluetooth-reading, data transmission, and visualization.
Function2: Make surveys
The students RPi UI can show the content of the survey and choose their answers, while the teacher can view the response. However, the Pi could not handle lots of questions due to Pygame design.
Function3: Show timetables
The Raspberry Pi only show the timetables once at a time.
Function4: Publish announce- ments
The function works well, from input, data transmission, and reading at Pi.
All the functions works as planned. However, there still need some improvement, either on RPi display; database complexity and website beauty.
|3||SD Card 16G||2||N/A|