Measurement of Acceleration Due to Gravity Using Arduino and Ultrasonic Sensor

In this study, a simple Arduino-based experiment was designed to examine the acceleration of the object during free fall and to calculate the value of “g” (acceleration due to gravity). Experimental data on the free fall of a plastic box through the air was gathered with the help of an ultrasonic distance sensor (HC-SR04). Readings were taken at different intervals during the fall to obtain distance time curves. Acceleration during the free fall was then determined by applying the standard kinematic equations. The shape of the dis-tance-time graphs obtained from the experimental setup was in good agree-ment with the predicted graphs and the calculated values of g lie within the expected range. After repeated experiments, value of gravitational acceleration was found to be 9.805 m/s 2 . Hardware and software prepared for the experiment are sufficient to examine movement of ordinary objects during free fall, therefore the experiment can be easily settled in a laboratory for the pur-pose of learning and teaching.


Introduction
One important problem in School and High School labs (especially in developing countries) is unavailability of modern devices to acquire data. Manual ways to record readings are being used which consume a lot of time and are less accurate [1]. In a recent study, it is proposed by Chen et al. that if the general labs could be equipped with microprocessors and mobile data collection tools, the trend of working in lab will be directed more toward better data analyses instead of spending a lot of time in data collection. This will not only reduce time needed for data acquisition but will also increase precision and accuracy of the data.
Moreover, students will get exposure to the practical use of modern technology [2]. One such bridge between the electronic and mechanical gadgets is made by Arduino which began in 2005 as a tool for students at the Interaction Design Institute Ivrea, Italy, aiming to provide a low-cost and easy way for both students and professionals to create devices that interact with the environment using various types of sensors and actuators. Common examples of such devices intended for beginner hobbyists include simple robots, automated path finding vehicles, thermostats and motion detectors. The simplest and easy to use circuit board available is the Arduino UNO which is equipped with sets of digital and analog input/output pins that may be interfaced to various sensors, expansion boards or other circuits. The board can be powered by the USB cable or by an external 9 volts battery, though it accepts voltages between 7 and 20 volts and is programmable with Arduino IDE (Integrated Development Environment) computer language/software. Therefore, Arduino UNO can provide an easy way to automate and improve various physics lab experiments. Recently, one such work was done by U. Sari who prepared an experimental setup for the calculation of coefficients of friction by the movement of a wooden block on an inclined plan [3].
Among the basic concepts of physics, gravity or gravitation is of utmost importance which is a natural phenomenon by which all things having mass (including planets, stars, galaxies, and even light) are attracted to (or gravitate toward) one another [4] [5]. The gravitational attraction of the original gaseous matter present in the Universe caused it to begin coalescing and forming stars and caused the stars to group together into galaxies, so gravity is responsible for many of the large-scale structures in the Universe [6] [7]. Gravity has an infinite range, although its effects become weaker as objects get further away. On Earth, gravity gives weight to physical objects, and is also necessary for our motion on the surface of the earth. Without gravity, we would have no weight and would not be able to walk around on the earth. Earth attracts every object towards its center with a force which is given by Newton's law of universal gravitation. Due to this force every object in our daily life falls downwards when released from a height. Velocity of the freely falling object increases at a constant rate which is termed as acceleration due to gravity (g). In history, many experiments have been performed to determine the value of g, especially the famous experiment of Italian scientist Galileo which he performed at the leaning tower of Pisa, Italy.
From these experiments scientists have been able to accurately determine the value of g which came out to be 9.8 m/s 2 [4] [5]. Now, after having the availability of microprocessors, sensors and data analysis softwares, it is an interesting task to develop an experimental setup to determine the value of gravitational acceleration for a freely falling body with the aid of modern data acquisition and data analysis tools.
In the present work, we have used Arduino UNO and ultrasonic distance sensor HC-SR04 to measure distance of freely falling body at different intervals of time.
Software's like Microsoft Excel, Origin pro and DESMOS were used to plot the graphs for data analysis. Slope of the distance time curves was determined from the data which was then used in Newton's equations of motion to calculate the acceleration due to gravity. This experiment will not only enhance the interest of students in physics experiments but will also allow them to verify and understand many basic science concepts like sound waves, value of g, Newton's equations of motion, law of universal gravitation, practical implementation of calculus, derivatives and some computer programing.

Theoretical Background
According to Newton's law of universal gravitation, every object in the universe attracts other objects with a force given by Here F is gravitational force, G is gravitational constant, M 1 and M 2 are the masses of the objects and r is the distance between their centers [4] [5]. Earth attracts every object towards its center with a force that can be calculated by using the above relation. For the system of earth and an ordinary object (such as a tennis ball) of mass m, we get Here M e and R e are mass and radius of the earth. Since the distance between the centers of earth and a tennis ball placed near the surface of the earth is nearly equal to the earth's radius, therefore we replaced the distance r with R e . Combining the constants into a single constant termed as g we can simplify the above relation as Comparing this expression with Newton's 2 nd law of motion (F = ma), it becomes clear that g is the acceleration for a freely falling body under the action of earth's gravity, i.e., the velocity of object keeps on increasing with an increment equal to g in each second as long as the object is falling toward the earth.
Motion of the freely falling object can also be analyzed by using the Newton's equations of motion which are Here This is the equation of a straight line ( ) y mx c = + . Therefore, the graph of the distance of a freely falling object from a fixed point versus t 2 should be a straight line, whose slope will be equal to the half of the acceleration According to Equation (1), force of gravity should increase as the distance between the centers of the objects decreases. In the present case, we made the experimental setup in which the maximum change in object's height is less than 1 m which is negligible compared to the total distance between the object's and earth's centers. Therefore, the gravitational force and hence the acceleration due to gravity can be taken as constant during the motion.

