Design, simulation and implementation of an Arduino microcontroller based automatic water level controller with I2C LCD display

Received May 8, 2019 Revised Feb 11, 2020 Accepted Mar 14, 2020 The paper explains utilization of Arduino Microcontroller to automatically control level of water in a tank. From a well spelt out algorithms, flowchart was drawn, from which Codes were written and compiled on Arduino IDE. IF statements were copiously used. Proteus was used to simulate the design while the project was implemented on breadboard. Liquid Crystal Display function displays the level of water on the 16 × 2 LCD thus: Very Low, Low, High and Very High. An option of I2C LCD codes was written thus providing advantage of using only two analog input A4 and A5 pins instead of 4 to 8 pins in other configurations thereby allowing other pins dedicated for other tasks. The design recommends improvements in the area of sump control so that its low water level could disable pump thus preventing it from running dry. Protection devices like circuit breaker overload and phase failure relays are recommended in order to prolong the life of the Water pump. It is believed that the design will go in long way in educating power electronic engineers in the arts of design using Arduino; also, a mass production of the device will accentuate Small and Medium Enterprises SMEs in developing countries with its concomitant economic advantages.


INTRODUCTION
One of the results of modern age is the increase in devices that work in automatic fashion. Daily man tends to find a way to simplify his activities thereby solving problems. Many times are wasted operating systems manually; also cost of employing operators can eat deep into the company finance. The design, apart from solving this problem, also delves into trending Arduino design methodology. Appliance or equipment manufacturers and designers alike have keyed-in into this in order to remain relevant. Automatic systems reduce number of workers to attend to industrial process; the resultant is the drastic reduction in wages and losses which will undoubtedly dovetail into more profits. Thus automatic system supports lean manufacturing where customers are satisfied at low and affordable cost [1]. The aforementioned is made possible by continuous improvement in design techniques and ingenuous usage of electronics components and building blocks. Microcontrollers offer better solution, being computers on single chips; enable production of embedded smart systems which are prevalent everywhere today [2]. A designer just need to master it, learn their instruction sets and write codes that make them work. 78 This project will allow the level of water in a tank to be maintained automatically, that is, unattended to; it uses Arduino microcontroller, codes were written in order for it to perform as water level controller.

METHODOLOGY
The tasks to be performed were listed while flowchart for the design was drawn. Input pins hosting three float switches were connected to Arduino pins 1 to 3 using pull down 10k resistors. Four LEDs level indicators indicating "Water Level Very High, High, Low, and Very Low" were connected to Arduino pins 9, 8,7and 6 respectively. IF statements were in the codes. The project was simulated using Proteus while the implementation was done on breadboard. An LCD displaying water levels was included using six Arduino pins. An option of I2C LCD was included thus enabling only two analog pins A4 and A5 to be engaged; where A4 is connected to SDA and A5 to SCL , that is, i2C data and clock respectively [3].

System's flowchart
Algorithms that explain the sequence of operations and steps for the design were written thus enabling the diagrammatical representation of flow of process through the agency of flowcharting [4]. This approach simplifies the writing of system's codes ( Figure 1).

Arduino uno microcontroller
A Microcontroller can be referred to as a computer on a chip. It parades input and output pins. Unlike a Microprocessor, it includes processor with memory location for storing programs written in C language [5].
Arduino Uno board, Figure 2, has an Atmega 328 on it as the main Microcontroller. Using this unit does not require extra money for a Programmer. Codes or sketches and compilations are done on its Integrated Development Environment IDE This advantage makes prototyping of embedded system easier by engineers and electronic systems enthusiasts. The board has six (A0 to A5) analog inputs to handle analog signals and fourteen I/O pins for input and output functions [4].

Design of a relay controlling switch
Transistor works as a switch when it is operated at its extreme regions, that is, at cut-off and saturation [6] At saturation, Common-Emitter Voltage, VCE =0; and Collector Current IC = As shown in Figure 3.

