Development of Ultrasonic Anemometer Using HC-SR04 with Kalman Filter Based on Microcontroller Integrated IoT

. Measurement of wind speed using an anemometer is very important in various fields. The most effective and efficient type of anemometer is the ultrasonic anemometer. This research develops an Arduino-based ultrasonic anemometer using the HC-SR04 sensor with a Kalman filter to reduce noise and integrated IoT with the Blynk application on a smartphone. The advantage of ultrasonic anemometer is not having analog signal conditioning and analog filters, thereby reducing the possibility of having noise, low cost, and can be monitored remotely. The ultrasonic anemometer has been calibrated on the wind tunnel and has a measurement resolution of 0.10 m/s and a measurement error of 0.14 m/s.


INTRODUCTION
Wind measurements are needed in various fields, such as military, aviation, shipping, weather monitoring, and many more [1]. Therefore, we need an instrument to measure wind speeds that have high accuracy, are easy to apply, are durable, and are monitored in real-time. An instrument for measuring wind speed is called an anemometer. Anemometer which is being developed based on the working principle has 3 types, namely mechanical anemometer, thermal anemometer, and ultrasonic anemometer [2]. Among these types, anemometer which has many advantages is an ultrasonic anemometer including, having no rotating parts, no speed limit, wide measurement range, high accuracy, and low cost [1].
The working principle of an ultrasonic anemometer uses sound waves as a method of measuring wind speed [11]. The method for determining wind speed using sound waves on an ultrasonic anemometer has 3 types of methods, namely the time difference method [3], the phase difference method [4], and the Doppler method [5]. The most used method is the time difference method because it has an easy application. Anemometer measurements using the time difference method get wind speed based on the Time of Flight (ToF) value.
The main component of an ultrasonic anemometer is an ultrasonic sensor that has transmitter and receiver antennas [11]. Ultrasonic sensors used in ultrasonic anemometers have several types, such as 400EP18A [9] and MCUSD16A40S12RO [7,8]. The sensor requires an electronic circuit to be processed by Arduino. Anemometer design that uses these sensors also requires an analog circuit to send signal impulses to the sensor [2]. Analog signals are easily affected by noise so they can affect the measurement results. This causes the measurement results to have a small standard deviation [2,6]. Noise measurement results can be eliminated by using filters neither analog filters nor digital filters. Ultrasonic anemometers that use analog filters, such as band pass filters, has a measurement errors of 1.9 m/s [7].
The HC-SR04 sensor is one of the sensors that already has signal conditioning. The sensor has an affordable price and is easy to use. HC-SR04 sensor readings have a noise that causes the measurement data consistency to be unstable. Noise on measurement results can be eliminated or reduced with Kalman filter [14].
In this study, an ultrasonic anemometer was made using the HC-SR04 ultrasonic sensor. The advantage of ultrasonic anemometer is an affordable sensor price and there is already signal conditioning and uses a Kalman filter to reduce sensor noise. Also, anemometer has integrated with the internet so that it can be monitored via smartphone. Then anemometer design can be used as a wind measurement that is more accurate, faster, and can be accessed easily.

