Design and implement of robotic arm and control of moving via IoT with Arduino ESP32

Every day, the technologies are expanding and developed with extra things to them. A cloud computing (CC) and Internet of things (IoT) became deeply associated with technologies of the internet of future with one supply the other a way helping it for the successful. Arduino microcontroller is used to design robotic arm to pick and place the objects by the web page commands that can be used in many industrials. It can pick and place an object from source to destination and drive the screws in into its position safely. The robot arm is controlled using web page designed by (html) language which contain the dashboard that give the commands to move the servos in the desired angle to get the aimed direction accordingly. At the receiver end there are four servo motors which are made to be interfaced with the micro controller (Arduino) which is connected to the wireless network router. One of these is for the arm horizontally movement and two for arm knee, while the fourth is for catch tings or tight movement. Two ultra-sonic sensors are used for limiting the operation area of the robotic arm. Finally, Proteus program is used for the simulation the controlling of robot before the hardware installation


INTRODUCTION
In recent years, computing as utilities has seen a greater expansion. The essential stimulation for this expansion was the objective of diminishing the cost and the time of operating. In addition to making simpler the service and place new services automatically without the need to sustain on the specified infrastructure of a compute. After that, cloud computing started rapidly to change the way it's to assist the organization's exhibit their information technology (IT) source. Cloud computing is able of supplying unrestricted sources of computation and storage as services via the internet provide to [1]. Cloud computing distinguish a very important point in computing by provides common computational energy of the demanded resources. It has changed the way of introducing the services of IT with lower demands of infrastructural due to depending on the essential idea of virtualization [2]. The virtual global include the different technological models to supply infrastructure of devices, progression program, and applications as services of on-demand which depend on n a pay-as-you-go type [3]. Cloud computing (CC) and the internet of things (IoT) appeared the revolution in information and communications technologies (ICT) the twenty-first century by new platforms [4]. It is rapidly grown by 2018 and this year is an adventure year for IoT industry. According to the Gartner report, ISSN: 2088-8708  Design and implement of robotic arm and control of moving via IoT with … (Anwer Sabah Ahmed) 3925 20 billion systems and instruments will be connected to the cloud by the end of 2020 [5]. IoT is used as a counter that design of a smart counter of the digital bidirectional visitor. The main focus is on compute vast a number of humans which enter multiple entrance gates in one place [5], [6], using Nano Things via the internet (IoNT), using mobile things via the internet (IoMBT), and more. both cloud computing and the internet of things (IoT) are an important part of our life [7]. Intelligent workshops are defined as the almost the works that be achieved within complex and the future sensors generation technologies and most of the personnel works can quickly answer to many changes types. Industry 4.0 will connect the physical and digital world to make a new system which is known by the term: "Cyber-physical systems". This system has more importance for developing IoT to give it the more advanced principle in the meaning of robotics which led to found a term known as "internet of robotic things or (IoRT)". By the IEEE society related to robotics and automation of technologies for networked robotics [8], the robot that is networked via the internet is "a robotic instruments connected to a communicating by a specified network like the Internet or local area network (LAN). The robots which combined with sensors that operate smartly within the network and interchange the information.
In the near future, the internet of things (IoT) with other areas as artificial intelligence, and cloud computing can make a new future for robots by introducing the next covenant of smart robots known as the "internet of robotic things (IoRT)". Cloud robotics was the basic purpose of the planning and enhancement of the internet of robotic things [9]. Cloud robotics can be considered as a system that depends on "cloud computing" construction to connect with huge amounts of data to perform the required operations. All the operations like sensing methods, calculation, and storing memory are gathered into one separate system such as networked robot, are done by cloud robotics is shown in Figure 1. Cloud robotics was designed to be a transition from preprogrammed robotics into interconnected by internet robots [10], [11].

