Creating a Seamless Communication Terminal Based on MQTT

Author:Nanhai District Dali Town Junior High School, Foshan City, Guangdong Province Zhang Quan, Ling Yujie, Xie Hanzhe

Creating a Seamless Communication Terminal Based on MQTT

This article is sourced from “Invention and Innovation” May 2023 Junior High School Edition

We found that homeroom teachers and subject teachers have many repetitive and mechanical tasks, such as: every day the homeroom teacher conveys messages from parents to boarding students, or notifies boarding students to call their parents; subject teachers need to go to the classroom to convey notifications to students. If we design a device placed in the classroom that can display messages sent by teachers and parents via mobile phones in real-time, it can improve notification efficiency and reduce the burden on teachers.

1. Preliminary Preparation

We, together with the guiding teacher, determined the research direction of the project.

(1) Project Novelty Search

We conducted a project search and found no devices with similar functions.

(2) Clarifying Responsibilities

To efficiently complete the project research, we divided the tasks, with specific responsibilities shown in Table 1.

Table 1 Project Team Member Responsibilities

Creating a Seamless Communication Terminal Based on MQTT

(3) Demand Survey

We interviewed homeroom teachers and subject teachers to understand their needs in daily management and teaching, and solicited expected solutions and suggestions. After considering multiple opinions, we formulated a research plan.

2. Product Design

(1) Component Selection

The components required for the device include an LED dot matrix screen, Raspberry Pi 2 Model B, Raspberry Pi CSI protocol camera, TTL to RS-485 module, serial infrared receiving module, infrared remote control, serial noise module, CH340 module, and Dupont wires, etc. We purchased these components on a shopping platform.

(2) Module Development

Each of us took on the development task for one module. It took about three weeks to complete all module development.

When selecting electronic modules, we prioritized modules with UART serial protocol because UART communication is simple. Communication between the module and the Raspberry Pi is achieved through the CH340 module. When using the serial module, it is important to note that: the connection order of VCC and GND must not be reversed; the GND pins of the two communicating devices must be connected together; when connecting two serial devices, the TX pin of device A must be cross-connected to the RX pin of device B.

(3) Design of the Expansion Circuit Board (PCB)

We drew the schematic diagram and then used Lichuang EDA to convert the schematic into PCB: set the size of the PCB, install components according to the positions in the schematic, and then use the software’s one-click routing function to automatically complete the PCB circuit connections according to the schematic wiring. Finally, for the lines carrying high current, we appropriately widened the traces to prevent burning.

Creating a Seamless Communication Terminal Based on MQTT

Figure 1 Schematic and Layout of the Expansion Circuit Board

(4) Assembly and Debugging

After debugging the modules, we assembled the device. Since the device is a prototype, we fixed the electronic modules with 3M foam glue and then connected them with Dupont wires. If all tests go smoothly later, we will consider drilling holes for fixing.

Creating a Seamless Communication Terminal Based on MQTT

Figure 2 Internal Wiring Diagram of the Device

After that, we conducted joint debugging. We chose Raspberry Pi as the main control unit and installed a streamlined command line operating system on the Raspberry Pi 2 Model B. By connecting the Raspberry Pi 2 Model B and the computer to the same wireless network, we can debug the code on the Raspberry Pi using the SSH tool “FinalShell” on the computer.

The debugging process is: write the code on the computer, after completion, transfer the code file to the Raspberry Pi, and run it by entering “Python3 +(code path)” in the command line. Based on the error codes generated during execution, we modify the code accordingly. Repeating this process completes the code joint debugging.

Creating a Seamless Communication Terminal Based on MQTT

Figure 3 We are debugging

3. Structure and Function

(1) Appearance

The device shell is made of anodized aluminum, with two LED dot matrix screens embedded on the surface, fixed with magnets. The shell has reserved holes for easy installation of brackets or hanging on the wall. The buzzer, camera, spring metal antenna, serial infrared receiving module, and boat-type master switch are located above the screen.

Creating a Seamless Communication Terminal Based on MQTT

Figure 4 Appearance of the Device

(2) Internal Structure

Creating a Seamless Communication Terminal Based on MQTT

Figure 5 Internal Structure of the Device

The device contains an expansion circuit board, Raspberry Pi 2 Model B, display driver for the screen, and the main power supply. The expansion circuit board integrates the TTL to RS-485 module for screen driving and Raspberry Pi communication, SHT30 module for measuring classroom temperature and humidity, and a transistor driving circuit for the buzzer, etc.

Creating a Seamless Communication Terminal Based on MQTT

Figure 6 Schematic Diagram of Internal Wiring (Network Card Connected via USB)

(3) Functions and Operating Methods