ULTRASONIC ANEMOMETER
Sound waves propagate in the air medium. The pressure change on the air will affect the wave velocity. This situation can be utilized in the use of ultrasonic waves to measure wind speed [12]. Sound waves emitted by the transmitter at 40 kHz and propagate in the air. If there is a difference pressure in the air that causes the wind to move between the transmitter and receiver, the speed of sound waves in the air at the same time mixed with the speed of the wind. Mathematically written the following equation: s = Tof x (c + ν) (1) ν =( s)/T_of -c (2) Where s is the distance between the transmitter and receiver, c is the wave velocity, Tof is the ultrasonic wave travel time and ν is the wind speed [1]. Variables c and s are fixed variables so ν depends on Tof. Tof is obtained from the HC-SR04 sensor measurements.
The measurement results using the HC-SR04 sensor are not good because they still have noise in the measurement results. To reduce or eliminate noise, a Kalman filter is needed to get better measurement results. Kalman filter is a digital filter that serves to reduce or eliminate measurement noise [13]. The Kalman filter algorithm for ultrasonic sensors is shown by the following equation 〖x _k〗^((-))= x _(k-1) 〖P_k〗^((-))= P_(k-1) + Q (4) K_k= 〖P_k〗^((-)) ( 〖P_k〗^((-)) +R)^(-1) (5) x ̂_k= 〖x _k〗^((-))+ K_k (z_k-〖x _k〗^((-))) (6) P_k=(I-K_k ) 〖P_k〗^((-)) Equations from (3) to (7) can be applied in the software programming languages in the Arduino IDE. The Q value can be determined randomly, while the value of R is obtained by looking for a variation of the sensor measurement data constantly in Microsoft Excel [14].  The speed on the x-axis (νx) is based on the measurement results of the west sensor (νw) and the east sensor (νe). The velocity on the y-axis (νy) is based on the measurement results from the north sensor (νn) and the south sensor (νs). The measurement results between the east sensor and the west sensor are always inversely proportional. If the wind blows eastward, the measurement value of the east sensor will be positive and the west sensor will be negative. The velocity on the x-axis is the result of the measurement value of the sensor which is positive so the velocity on the x-axis is the same as the measurement result on the east sensor.
To determine the speed on the x and y-axis can be seen in the following table.
The minus sign on νw and νs indicates that the positive value of the westward velocity is in the opposite direction to the velocity direction on the x-axis and the positive value of the south velocity is in the opposite direction to the velocity in the y-axis.
Wind speed and wind direction are obtained by adding the vector at the x-axis and y-axis speeds.
Where ν is the wind speed and θ is the wind direction angle [7]. Equation (10) produces wind direction in the form of angles. The resulting angle is between -phi to phi or -180 to 180. Each wind direction is represented by a certain angle given in the following table 2.

METHODS
The ultrasonic anemometer has 2 main parts, namely the sensor and data processing. On the sensor there is an ultrasonic sensor, the transmitter and receiver are desoldering and placed facing each other. Whereas in the data processing section there are HC-SR04 modules, microcontroller, OLED, RTC, SD Card Module, and ESP8266. The working principle of the instrument is illustrated through the block diagram in Figure 4. Ultrasonic anemometer uses a microcontroller to carry out the measurement system. The sensor used is the HC-SR04 sensor which can emit sound waves of 40 kHz. The output from HC-SR04 is a ToF. Then the ToF is added to the Kalman filter to reduce measurement noise. After that the ToF is converted to wind speed according to equation (2), the resulting wind speed is the speed value measured by each sensor. Then look for the resultant wind speed and wind direction. The measurement results are saved on the SD card, displayed on OLED, and sent to the Blynk application on a smartphone via the internet.
All commands and logic on the anemometer are done digitally through programs created using the Arduino IDE software. The microcontroller used uses Arduino Mega 2560. To save measurement data, an SD Card module is used to write data from the microcontroller to the micro SD card. The component used to transfer measurement data via the internet is ESP8266 which has been integrated with the Blynk application on smartphones. Ultrasonic anemometer uses RTC to show the time in real-time at the time of measurement. The electronic circuits of all components are described in the form of a circuit scheme shown in Figure 5. The mechanical design of an ultrasonic anemometer is shown in Figure 6. The ultrasonic anemometer box, which functions as a place for electronic components, is made of 3 mm acrylic. The frame and sensor area are made of 5/8 "diameter PVC pipe which can support the ultrasonic anemometer well and is lightweight. Smartphone applications that are easy to use and support IoT, one of which is Blynk [16]. The interface design in the Blynk application is shown in Figure 7. One of the devices that can connect Arduino Mega with the internet is ESP8266. ESP8266 is a wireless LAN device that is equipped with WiFi features for data exchange.

RESULT
Ultrasonic anemometer testing is done in several stages. The first step is characterization and calibration the HC-SR04 sensor. After that, the HC-SR04 sensor is given a Kalman filter and tested with the process noise covariance to find the optimal filter coefficient. Then the calibration of wind speed and direction in wind tunnels. Finally, anemometer is used to measure wind speed and wind direction in field.

