4
An Embedded Approach for Controlling Automatic Water Pump and Monitoring Real-Time Remote Data on Desktop, Android, and Web-based Application A. A. Bashit 1 , and D. Valles 1 1 Ingram School of Engineering, Texas State University, San Marcos, Texas, USA Abstract - Over the past few years, the advancement of microcontroller has opened the door to work it as a real- time data acquisition kit for a low-cost alternative. In this paper, an ultrasonic sensor is proposed as an input to NXP LCP1768 microcontroller which receives water-level from a water tank and sends data wirelessly over Wi-Fi. Another remotely placed Arduino microcontroller is used to display and to configure minimum and maximum water threshold level to automate pump control which is also Wi-Fi connected to the same Local Area Network (LAN). The NXP microcontroller can be accessed locally by an Android app, web browser and python application for monitoring real- time data and to control the pump connected to the relay of Arduino. Keywords: real-time data, IoT, Wi-Fi, python, water- level 1 Introduction and Motivation Water is essential for our life, and we cannot live without water. It makes us think about how to conserve water efficiently; do not waste it and save energy as much as possible. Houses used to conserve water in an overhead tank for their daily necessities. To fill the overhead tank with water, there is in need of a pump. However human effort is involved here to check when the tank gets empty. Sometimes the person who operates pump uses his intuition of tank water-level when to switch the pump on or off. It is quite a common scenario in developing countries like Bangladesh where the major duty of a caretaker in an apartment complex is to make sure people do not run out of water. We propose an embedded solution that implements the NXP LPC1768 Cortex M3 microcontroller with an ultrasonic sensor, and Wi-Fi module to capture and transmit data to a remotely placed Arduino microcontroller that uses touchscreen display, Wi-Fi module, and relay connected water pump to monitor water-level and automation of the pump. Our captured data is monitored and controlled and by Personal Computer, Web- Application or Android app. The goal is to personalize the application to user configuration. The effect of this embedded design will help reduce water utilization and improve conservation. The aim is to generate a proof-of-concept design that can help users automate water-level usage and control. Expansion of this idea is to provide a cost-effective solution to areas that deal with water shortages with minimal human interaction. At home and industries, where water or any other liquid reservoir tank and pump involved to fill the tank; there is an opportunity to automated water-level control solution. To accomplish the embedded design, the user can define the desired water-level using the microcontroller connected touch screen graphic display for automated pump switches on or off without any manual labor. 2 Background Internet-of-Things (IoT) has become a technological approach to monitor and manage a variety of networked devices. In our proposed embedded solution, we approach our devices connected to internet modules without trafficking data through the Internet. Our approach is to use Internet modules that utilize Transmission Control Protocol/Internet Protocol (TCP/IP) protocols to communicate between devices. In [1], they propose a web- based real-time monitoring of electrical quantities such as power, frequency, and voltage without transmitting through the Internet. In [2], they implemented an IoT with web services and cloud computing for measuring home conditions, monitoring home appliances, and controlling home access. Although in [3] and [4], they proposed an Arduino Mega 2560 implements smart home and irritation system respectively using Local Area Network (LAN) based. However, this paper did not show real-time data without refreshing the web page. Our design reflects the efforts found in [1] and it is implemented using the NXP microcontroller. We found in [5] that the water-level was detected using ultrasonic sensor and it is considered for our design as well. In our proposed work, we introduce a real-time reading of the water-level data on a display that helps the user see changes in water-level and configuration panel for customization. This configuration panel is an LCD touch screen that will be interfaced with the Arduino microcontroller. Int'l Conf. Embedded Systems, Cyber-physical Systems, & Applications | ESCS'18 | 33 ISBN: 1-60132-475-8, CSREA Press ©

An Embedded Approach for Controlling Automatic Water Pump ... · The ultrasonic sensor detects water-level from a water tank. The NXP triggers this module to transmit an ultrasonic

  • Upload
    others

  • View
    3

  • Download
    0

Embed Size (px)

Citation preview

Page 1: An Embedded Approach for Controlling Automatic Water Pump ... · The ultrasonic sensor detects water-level from a water tank. The NXP triggers this module to transmit an ultrasonic

An Embedded Approach for Controlling Automatic Water Pump and Monitoring Real-Time Remote Data on

Desktop, Android, and Web-based Application

A. A. Bashit1, and D. Valles1 1Ingram School of Engineering, Texas State University, San Marcos, Texas, USA