1. Display time, date, weather conditions, and countdown

In standby mode, the screen will display the current time in the format “hour:minute:second”. Using the infrared remote control, different content can be displayed on the screen: pressing button “1” displays the current date; pressing button “2” displays the weather for today and tomorrow (queried through a weather API), returning to the main interface after 5 seconds. The SHT30 module can measure the classroom’s temperature and humidity in real-time and display it.

The screen can also display a countdown. If you want to display the remaining time until a target date, you can set the date and content before use. Once completed, the screen will switch between displaying the time and the remaining date, with an interval of 10 seconds. If you want to display a countdown to a specific time point, you can press button “4”, input hours, minutes, and seconds, and then press “OK” to start the countdown. A beep will sound when it ends, and pressing “back” will return to the main interface.

Creating a Seamless Communication Terminal Based on MQTT

Figure 7 Displaying Countdown and Temperature & Humidity

2. Display random student ID in lottery mode

By pressing button “3” on the infrared remote control, we enter lottery mode, and after pressing “OK”, the screen displays a random student ID and scrolls. Pressing “OK” again stops the scrolling student ID. Pressing “OK” again continues the lottery, and pressing “back” returns to the main interface.

Creating a Seamless Communication Terminal Based on MQTT

Figure 8 Entering Lottery Mode, Displaying Random Student ID

3. Display messages

Communication between the mobile phone and the device is achieved through the MQTT protocol. When the device starts, it creates an MQTT server and uses Peanut Shell software for internal network penetration, allowing external devices to connect to the Raspberry Pi’s MQTT server.

Parents and teachers’ mobile phones or computers subscribe to the same TOPIC, sending messages in a unified format by adding the sender’s ID to the message. After receiving the message, the device screen will display that a certain student has new information, and the buzzer will sound a reminder. If students do not see the message after parents or teachers send it, they can use the infrared remote control to check the message content: pressing the button “5” on the infrared remote control enters the unread message query mode, where they can switch up and down using “↑” and “↓”.

Creating a Seamless Communication Terminal Based on MQTT

Figure 9 Device Screen Displaying Messages

4. Supporting Program

To facilitate teachers and parents in using the device, we designed a WeChat mini-program that accompanies it. After entering the mini-program with an account and password and completing permission authentication, they can send messages. The homeroom teacher can click the “Video Monitoring” button to open the link in a browser on their mobile phone or computer to view the video monitoring screen.

4. Testing and Deployment

We placed the prototype in the classroom for trial use, collecting feedback from students, parents, and teachers, and compiling it.

5. Improvement Ideas

Creating a Seamless Communication Terminal Based on MQTT

Figure 10 The prototype placed in the classroom for testing usage effects

Afterward, we will improve the device, planning to add servo control for the camera direction, voice intercom functionality, etc. We hope to achieve mass production, and one day, all classes in the school can use the communication terminal we designed. (Guiding TeacherChen Jixuan

Expert Review

The communication terminal based on MQTT designed by students Zhang Quan, Ling Yujie, and Xie Hanzhe is a work with considerable difficulty and high technical content. The highlights of this work are: student Zhang Quan is responsible for the overall operation of the project, student Ling Yujie is responsible for preliminary research, and student Xie Hanzhe is responsible for circuit design, all in accordance with the requirements of the new era of youth science and technology innovation activities, with clear division of labor and accountability; this is a good example of cultivating youth’s comprehensive awareness and abilities. At the same time, from the final presentation of this work, it can be seen that it meets its design requirements, reflecting the support of the school and the guidance capabilities of the teachers. It is worth discussing that, based on the current understanding, this project should belong to Category A works in the Youth Science and Technology Innovation Competition, which means it has a strong professional topic. Completing this work also poses a certain difficulty for adults with considerable technical backgrounds, and even more so for three junior high school students, requiring time and effort. The purpose of youth science and technology innovation is to allow them to gain innovative growth through practical experience, rather than providing “high, large, and top” products. It is recommended that everyone choose small inventions (Category B) that are suitable for their age characteristics and knowledge level during innovation practice activities. (Reviewer: Tan Di’ao, First Expert Consultant of the Chinese Invention Association, President of the Primary and Secondary School Creation Education Branch of the Chinese Invention Association, Special Teacher of Science and Technology Innovation Education, Expert in the National Training Program Expert Database of the Ministry of Education.)

Creating a Seamless Communication Terminal Based on MQTT
Creating a Seamless Communication Terminal Based on MQTT
Creating a Seamless Communication Terminal Based on MQTT
Creating a Seamless Communication Terminal Based on MQTT
Creating a Seamless Communication Terminal Based on MQTT
<Swipe Left and Right to See More>

Leave a Comment