I certify that this project report entitled "General platform for Internet of Things Application" prepared by LEONG ZHE HAO has met the required standard of submission in partial fulfillment of the requirements for the award of the Bachelor of Engineering (Hons.) Electrical and Electronics at Universiti Tunku Abdul Rahman. The copyright of this report belongs to the author under the terms of the Copyright Act 1987 as qualified by the Intellectual Property Policy of Universiti Tunku Abdul Rahman. Due acknowledgment must always be given to the use of material contained in or derived from this report.
I would like to thank everyone who contributed to the successful completion of this project. See Yuan Chark for his invaluable advice, guidance and great patience during the development of the research. A server is developed to provide services to healthcare devices and users, users can also access the server using web browser and mobile application.
The communication protocol between the devices and the server, the server framework structure and the server services are designed with the concept of the Internet of Things to utilize the resources. The protocol in this proposed application between the devices and the server is MQTT, the devices communicate with the server through the MQTT packet.
Background
By applying the Internet of Things, health monitoring system, home automation system can be implemented. Health monitoring devices are connected to the Internet to reduce physician effort in rural areas; The status of patients can be monitored directly from the central hospital. The improved system can reduce the virtual distance between urban area and rural area, patients in rural area can get better health services with the help of Internet of Things devices.
The embedded devices can be implemented in smart gadget for home status monitoring, home automation and fixture control. The power consumption, the safety switch, the camera and a personal status can be monitored through the system. With the help of the internet of thing concept, it can become a smart home solution.
Aims and Objectives
Problem statement
The development of IoT is influenced by two aspects, which are market and technology. Some countries have started to undertake and develop the implementation of IoT system in projects that focus on water, energy, construction, transportation and so on. However, several challenges are stated to unleash the full potential of IoT, apart from leveraging Malaysia's existing technology strength.
From a technology point of view, Malaysia has challenges to start implementing IoT with high technology complexity, difficulty to replace the legacy systems used in Malaysia and data accessibility and availability of knowledge sharing in the last system. With the presence of wireless devices available in the market, the powerful and complex machine-to-machine communication protocols available in the open source community and complex operating software for wireless devices. An IoT system framework is formed to lower the barrier for IoT implementation in Malaysia, which can provide a complex, compatible or easy-to-replace system for the legacy system and increase the access and availability of data .
Internet of Things
Network connectivity of devices
Zig-Bee
Zig-Bee is a wireless protocol specially designed for Internet of Things devices that have high mobility and monitor or measure simple parameters. It allows a large number of devices connected to the network, the Zig-Bee protocol provides the devices can form different network topology, such as mesh, star and cluster tree topologies, the connection is not as stable as Wi-Fi. The Zig-Bee is widely used for Internet-of-thing devices application due to its extremely low power consumption. (Lee et al., 2007).
Bluetooth
It is widely used as a wearable device with IOT functions that can be connected to a mobile phone. Bluetooth offers a large number of RF channels that allow multiple users in the same location without interference.
Software
FreeRTOS
Contiki
Hardware
ESP8266
IOT protocol
MQTT
The MQTT protocol works to exchange a series of MQTT control packets in a predefined manner. An MQTT control packet consists of three elements, which are a fixed header, a variable header, and a payload. A fixed header is a special header used to distinguish the type of an MQTT control packet.
The header variable is used to send the MQTT packet identifier to identify the packet types with other packets.
CoAP
LAMP server
System Framework
Hardware
Microcontroller
The data memory and instruction memory are separate and the memory sizes are 96KiB and 64KiB respectively.
Wi-Fi module
Cloud
HTTP server
Database
MQTT broker/ Web services
Block diagram
Testing and Background setting
ESP8266 Module
ESP8266 Firmware test
LAMP server configuration and testing
- Server Ping Test
- PHP test
- MQTT broker setup and testing
- Database configuration
The PHP server reads the PHP script on the web page, transcribes the script to HTML type, and then sends it to the request address. To verify the compatibility of the Python MQTT protocol, the ESP8266 protocol, and the MQTT broker protocol, an MQTT broker service is running in frontend mode. The “apt-get update” and “upgrade” commands are called to update and install any obsolete software committed to the repository.
After the upgrade, the MQTT broker still remains the old version because the Linux repo maintainer did not update the PPA to the latest version. The latest version is 1.4.9 on the official site of the MQTT broker and there is no binary installation for the Linux platform. The only way to get the latest version of the MQTT broker is to build from its source code.
Before building the software, the Mosquitto PPA site is visited to ensure that the package is built in the current Linux version of the server. Then the source code of the MQTT server is "git clone" from the official Github, and then the code is built using the "make" command in the source folder. The Mosquitto broker server is opened again in frontend mode and the python script is opened to test the MQTT server connection.
Figure 4-8 shows that the test Python script successfully connects to the MQTT broker and dumps a debug message in the terminal. In Figure 4-9, the MQTT broker in frontend mode shows a new client successfully connected from localhost using port 1833 as a specific client ID. From Figure 4-10, the tables in the database are data, devices, logins, and members.
Table members, devices, and data are normalized from each other, as shown in Figure 4-11.
User Interfaces
ESP8266 Interfaces
After the user enters the SSID and the password, the ESP8266 is connected to the chosen network. When connection is established, the IP address of the device is shown and starts connecting to the MQTT server and a dummy data (humidity) is published periodically in this demo. On the server side, a python script runs on front mode to log the topic and print it to the terminal for testing purposes.
Server Interface
An account is created on the registration page. Clicking on the registration link on the login page will take a registration page to the user. An account is used to log in to the server, the data is displayed in a table on the web page. The name of the device, time of last update, topic, and latest submission details are displayed in this table.
The user can also add devices by submitting the topic and device name to the server. In figure 4-17, two devices are added and only one topic is submitted by the device, the latest update time and latest data are shown.
Performance
- Webpages Server
- MQTT broker
This is because a PHP technique that performs the web service as a web page is used in this proposed project and the web page itself is acting as a request. When the browser requests the web page, the web server sends nothing but a final data and redirecting hyperlink. The load time used by the zero-sized website is the time it takes the server to process the data and perform the services.
An open source benchmark tool is used to test the performance of the MQTT broker. The command is inserted into the application and the results are displayed after a few seconds. The test is performed with an increasing amount of data, the data is tested multiple times, and the averaged data is shown in Table 4.3.
Discussion
HTTP
Data Visibility Data is displayed in the URL Data is not displayed Table 4.4 Difference between GET and POST method. From Table 4-4, HTTP GET appends all data to the end of the request URL, limited length, and lower security strength when sending data to the server. The method is used to send data from the user to the server in this proposed project.
Authentication and Authorisation
Conclusion
Personal Breakthrough
Conventionally, the firmware in the wireless module is fixed and not open to change the firmware, the user must follow the protocol to use the wireless module, such as AT commands. Using the ESP8266, the module's firmware can be designed using the provided SDK library.
Recommendations
- MQTT in endpoint devices
- MQTT security protocol
- Email identification
- AP mode of ESP8266
To activate the security service, the user must use the username and password to submit data with subject. In this project the user can subscribe to any topic they want, this may violate the privacy of the users. The submitted topic must be treated with a header to identify the topic belonging to which user to prevent topic duplication and invasion of privacy.
In this project, an account can be created by submitting any character in the email form. To further improve the system, the server can verify the email to prevent the account from being created directly. To solve the problem, the ESP8266 will change to AP mode when the ESP8266 is not initialized or not initialized.
By entering the address of the ESP8266 with the browser, the user can change the setting and restart the device through HTML interfaces.