Abstract - Over the past few years, the advancement of microcontroller has opened the door to work it as a real-time data acquisition kit for a low-cost alternative. In this paper, an ultrasonic sensor is proposed as an input to NXP LCP1768 microcontroller which receives water-level from a water tank and sends data wirelessly over Wi-Fi. Another remotely placed Arduino microcontroller is used to display and to configure minimum and maximum water threshold level to automate pump control which is also Wi-Fi connected to the same Local Area Network (LAN). The NXP microcontroller can be accessed locally by an Android app, web browser and python application for monitoring real-time data and to control the pump connected to the relay of Arduino.

Keywords: real-time data, IoT, Wi-Fi, python, water- level

1 Introduction and Motivation Water is essential for our life, and we cannot live without water. It makes us think about how to conserve water efficiently; do not waste it and save energy as much as possible. Houses used to conserve water in an overhead tank for their daily necessities. To fill the overhead tank with water, there is in need of a pump. However human effort is involved here to check when the tank gets empty. Sometimes the person who operates pump uses his intuition of tank water-level when to switch the pump on or off. It is quite a common scenario in developing countries like Bangladesh where the major duty of a caretaker in an apartment complex is to make sure people do not run out of water.

We propose an embedded solution that implements the NXP LPC1768 Cortex M3 microcontroller with an ultrasonic sensor, and Wi-Fi module to capture and transmit data to a remotely placed Arduino microcontroller that uses touchscreen display, Wi-Fi module, and relay connected water pump to monitor water-level and automation of the pump. Our captured data is monitored and controlled and by Personal Computer, Web-Application or Android app. The goal is to personalize the application to user configuration.

The effect of this embedded design will help reduce water utilization and improve conservation. The aim is to generate a proof-of-concept design that can help users automate water-level usage and control. Expansion of this idea is to provide a cost-effective solution to areas that deal with water shortages with minimal human interaction. At home and industries, where water or any other liquid reservoir tank and pump involved to fill the tank; there is an opportunity to automated water-level control solution. To accomplish the embedded design, the user can define the desired water-level using the microcontroller connected touch screen graphic display for automated pump switches on or off without any manual labor.

2 Background Internet-of-Things (IoT) has become a technological approach to monitor and manage a variety of networked devices. In our proposed embedded solution, we approach our devices connected to internet modules without trafficking data through the Internet. Our approach is to use Internet modules that utilize Transmission Control Protocol/Internet Protocol (TCP/IP) protocols to communicate between devices. In [1], they propose a web-based real-time monitoring of electrical quantities such as power, frequency, and voltage without transmitting through the Internet. In [2], they implemented an IoT with web services and cloud computing for measuring home conditions, monitoring home appliances, and controlling home access. Although in [3] and [4], they proposed an Arduino Mega 2560 implements smart home and irritation system respectively using Local Area Network (LAN) based. However, this paper did not show real-time data without refreshing the web page. Our design reflects the efforts found in [1] and it is implemented using the NXP microcontroller.

We found in [5] that the water-level was detected using ultrasonic sensor and it is considered for our design as well. In our proposed work, we introduce a real-time reading of the water-level data on a display that helps the user see changes in water-level and configuration panel for customization. This configuration panel is an LCD touch screen that will be interfaced with the Arduino microcontroller.

Int'l Conf. Embedded Systems, Cyber-physical Systems, & Applications | ESCS'18 | 33

ISBN: 1-60132-475-8, CSREA Press ©

Page 2: An Embedded Approach for Controlling Automatic Water Pump ... · The ultrasonic sensor detects water-level from a water tank. The NXP triggers this module to transmit an ultrasonic

In our project, we incorporated forms of real-time data display. The design integrates a developed Android application, an LCD display, a Web-browser display and a Python application for the real-time monitoring and control of the load. The extra feature of the Python application is to store and record data to a spreadsheet for data analysis. Our goal is to obtain higher resolution data through the NXP microcontroller and overall provide an embedded solution that requires minimal human interaction. 3 Procedures Our embedded solution consists of two microcontrollers in a system that help users read and configure water-level data acquisition. The proposed solution will be driven by different developed applications that aid users in reading water-level data. These applications will have the capacity to display values in Web-browser form, Android phone capability, and LCD display. Overall project can be summarized in Figure 1 block diagram.

Fig. 1. Design Block Diagram

For this approach, an ultrasonic sensor is used to measure water-level from the water tank. It is a transducer that acts as a non-contact water-level measurement sensor. When the NXP sends a trigger pulse to the ultrasonic sensor, the sensor generates an ultrasonic sound wave [6]. Then the generated wave reflects back from the water surface just like an obstacle for ultrasonic. While sending trigger pulse, the NXP also keeps counting the time until it gets echo signal from ultrasonic sensor [6]. After receiving the echo signal, the NXP calculates the time required to receive the echo thus the water-level.