Experimental Setup
The apparatus used for collecting the data was constructed from a wooden frame which was 92 cm heigh and 25 cm wide as shown in Figure 1. Arduino UNO circuit board [8] and an HC-SR04 ultrasonic distance sensor [9] were used for data collection and are shown in Figure 2. Arduino UNO was placed on upper face of top plate and ultrasonic sensor was placed in such a way that it points downward. Sensor was electrically connected to Arduino UNO using breadboard and 4 jumper wires. Arduino UNO was connected to computer using the USB cable. Pin configuration for sensor and Arduino is shown in Figure 2.
Here, V cc , GND, Trig, Echo are the power supply, ground, trigger (input) and echo (output) ports of the SR04 sensor. These pins are connected to 5 V, GND,  pin 13 and pin 12 of the Aurdino board. Magnitude of V cc determines the strength of ultrasonic signal generated by SR04. Trig and Echo are the input and output terminal of sensor. Once pin 13 is trigged to on state, SR04 generates an ultrasonic wave which travels and reflects back toward the sensor. If the reflected signal strikes the receiver, SR04 generates a signal in the Echo pin which is transferred to pin 12 of Arduino board and is recorded in the system. By using the value of speed of sound and the time interval between trig and echo signals, distance of the object can be calculated from the relation Sensor SR04 works best between 2 cm -400 cm within a 30 degree cone, and is accurate to the nearest 0.3 cm. Sensor will transmit signal and will then receive the signal reflected from the object's surface. By measuring the time taken by signal, its distance can be calculated (knowing the speed of sound). In the present experiment a plastic box of mass 156 g, length 22.5 cm, width 16.8 cm and height 6.8 cm was dropped from a height of 97 cm. Its distance from the sensor was recorded at various intervals of time during its downward motion under the action of gravity. As explained in the previous section, distance versus square of the time graph can be used to determine the acceleration during the motion (acceleration must be equal to two times of slop of the distance versus time squared graph). Software Arduino IDE was used to operate Arduino and sensor. This softwere is free and can be downloaded and installed on any computer. Origin pro 9 and DESMOS were used for data plotation and analysis.

Arduino Program
Arduino UNO was programed and operated by using software Arduino IDE. Arduino code written in Arduino IDE is given in Figure 3.
On the computer the compiler compiles this code and sends it to the Arduino. After running the Arduino motherboard code, it sends back two experimental measurements to the computer after each 100 ms. Thus, the time (t) of the object that moves away from the sensor and the distance between the sensor and the object are measured. The Arduino Serial Monitor will display the distance between the object and the sensor and the time when the reading was taken. The data can be easily read and written in an Excel table for further analysis. Journal of Sensor Technology

Results
The plastic box was left to fall under the action of gravity and its distance from the sensor was measured after every 100 ms. Experiment was performed several times to attain accurate results. Data points of one such best run are presented in Table 1, while Table 2 shows the same data converted to standard units i.e., the time in seconds and distance in meters. Data points of Table 2 are plotted in Figure 4. Slope of this graph gives the velocity of the object at any time. Here it is important to mention that the increasing slope implies that the velocity of the object keeps on increasing during the motion (as explained in the introduction section).
To calculate the acceleration, data points of Table 2 are plotted as distance versus time squared (Table 3) graph and are presented in Figure 5. This is nearly a straight-line graph as expected. Slope of this graph is equal to half of the acceleration. Therefore, we measured the slope of this line using DESMOS and multiplied it by 2 to get the value of acceleration due to gravity which came out to be ~9.8 m/s 2 which is significantly accurate.

Explanation of c
In the equation of straight line (y = mx + c), c is the point of intersection of line and the y axis. On y-axis we have distance so c will be equal to that initial distance from which we dropped the object. In our case, we dropped the object from 5 cm or 0.005 m, as shown in Tables 1-3. That is why c is taken as 0.005 in all the calculations. Initial distance and hence the value of c can be reduced to 2 cm, as this is the minimum distance to which SR04 can determine the distance of the object accurately.

Summary and Conclusion
A simple Arduino based experiment was designed to measure the acceleration caused by gravity during the free fall motion of the object through air. This physics experiment can be carried out to collect data in an inexpensive and efficient way using an Arduino UNO board, an HC-SR04 ultrasonic distance sensor and a breadboard. A close match can be seen between the obtained distance-time experimental data and the theoretical model. We hope that the teachers will be able to create experiments with the system in this work and can easily examine the free fall motion for objects and determine the free fall acceleration.

Conflicts of Interest
The authors declare no conflicts of interest regarding the publication of this paper.