Codes using I2C
In order to employ i2C configuration and benefit from its gain, the above code can be modified by including its code using #include<LIquidCrystal_I2C.h> and LiquidCrystal_I2C lcd(0x3F,2,1,0,4,5,6,7); 0x3F is the address of the i2C module [4]. Other syntax should be noted. The void () loop codes which the Arduino executes continuously remain the same as in the section above. #include <LiquidCrystal_I2C.h> #include <Wire.h> LiquidCrystal_I2C lcd(0x3F,2,1,0,4,5,6,7); int kpinF=1; // pin 1 is set as water full sensor pin int kpinM=2;// pin 2 is set as water medium level sensor pin int kpinL=3;// pin 3 is set as water low level sensor pin int MotorBuzzer=0; // pin 0 is set as water pump and buzzer drive pin int LEDvh=9; // pin 9 is set as Very High water level indicator pin int LEDh=8; // pin 8 is set as High water level indicator pin int LEDl=7; // pin 7 is set as Low water level indicator pin. int LEDvl=6;//pin 6 is set as Very Low water level indicator pin.

Simulation using proteus
The project was wired in Proteus [8] for simulation, (Figure 4). Proteus is a simulation and design software developed by labcenter electronics [9]. Single pole single throw switch was employed to represent float switches sensing low, medium and full water levels. They drive kpinL, kpinM and kpinF respectively. The pins are pull down using three 10kΩ resistors. A closed switch applies +5V across its respective pin.

THE COMPLETE CIRCUIT
Water sensors sensing Low, Medium and Full levels of water tank are connected to Arduino pins 1, 2 and 3 respectively. Pin 0 drives the water pump and buzzer while Light Emitting Diodes indicating Very Low (vl), Low(l), High(h) and Very High(vh) are connected to pins 6, 7, 8, and 9 respectively. Current flowing in the LEDs are minimized by connecting 220Ω resistors in series with them; As their cathodes are grounded (0V), the arrangement is active High, that is, when the conditions for any of the LED to be illuminated is met, its anode terminal connected to an Arduino pin goes High, thereby allowing current to flow through it, as shown in Figure 5.
Input Pins (Sensors) are tied down using 10KΩ resistors; so +5VDC is connected through the float switches to each input pin. When the water level is below any switch, its contacts becomes opened, its Arduino pin sees 0V but as water reaches that float device the switch closes thus presenting +5V to its Arduino pin. The values in the pins are stored in valf (full), valm (medium) and vall (low) memory location. The HIGH level drives a transistor switch [10] using a switching transistor 2N2222, Its Vcc is connected to the output terminal of a +9V fixed voltage regulator, LM7809. The base resistor 4.7Ω provides a potential difference in the base circuit which allows current to flow into the transistor. A transistor connected in common emitter configuration act as an Inverter [11], that is, +5V at the base produces 0V at the collector. Since a 9V relay with operating coil having ohmic (DC) resistance of 400Ω is the load, a 9V is effectively across the coil thus cause it to operate thereby closing its normally open contact which is wired in series with Electric pump control circuit. A piezoelectric device wired across the relay produces sound. A power diode 1N4001 acting as a suppression diode [11] connected across the relay protects the transistor against the back emf.
As the level of the water in the tank rises with val, valm and valf become HIGH, all the LEDs are lit, Arduino pin 0 becomes 0V, the transistor switch cuts off, relay de-energizes, hitherto closed relay contact becomes opened thereby disengaging power into the water pump control circuit. The buzzer goes off. The Water Pump is automatically switched off.
The LCD circuit uses the 12C module to reduce complexity of display circuit. Instead of using six Arduino I/O pins 4, 5, 10, 11, 12 and 13; only two analog pins A4 and A5 are used. They are connected to SDA and SCK respectively. The I2C module is soldered to the back of the 16 x 2 LCD unit. (Figure 6)