*3.1.1.4 Application layer*

It uses a user interface where the central company managing the three stations can view data from any station using any web browser from a desktop or smart phone.

### *3.1.2 Software Part*

The petrol station is controlled by a system to enable that it operates efficiently. As this petrol station is expected to be left standalone and managed wirelessly, a system to control and monitor it from a distance is necessary. Software that was used in this application are:

## *3.1.2.1 Arduino Software (IDE)*

The Arduino Integrated Development Environment (IDE) is a free and opensource cross-platform application (for Windows, macOS, and Linux) developed in C and C++ functions. The Arduino IDE makes it simple to develop code and upload it to the device [15]. This software can be used with any Arduino board. Arduino programming is used to control the petrol station system. The Arduino Mega is communicated with the ultrasonic sensor for the fuel leveling and with other sensors in the project for environmental monitoring and controlling. Aside from that, Arduino programming controls the 4 x 4 keypad number, RFID system, and LCD display that serves as the customer's interface. Flow meter and relay are responsible for determining the functionality of the pump, needed to be programmed by Arduino. Finally, Arduino IDE uses the ESP-32S module in programming to establish a connection with the internet, in order to provide these functionalities;


#### *3.1.2.2 Proteus program for simulation*

"Virtual System Modelling" (VSM) by Proteus combines SPICE simulation in mixed modes with the industry's fastest microcontroller simulation. It allows for quick hardware and firmware prototyping in software [16]. Proteus VSM's most significant aspect is its ability to simulate the interface among software functioning on a microcontroller and any digital or analog devices linked to it. The microcontroller simulation is put on the schematic among the other parts of design of your product. It mimics object code execution in the same way as an actual chip does. Logic levels in the circuit will change whenever your program code writes to a port, and if the circuit varies the situation of the pins of processor, your program code will notice, just like in physical life. The VSM CPU models accurately emulate each supported processor's input/output ports, timers, interrupts, USARTs, and other components. Because the interface of each of these peripherals with the outside circuit is thoroughly described to the level of waveforms, the whole system is being tested, it is far more than a simple software simulator. With over 750 microprocessor variations supported, a lot of fixed SPICE models, as well as one of the major libraries of entrenched simulation peripherals in the world, for an embedded model, Proteus VSM is still the best option.

#### *3.1.2.3 LabVIEW program for simulation*

LabVIEW (Laboratory Virtual Instrumentation Engineering Workbenches (where a national instruments platform and development environment for a visual programming language. The goal of this type of programming is to automate the use of laboratory decision-making and measurement equipment. It's a proprietary software package that makes it easier to design different types of data management, control, and measurement systems and is therefore ideal for GUI design.

#### **3.2 Implementation of the proposed system**

The designed system is divided into two main parts: the first part relates to the hardware on the board (control system) and the second part relates to the ThingsBoard web server. In **Figure 4**, the arrows pointing toward the Arduino mega 2560 shows the input, while the arrows pointing from Arduino shows the output of the processor. For a single petrol station two parts are implemented as shown in **Figure 4**.

*First*: the ultrasonic sensor HC—SR04 connected at the top of a fuel tank to calculate the fuel level by sending ultrasound waves. The distance is equal to the speed multiplied by the time, the speed of sound is known at a temperature of 20 degrees Celsius equivalent to 343 meters/second. The time that the sensor processor calculated from the start time of the pulse to the echo return time is divided by 2. By knowing the time and speed, it is possible to calculate the distance, determine the height level, send the data to the microcontroller (ATmega2560) connected to the ESP32 Wi-Fi module and send the data later to the server. A fluid temperature sensor (DS18B20) has been added to the tank, and it can be added to the pump hose to measure the temperature of fuel and the consequent result of calculating is the evaporation rate and density which dependent on temperature to determine types of mixtures. DS18B20 connects via 1-WIRE protocol requiring one data line to connect to the Arduino Mega Board.

*Second:* the fuel dispenser system is a box where the electronic parts appearing on it, which represented by a 4 \* 4 keyboard, have been linked. The letters on the panel

**Figure 4.** *The proposed smart petrol station.*

perform a number of functions. Also, a 20 \* 4 LCD screen was attached to the box to show the customer all the functions when pressing the keypad. NFC RFID to scan the RFID tag by establish a wireless connection with each other by touching or bringing them close at close range, usually not more than a few centimeters. NFC RFID and LCD communicate with each other and send data between them via the (I2C) protocol, which is a serial data communication protocol, which operate among two devices or a group of devices to transfer information among them. The protocol works in a "halfduplex" manner, one of the devices will be sending whereas the another will be at the receiving state and they cannot transmit at the same time. The DHT11 temperature and humidity sensor has been added to the contents box to monitor the temperature and humidity to be an example of monitoring the environment and showing the results directly on the server from the second petrol station. The fuel and water pumps are connected on the sides of the box; the fuel pump is connected to the fuel tank on the one hand and linked to a flow meter that calculates the number of liters required; the flow meter is connected to a hose on top of which hose there is a button that can be pressed to fill the required amount of fuel; and if the required quantity is filled, the pump will revert to its original position. As for the water pump, it has been linked to a flame sensor that sounds an alarm when a flame is detected, as it sends its data to the microcontroller that instructs the relay switch associated with the water pump to operate it. This pump can also be controlled manually via a push button and the pump is started. **Figure 5**, shows the connection map establishes by fritzing software for the hardware parts on the board. **Figure 6**, shows a section of the practical hardware of the designed and implemented system, which is installed outside the control system box.

Inside the control system box, there is an Arduino Mega 2560, a microcontroller board based on the ATmega2560 processor. The board contains everything needed to support the microcontroller; It can be connected to a computer with a USB cable or powered by an AC-to-DC adapter or battery to start. The ATmega2560 contains 256 KB

**Figure 5.** *Connection map on the board.*

**Figure 6.** *Hardware section outside the box of the control system.*

of flash memory to store the code (of which 8 KB is used for the bootloader), 8 KB of SRAM and 4 KB of EEPROM. And because of this memory is little, the MicroSD card adapter module, which is a Micro SD card reader for reading and writing through the file system, and the SPI driver, has been linked, so this module connects with the microcontroller through the SPI serial communication protocol. This protocol works through three lines "MISO, MOSI & SCK". At any given time, only two devices can talk to each other. What distinguishes this protocol is that it is (Full-duplex) that is, the two devices can transmit and receive at the same time. Also, from the electronics that were provided for this system inside the box, the voltage regulator is fixed, as it has a voltage of 12 volts to feed the pumps and a voltage of 5 V comes out of it to feed the rest of the system elements. The two channel relay module MR009–004.1 is fixed inside the box, where is a module designed with two relays that provide 12 volt power to allow control of the fuel pump and the water pump. WiFi-BT-BLE MCU module the core of this module is an ESP32 chip that supports Secure Over-The-Air (OTA) upgrade. This module inside the box is responsible for providing a direct connection to the server via a WiFi router and it acts as a second microcontroller represent as second petrol station. **Figure 7**, shows the core components of the control system box.