Fig. 8. Ultrasonic anemometer testing in the field
Sensor characterization is measured by the ToF value generated by each sensor with a certain distance to find the relationship between the ToF value and the distance. The distance variations used are 10 cm, 15, cm, 20 cm, 25 cm, 30 cm, 35 cm, 40 cm, 45 cm, and 50 cm.  Figure 9 is a characterization graph for each sensor. The graph shows that each sensor has a different linear regression function. Each sensor shows that the relationship between ToF and distance is directly proportional. The coefficient of determination of the four sensors more than 0.9990 shows that the relationship between ToF and distance is very strong. The equation of the characterization results is then used to determine the relationship between the ToF and the wind speed.
The sensor needs to be calibrated to find out the measurement error made by the sensor. Sensor calibration is done by comparing the results of distance measurements between HCSR-04 sensors using the bar. The measured distance varies between 10 cm, 15 cm, 20 cm, 25 cm, 30 cm, 35 cm, 40 cm, 45 cm and 50 cm.  Data from ToF measurements by each sensor is processed in Microsoft Excel to find the measurement noise covariance value. East sensor has a measurement noise covariance of 23.1656. West sensor has a measurement noise covariance value of 26.4986. North sensor has a measurement noise covariance value of 12.5164. South sensor has a measurement noise covariance value of 13.0401. Each measurement result by each sensor will pass the Kalman filter process so that the Kalman filter coefficient for each sensor differs depending on the process noise covariance value, the measurement noise covariance value, and the ToF of the measurement results.  The blue line is the real time ToF without Kalman filter. While the orange line, the yellow line, the grey line, and the dark blue line is the value of Tof that has been given Kalman filter with different of process noise covariance. From the Kalman filter tests on each sensor, it was found that the Kalman filter was able to reduce noise/fluctuations in the measurement results with an optimal process noise covariance value of 0.25 and 1. The smaller the order of the process noise covariance, the time needed to achieve the equilibrium point is getting longer but can reduce noise better [13]. The Kalman filter equation is entered into the Arduino IDE program algorithm to filter the measured ToF value.
Ultrasonic anemometer calibration is done by comparing the results of digital anemometer measurements with an ultrasonic anemometer. The results of the wind speed of each sensor are vectored so that the total speed of the wind speed measurement results is obtained. The test results found that the measurement value of the ultrasonic anemometer is close to the measurement value of a digital anemometer for several experiments. The biggest measurement error is 0.14 m/s. Ultrasonic anemometer has a resolution of 0.10 m/s. Measurements on the ultrasonic anemometer are unstable because there are several factors, such as air temperature, air pressure, and air turbulence around the anemometer [8].
Testing of the wind direction by comparing the display on the OLED and the direction of the wind source given to the ultrasonic anemometer. Tests carried out with 8 variations of the wind direction, namely, east, southeast, south, southwest, west, northwest, north, and northeast. The test results are given in the following table 5. The results of wind direction testing have no errors in determining the direction of the wind. But there is an error in the results of the angle measurement. The biggest measurement error is at an angle of 45 o and -135 o . The error is caused because at an angle of 45 o has greater turbulence than the angle of 0 o . This is proven by simulations in the Comsol Multiphysics TM software as shown in Figure 15. The air flow from the left at 4 m/s and is represented in green. In figure 15 (a) the simulated angles represent angles 0, 90, 180, and -90, while in Figure 15 (b) the simulated angles represent angles 45, 135, -45, and -135. In Figure 15 (a), the air between sensors B and C do not have large turbulence so the measurement has a small error. In Figure 15 (b), the air between sensors A and B and C and D has large turbulence marked in red which results in a greater measurement error at an angle of 45 o . Wind direction resolution can reach 1 o with the biggest measurement error of 7 o .
After calibration of wind speed and wind direction, an ultrasonic anemometer is tested in the field to measure the wind direction. Ultrasonic anemometer testing was carried out at Diponegoro Hill at 17.19-17.36. Tests carried out the place because the place has a large area of land and has few tree barriers to reduce turbulence that occurs in that place. The test results showed that the results of measurements in the field ranged from 0 to 1.28 m/s which blew east and northeast. The measurement value changes because the wind in that place is not constant. The type of wind that blows at that time is a gentle breeze [18]. The test results show that the IoT system is functioning properly. In sending data to smartphones, ESP8266 will connect to Wi-Fi that has been set in the program and there is a ping that states the power to transfer data, the smaller the ping, the faster the data transfer.

CONCLUSION
The ultrasonic anemometer has been designed and realized by having a feature to store data on a memory card and has been integrated with IoT so that the measurement results can be accessed on a smartphone via the Blynk application. An ultrasonic anemometer has been made with an HC-SR04 sensor which has a measurement error below 1.5% and a Kalman filter has been applied to the HC-SR04 sensor. The results of the ultrasonic anemometer calibration have wind speed measurement resolution of 0.1 m/s measurement error of 0.14 m/s and have wind direction measurement resolution of 1 o with a measurement error of 7 o .