Figure 1. Cloud robots interconnection
A robotic arm means a group of rigidly connected bodies that can be taken different configurations, and move between these configurations with speed and speed restrictions. Industrial robot arms vary in size and some are fixed body, type of joint, joint sequence. Links are many motions to be at each connected and individual points. Robot is constructed by many points such as quantity pivot, degrees of free movement, and the space that the arm can to cover in the working, loading, acceleration and accuracy motion control this survey summarizes a developing issue robot arm [11], [12]. Now, internet is found at any instance [13]. The mechanical and electrical construction are the components used to build the robot arm. To avoid the connection restriction internet controlled robots will connect these wired robots wirelessly to overcome some of the limitations related to space [14], [15]. In this part, summarized to many similar studies is explored to the methods and principles of working are utilized in the past.
Pujari [12]. designed a robot was working. to monitor. the children remotely and communicate with the camera by their families. The robot uses technologies as Wifi, Bluetooth, Raspberry Pi 3 and camera unit. The Raspberry Pi, which is used as a core to the robot and programmed by the Phyton language. Mishi [13] was designed a car of robotic. He was used the Arduino microcontroller Uno with and Raspberry Pi for this purpose. Thus, the system of multi-motion was controlled. Amareswar [14] proposed a robot to the military purposes. The robot was used for the detection of explosives thanks to the detector of the metal, also the surroundings area was viewed by a camera which is installed in Android device. Rao and Sridhar are suggested method that purpose to make agriculture smart using many technologies as automation and IoT. The internet of Things (IoT) enables monitoring to various applications crop growth and selection, the  [15]. In other project, Abhilash and Mani are mixing the robotics and the IoT [16]. The IoT is control the robot, the robot is used here the robot of wheeled due to it is easy using a wheeled robot in a soft and hard surface. Proposed a method for controlling a robotic arm using an open source web application by Jyothsnadevi et al. [17]. It is controlled by using mobile application and for continuous monitoring and observing by the user we use IP web cam application [17]. Ajith and Nambiar [18] are introduces a master slave robotic arm 'SAKSHA'. SAKSHA is a controller for an industrial robotic arm which can be used in factories, medical field and. manufacturing companies. The device can replace the present version. of controllers which are used in industries, make them easy to use and precise [19], [20]. The work proposed by Stelian-Emilian Oltean is platform of a mobile robot which has a constant 4-wheel structure. The platform was designed around the Raspberry Pi computer of single board and control by Arduino Uno to the motion of the structure. The platform was supplied with multi-sensors and a Pi camera in addition it can uplift and transfer the obstacle because it has a robotic arm. [19]. Singh and Shimi [20] and Therib et al. [21] are proposed using lux sensor and temperature sensor respectively to maintained and monitored of conditions of the room as light intensity and temperature of the room. Mishra et al. [22] and Kruse et al. [23] advanced a robotic arm by utilize Arduino uno and make hinges of a robotic arm and control it by making use of servo motor and potentiometer.

PROPOSED METHOD
The implementation process of pick and place things of robot is to make the process of sorting and moving heavy materials to be easy. The transfer process of thing can cause injury to workers if it is done manually and consume more power and time. Thus, using the special purpose robot, the man who works in the factory for example will do his jobs speedily and thus avoid the injuries with increased perform efficiency. In most factories, the work cannot be carried by any type of error, where any error can cost time and money. Therefore, robotic arm movement control so that the arm can pick or place the goods from one place to another. This can be done by sending the commands wirelessly using html designed web page through the WiFi router. Constructing the robotic arm with ultra-sonic sensors for limiting and accuracy of the operation area for an accurate displacement of the things.