Ultrasonic sensor will be located on top of the water tank so do NXP microcontroller. In the case of home and industrial application of water pump, a tank is usually located on the rooftop of a building, and a pump is situated on the ground floor. By connecting a wire from the rooftop NXP to ground floor relay to operate pump is inconvenient; rather wireless communication will ease the need for wire communication. That is why we have introduced an Arduino microcontroller to remotely capture real-time

water-level data wirelessly from the NXP and to display it on an LCD and to control water pump connected to it.

The touchscreen will help the user view the current water-level of the tank. It is the user’s discretion to what minimum water-level pump should turn on, and while pump keeps filling the tank to what maximum water-level pump should turn off. We are calling these two values as a low threshold and high threshold respectively. These settings can be configured at 2.4-inch resistive touchscreen display which uses Nextion Editor to create a graphical interface. The Nextion instruction set [7] is used to receive real-time data through the Transmission (TX) pin from the NXP microcontroller over its serial port.

As Arduino needs to wirelessly monitor the captured data at a distant place, and NXP sends data over Wi-Fi. Both of the microcontrollers need to be interfaced with the Wi-Fi module for wireless communication. The ESP8266 Wi-Fi module was selected to provide the communication in a cost-effective and small size implementation. These modules will be initialized with our designated TCP socket port [8] using AT commands [9]. We are using a client-server architecture where NXP a server, and Arduino is a client. Right after initializing this configuration, the NXP is ready to send data, and Arduino gets real-time data. This wireless connectivity ensures that the Android app and a desktop computer connected to the router via Wi-Fi or Ethernet will be collecting data sent by the NXP microcontroller. Like the Arduino, these applications can also view real-time water-level data and configure thresholds values. Operating principle of Ultrasonic sensor and python, web application, and the Android app are explained in the following section.

3.1 Ultrasonic Sensor (HC-SR04) The ultrasonic sensor detects water-level from a water tank. The NXP triggers this module to transmit an ultrasonic wave and starts counting the time until the echo reaches the receiver [6]. The duration of response is defined as T, the sound in air is measured at 340 m/s, and the water-level distance from the sensor is defined as,

d = (T 340 m/s)/2 (1)

Fig. 2. Operation of Ultrasonic Sensor

34 Int'l Conf. Embedded Systems, Cyber-physical Systems, & Applications | ESCS'18 |

ISBN: 1-60132-475-8, CSREA Press ©

Page 3: An Embedded Approach for Controlling Automatic Water Pump ... · The ultrasonic sensor detects water-level from a water tank. The NXP triggers this module to transmit an ultrasonic

The Arduino general purpose input output (GPIO) pin is connected to the relay of the water pump; as a result, if the higher threshold desired water-level is reached. The Arduino will automatically trigger a signal to the relay of the pump to turn it off and if it reaches the lower threshold value, it turns the pump off.

3.2 Python Desktop Application Socket programming and client-server TCP/IP model [8] are implemented for bidirectional communication between NXP server and clients running versions of the application. In our design on the client, Python will display the real-time data as well as store the data in a spreadsheet if any further processing required by an end-user. The prototype of real-time Python Graphical User Interface (GUI) can be visualized in Figure 3.

Fig. 3. Python Real-Time Data Visualization

Each client has to connect with the NXP server and receive data continuously until the user closes the socket connection. If the user does not communicate with the server within a pre-defined time, the NXP server will close the socket. This model is called client-server model [8] and has been implemented in this design in order to communicate with the NXP and clients.

3.3 Web-Client Application The NXP will host web page developed using HTML and JavaScript. This web page will show real-time water-level vs time curve, pump condition (on/off) and pump switching thresholds.

The NXP hosted web-page prototype is shown in Figure 4. Here, HTML was used to render static web page

and JavaScript will be implemented to communicate with the server for dynamic real-time data display. It ensures minimal server traffic required between server and client [10].

Fig. 4. Web-Client application

Herein, a user will easily visualize real-time water-level data and operate a pump over the PC or mobile web-browser by accessing the IP address of the NXP microcontroller.

3.4 Android App MIT App Inventor 2 [11] is a web-based tool to develop an Android application using graphical blocks rather than conventional scripting. Using this web application, we will create an Android app that will act as a client and will connect to the NXP server to monitor and configure thresholds as well.

A 12V Relay module board [12] will be interfaced with the Arduino to control the water pump. This module operates in 12V and can handle a maximum load of AC 250V/10A. Thus, this relay can support maximum 2500VA pump. This board has optocoupler isolation and driving ability to trigger current of 5mA; in which it is installed via terminal wiring leads.

The NXP and Arduino microcontrollers, the ultrasonic sensor, Wi-Fi module, touchscreen, and relay are the major components used in this project. A Python program and Android apps were developed to capture real-time water-level data monitoring functions and controlling features. Thus, we will implement our proposed design as seen in Figure 1.