THE ARCHITECTURE AND DESIGN
The proposed block diagram of this robotic system is shown in Figure 2 which consists of an Arduino EPS32 board microcontroller and four digital servo motors driven by driver integrated circuit (IC), in addition to a Wifi router and volts-direct current (5 V-DC) power supply. The pick and place robotic arm has a robotic arm put on a fixed base. The pick and place robot utilize 4-motors for the operation of the structure. also, it contains an arm assembly with a selectable jaw or with a screwdriver, which can move up and down direction only. For, the motor controlling is using motor driver IC and Arduino EPS32 microcontroller. The processing signal is provided by a personal computer (PC) or mobile phone via html designed web page to the wireless router. The signal is wireless router. The signal is decoded in the controller when it is sent from the wireless router and suitable controlling signal is sent to actuators (servo engine) in the system.

FLOWCHART OF THE IMPLEMENTED CODE
The Figure 3 describe the methodology for programming of the system. First, we are arising a server instance that obey for hypertext transfer protocol (HTTP) commands on port 80 This port is represented the default port for servers of web. In the platform of Arduino, the signal is transmitted from the router to be read on Arduino utilized the command (if client available). The receiver flag of the Arduino controller is monitored to discover every order is supplied to the controller next mission is decoded the instruct the flag of receiver is high.

SIMULATION AND RESULTS DISCUSSION
The robotic arm is tested in Proteus software before the construction as shown in Figure 4. The arm is constructed using 4-servo motors with Arduino. After the completing the circuit diagram, the simulation shows a good operation by the servo motors. Then arm is ready to be installed for running and performs the duty which is for pick and place or to be used as screw driver for tightening the screws in the appropriate positions. Now we will be talking about the code of the Arduino which let us to control the servo movements by just sending its position in degree value via the web page designed in html language. The servos control lines are: const int Servo A=13; const int Servo B=14; const int Servo C=15; const int Servo D=16; Here we are used to specify the four servos to the pins (13,14,15,16) respectively. You can use other pins as its required. Practically we used ESP32 Arduino for wirelessly, connecting the robotic arm and control on it and movement the dashboard in the web page as shown in the Figure 5. The command which is the: ledcSetup (0, 90, 8) in Arduino, in the setup function, is going to setup the PWM with the ledcSetup function, which receives as input the PWM channel, the final servo position and the duty cycle resolution, i.e the increment in each command time of the slider movement.
The function ledcAttachPin (Servo A, 0) is to attach the servo (A) to the first specified pin (channel) which was the pin (13). This command is repeated to the other servos is being as: ledcSetup (1,90,8); for servos B ledcSetup (2,90,8); for servos C ledcSetup (3,90,8); for servos D The number (8) indicate increment in the servo movement in each step the slider of the dashboard sends. The command serial begins (115200) doesn't actually print anything but It is utilized to set up the communication speed in bits/ second instead of it initializes the connection of serial at 115200 bits per second. To obtain any type of clear data, it is using the same order of serial connection speed by adjust both sides of the serial connection (i.e. the computer and the Arduino). The data are distorting if there doesn't have symmetric in the speed for both the two systems. When the number is making smaller (e.g. serial. begin (300)) the Arduino will be transmitting the data in slow. While rising it, say to 57600 will transmit the data fast. Both the transmitting and the receiving systems need to agree on the speed must to use: the serial program for your computer's, as the window of Arduino serial monitor will let you adjust the speed at that the data is received by your computer but the speed is selected from the common speeds only: 300, 1200, 2400, 4800, 9600, 19200, 38400, 57600 and 11520 bit per sec. Now we have to enter the web page environment which begins with the log in gate. This can be done using the command (if (header. indexOf ("") >= 0) {), this will match the user name and password you have specified to the web page authentication which is shown in Figure 6. If the user name and password is wrong the web page in the Figure 7 will pop up.  After the entering the web page the control section will be in the slider bar, and each servo motor has its own slider bar to be controlled separately by the user. After the entering the web page the control section will be in the slider bar, and each servo motor has its own slider bar to be controlled separately by the user as shown below for servo A and is repeated for the other three ones: client. println("<p>Servo A: <span id=\"servoPosA\"></span></p>"); client. println ("<input type=\"range\" min=\"0\" max=\"50\" class=\"slider\" id=\"servoSliderA\" onchange=\"servo(this.value,'A') \" value=\"" + valueString + "\"/>"); client. println("<script>"); //send A value client. println ("var sliderA = document. getElementById(\"servoSliderA\");"); client. println ("var servoPA = document. getElementById(\"servoPosA\"); servoPA.innerHTML = sliderA.value;"); Our servo motors are installed by the screws on board shown in the Figure 8. They are tightened depending on the angular rotation of servo motors. The rotation degree is to be from 0 to 180 degrees for the base servo which is to rotate the arm. This base handle the remaining three servos to make the bending and the pick and pace of things. The println() method writes data to the serial port. This is often helpful for looking at the data a program is producing or to write data to other devices connected to the serial port. The println method works like print, but sends a new line character for each call to the function. Data can either be a single int, float, byte, long, char, char[], String or a number in decimal (DEC), hexadecimal (HEX), octal (OCT), or binary (BIN) base [24]. The authentication for the log in page can be done using the line command: client. println ("HTTP/1.1 401 Unauthorized"). The 401 Unauthorized error is an HTTP status code that means the page you were trying to access cannot be loaded until you first log in with a valid user identification (ID) and password. If you've just logged in and received the 401 Unauthorized error, it means that the credentials you entered were invalid for some reason. 401 Unauthorized error messages are often customized by each website, especially very large ones, so keep in mind that this error may present itself in more. The 401 Unauthorized error displays inside the web browser window, just as web pages do. Like most errors like these, you can find them in all browsers that run on any operating system [25].

Ultrasonic sensor
Pulse-width modulation (PWM) applications can be found in a number of applications such as communication, servo motor control, voltage regulation, and power conductivity [26], [27]. This paper gives in details the way to measure the PWM display by get the benefit of Arduino. Moreover, how the ultrasonic sensor (which can be used for telemetry) that can make its job with the help of the PWM is an ultrasound sensor that can remotely measure the physical quantities by using the ultrasound waves [28], [29]. The human ear has not the ability to detect ultrasound. This unit has the ability to correctly measure the distance from 2 to 400 cm (1 to 156 inches) and easily be connected together with the Arduino microcontroller. HC-SR04 consumes less energy that makes it a good choice to work in automatic and automatic control systems [30]. The principle of operation of this ultrasonic sensor (HC-SR04) is similar to the of object detection system of a bat which is shown in Figure 9. Ultrasound sensor sends a 40 kHz wireless frequency to the air at 346 meters per second and the receiver get the reflected signal arrived from the reflector body. Then this distance between the received (Rx) and the transmit (Tx) can be simply calculated by the looking at the time taken by the ultrasound to send from the transmitter and reflect back to the receiver which is reflected by the receiver. If we be in the interested calculation to this separating distance between the object and the transmitter, the sensor module is adjusted to do its job. The result of these calculations is depending on the pulse which has a width that is related to the separating measured distance. The HC-SR04 unit diagram has four pins using them in its operation as shown in Figure 10. At the first, it is very useful to study the functionality of the pins of this module sensor.
-Vcc can be supplied up to 5 V.
-Trig pin input is for getting a pulse with a time width of 10 micro seconds to generate the 40 KHz ultrasonic signals to be transmitted into the air from the Tx. -Pin 3 is the pin for receiving the Echo pulses arrived to the module from the objects to the calculate the width of the pulse and then the calculate the distance. -GND is the ground pin.
The characteristics curve of this module is that it generates a series of pulses signals with at least 10 micro second then it will be fed to the Trig pin. After that by about 1.4 milliseconds, it will receive a pulses signals which arrive to the echo pin which has a signal width ranges start from 150 seconds to 25 milliseconds. If the width of the signal is greater than the range above, the sensor module will not be able to detect the object. Therefore, it must wait for about 10 milliseconds and retransmit another Trig signal again as shown in Figure 11. In the Arduino program, we can calculate the object distance which stand in the front of the sensor. At first, the sensor will send a signal at an instance and staying waiting for the answer (reflecting) signal from the standing object or body, i.e the echo again at another particular instance. The Pinging or transmit and receive is about a voice wave that a human can't hear for this sensor is called "ultrasound". In mathematical details, the sensor programmed to send a signal at time t1 and receives a reflected one at time t2. For that, if we know the speed of the sound wave, then the time difference = 2 − 1 will give the idea of the distance between the sensor and the object. For example, if the time difference was Δt=500 microseconds, then it will be known that sound wave takes 250 microseconds to receive and hit the object and another 250 microseconds to be returned. Therefore for accurate operation, the robotic arm equipped with ultra-sonic sensor (HC-SR04) to be used in the accurate approximation between this arm and the aimed things that to be picked and placed, or to be tightened by the screw driver installed at the top which is rotate automatically when the splitting space is zero according to the ultra-sonic sensor reading. Ultra-sonic indicate to a voice wave with a frequency is over 20 kH, which is greater than the upper human. hearing level. Since the (HC-SR04) is depends on the ultra-sonic waves. Then the movement of this wave will be affected by the temperature of the environment it works. Theoretical calculation of the distance the ultrasonic wave travel is by the (1): where v, is the wave velocity (about 340 m/s) in the air at (20 o C). Since the ultra-sonic wave is affected by the temperature of the ambient of working, there must be a modification on the (1) to get the accurate position of the object the robotic arm deals with. Depending on the system specification below, we will develop a modification on the equation (1) to get the excepted results: Frequency of the oscillator= 20 Mhz, Cycle= 4/20 Mhz=0.2 µS and timer count = 0.2*8=1.6 µS At 20 °C sound speed= 34000 cm/sec so within 1.6 µS the distance will be (1.6*0.000001*34000=0.0544 cm per count), but sound distance is twice (because the come and go back), so relationship becomes 0.0544/2=0.0272 cm per count. The sound speed within 1.6 µS the distance will be (1.6*0.000001*34000=0.0544 cm per count), but sound distance is twice (because the come and go back), so relationship becomes 0.0544/2=0.0272 cm per count.
To start the measure, the device needs a pulse of 10 µS on trigger input then send (itself) a burst of 8 periods of 40 Khz (so during 200 µS) then echo output signal goes to 1 status and returns to 0 status when echoes is back timer measures this duration. To avoid to ear the receiver when emitter send the burst salve of 40 khz, timer start must begin to count after (10+210=210 µS). So minimum distance (theatrical) is 210*0.0544=5.712 cm (0.0544 because only one way), and add a little offset for calibration here offset is 1.093 cm. Then the final equation will be. Figure 12 shows the simulation of the effect of the temperature on the ultra-sonic speed which results in drift in the actual distance (2). distance=time*0.028+1.093 (2) Figure 12. Effect of the temperature on the ultrasonic speed

CONCLUSION
The robotic arm is designed and simulated using Proteus software by take the advantages of the Arduino model ESP32 which can be connected to the wireless router. The command is sent from the designed web page to this arm so as to pick or place objects or for tightening the screws of the devices or objects. We can use the speed of sound also (pace of sound) for this purpose. The pace of sound can be equal to (1/Speed of Sound=1/0.03435=29.1 s/cm). Therefore, the equation which is used to calculate the distance will become: D=(Δt/2) / of sound wave pace. This robotic arm here takes the benefits of the ultra-sonic sensor model (HC-SR04) for the best accuracy of working for good proximity between the arm and the objects and to specify the operation area of the arm. Since the sensor depends on the ultra-sonic waves, there will be an effect on its speed by the ambient working temperature, which made the need to the modification of the model distance equation. Finally, the goal of the IOT is can be done using the real internet protocol (IP) to connect to the external world of networks (INTERNET).