4 Expected Outcome Automation of water filling in an overhead tank is the objective of our project. The NXP calculates time lapse between these transmitted and echo signals from the ultrasonic sensor and finds water-level of the tank. This water-level determines whether pump needs to be turned on or off. These thresholds are customization by the two NXP and Arduino touch screens. Testing for the implementation of the two boards is shown in Figure 5. and Figure 6.

Int'l Conf. Embedded Systems, Cyber-physical Systems, & Applications | ESCS'18 | 35

ISBN: 1-60132-475-8, CSREA Press ©

Page 4: An Embedded Approach for Controlling Automatic Water Pump ... · The ultrasonic sensor detects water-level from a water tank. The NXP triggers this module to transmit an ultrasonic

In Figure 5, the NXP microcontroller is interfaced with the Wi-Fi module to act as a server for sending data wirelessly to the remote Arduino. The Arduino displays the real-time water-level data and operates pump automatically by the NXP command as displayed in Figure 6. The user will have the option to control the pump and change the water threshold value by means of the Arduino attached touch screen, web application, Python or the Android app. In some scenario, if the NXP and Arduino are in close vicinity in which both of the Wi-Fi modules can connect with each other without the need of a router, then it is possible for the NXP connected Wi-Fi module to be reconfigured as an access point. Further, both the NXP and Arduino will have to be located within the module range. With the use of IoT hosting web pages like ThingSpeak [13], Adafruit, or knowing internet connected LAN IP address by registering routers to noip.com, internet-based real-time water-level data monitoring is also possible to implement.

Fig. 5. NXP with Ultrasonic Sensor Measures Obstacle Distance

Fig. 6. Arduino Displays Distance Measurement. 5 Conclusion This project implements a standalone, versatile and user-friendly embedded solution for automatic water pump

control. This ensures a user flexibility to customize the configuration of thresholds and real-time water-level data monitoring and control of pump by mobile, desktop or web application services.

6 References [1] Despa, D., et al. “Web-Based Real Time Monitoring of Electrical Quantities Measurement.” 2017 International Conference on Sustainable Information Engineering and Technology (SIET), 2017, pp. 464–70. [2] Soliman, M., et al. “Smart Home: Integrating Internet of Things with Web Services and Cloud Computing.” 2013 IEEE 5th International Conference on Cloud Computing Technology and Science, vol. 2, 2013, pp. 317–20. [3] Kusriyanto, M., and B. D. Putra. “Smart Home Using Local Area Network (LAN) Based Arduino Mega 2560.” 2016 2nd International Conference on Wireless and Telematics (ICWT), 2016, pp. 127–31. [4] Singh, P., and S. Saikia. “Arduino-Based Smart Irrigation Using Water Flow Sensor, Soil Moisture Sensor, Temperature Sensor and ESP8266 Wi-Fi Module.” 2016 IEEE Region 10 Humanitarian Technology Conference (R10-HTC), 2016, pp. 1–4. [5] Mantoro, T., and W. Istiono. “Saving Water with Water Level Detection in a Smart Home Bathtub Using Ultrasonic Sensor and Fuzzy Logic.” 2017 Second International Conference on Informatics and Computing (ICIC), 2017, pp. 1–5. [6] “Ultrasonic Sensor,” https://www.sparkfun.com/ products/13959, accessed on 03/21/2018. [7] “Nextion Instructoin set,” https://www.itead.cc/wiki/ Nextion_Instruction_Set, accessed on 03/21/2018. [8] “TCP/IP base client-server model”, https://www.tutorialspoint.com/unix_sockets/client_server_model.htm, accessed on 03/21/2018 [9] “ESP8266 AT Instruction Set,” https://www.espressif.com/sites/default/files/documentation/4a-esp8266_at_instruction_set_en.pdf, accessed on 03/21/2018. [10] “Javascript,” https://www.tutorialspoint.com/ javascript/javascript_overview.htm, accessed on 03/21/2018. [11] “MIT App Inventor | Explore MIT App Inventor”, http://appinventor.mit.edu/explore/front.html, accessed on: 03/21/218 [12] “Relay Module Board Shield with Optocoupler,” https://www.aliexpress.com/item/One-1-Channel-12V-Relay-Module-Board-Shield-With-Optocoupler-Support-High-And-Low-Level-Trigger/32828017897.html, accessed on: 03/21/218. [13] “Thingspeak_mbed,” http://www.frank-zhao.com/thingspeak_mbed_tut1/, accessed on: 03/21/218

36 Int'l Conf. Embedded Systems, Cyber-physical Systems, & Applications | ESCS'18 |

ISBN: 1-60132-475-8, CSREA Press ©