J. Mechatron. Electr. Power Veh. Technol 06 (2015) 1–8 Journal of Mechatronics, Electrical Power, and Vehicular Technology e-ISSN:2088-6985 p-ISSN: 2087-3379 www.mevjournal.com © 2015 RCEPM - LIPI All rights reserved. Open access under CC BY-NC-SA license. Accreditation Number: 633/AU/P2MI-LIPI/03/2015. doi: 10.14203/j.mev.2015.v6.1-8 DEVELOPMENT OF A MICROCONTROLLER-BASED WIRELESS ACCELEROMETER FOR KINEMATIC ANALYSIS Maria Clarissa Alvarez Carasco a, *, Jan Pierre Potato Pizarro a , Giovanni Alarkon Tapang a a Versatile Instrumentation System for Science Education and Research National Institute of Physics, University of the Philippines Diliman, Quezon City, Philippines Received 14 October 2014; received in revised form 14 February 2015; accepted 16 February 2015 Published online 30 July 2015 Abstract Wireless Sensor Networks (WSNs) allow real-time measurement and monitoring with less complexity and more efficient in terms of obtaining data when the subject is in motion. It eliminates the limitations introduced by wired connections between the sensors and the central processing unit. Although wireless technology is widely used around the world, not much has been applied for education. Through versatile instrumentation system for science education and research (VISSER), a project which aims to develop modern science laboratory equipment for high school education and research in the Philippines, a low cost WSN using nRF24L01+ RF transceiver that is developed to observe and analyze the kinematics of a moving object is discussed in this paper. Data acquisition and transmission is realized with the use of a low power and low cost microcontroller ATtiny85 that obtains data from the ADXL345 three-axis accelerometer. An ATtiny85 also controls the receiving module with a UART connection to the computer. Data gathered are then processed in an open-source programming language to determine properties of an object’s motion such as pitch and roll (tilt), acceleration and displacement. This paper discusses the application of the developed WSN for the kinematics analysis of a toy car moving on flat and inclined surfaces along the three axes. The developed system can be used in various motion detection and other kinematics applications, as well as physics laboratory activities for educational purposes. Keywords: wireless sensor network; accelerometer; kinematics; nRF24L01+. I. INTRODUCTION With the world pushing forward towards the Internet of Things (IoT), which improves the transfer of information without much human interaction, almost everything is going wireless. Wireless technology is already being used in the industry, home automation and monitoring applications. Wireless Sensor Networks (WSNs) are one of the key components in the IoT, which serves as ground for information about physical quantities of the world that can be accessed remotely by any computing system. WSN integrates sensing, communication and computation capabilities into a single, compact device. This addresses the challenges of detecting significant quantities, monitoring and collecting data, and analyzing the information gathered [1, 2]. Wireless sensor networks eliminate the complexity in connections for wired systems and allow free movement for bodies with on-board sensors. Numerous designs for wireless sensor networks have already been published. WSNs have been developed for health care that can monitor physiological conditions, motion and activity such as accidental falls [3, 4], and behavioral patterns [5]. Aside from medical and health care; various prototypes have been made for environmental monitoring like temperature [6], soil moisture and temperature in croplands [7], and a cluster of environmental factors can be analyzed from WSN data like solar radiations, CO2 flux, wind, water contamination, etc [8]. Papers on WSNs for industrial monitoring applications have also been published like fault analysis in the electrical field [9, 10]. Still, there have only been few efforts in incorporating such technology in the field of science education. In the Philippines, a 2012 official report stated that only 2,809 public high schools out of 7,470 had science laboratories [11], moreover some of the laboratory devices of those who have are outdated or incomplete. Although there are science laboratory equipment * Corresponding Author.Phone: +632 9209749 E-mail: clarissa.carasco@gmail.com M.C.A. Carasco et al. / J. Mechatron. Electr. Power Veh. Technol 06 (2015) 1–8 2 available in the market, they are expensive and public high schools cannot afford them. To improve the quality of science education and the state of science laboratories in high schools, Versatile Instrumentation System for Science Education and Research (VISSER) develops laboratory devices (e.g. sensors) that incorporate modern technology such as wireless capabilities and multiple interfacing of data- gathering devices. The developed devices must be robust, sophisticated and low cost so that public high schools and institutes can afford those [12]. In line with the goals of VISSER, a design of a wireless sensor network that is applied to kinematic analysis, such as acceleration of an object moving on flat and inclined surfaces, is developed. The main goal is to implement the wireless sensor network design with low cost and low power components. II. METHODOLOGY A. System Architecture Figure 1 shows the overall design of the wireless sensor network. The accelerometer is connected to the microcontroller unit (MCU) through Serial Peripheral Interface (SPI) and a radio frequency (RF) transceiver module is used to transmit the data to the central receiving module. The RF transceiver is connected to the microcontroller via SPI as well. For the receiving side, a similar architecture is used. A microcontroller accesses the transceiver through SPI and sends the data to a PC application via UART. Sensor ADXL345 Microcontroller ATtiny85 RF Transceiver nRF24L01+ (a) RF Transceiver nRF24L01+ Microcontroller ATtiny85 PCPC (b) Figure 1. System overview of: (a) Transmitter module; (b) Receiver module M.C.A. Carasco et al. / J. Mechatron. Electr. Power Veh. Technol 06 (2015) 1–8 3 B. Microcontroller The system uses ATtiny85, a low power and low cost CMOS8-bit microcontroller that is based on the AVR advanced RISC structure, as its main processor [13]. It is an 8-pin microcontroller that can be powered with a voltage supply of 1.8 V – 5.5 V and draws about 300 μA when in active mode and 0.1 μA when in power-down mode, both at 1.8 input voltage. The ATtiny85 has 8 kbytes of program memory that is In-System programmable via SPI ports. Although the program memory of the microcontroller is smaller than many other chips, 8 kbytes is enough for our application. Also, the microcontroller has 6 programmable I/O lines but out of the 6 I/O lines of the ATtiny85, only five are used actively as I/O pins with the default setting of the fuses. These I/O lines can also be configured for I2C or SPI interface using Universal Serial Interface (USI) to communicate with one or multiple slave devices such as sensors, (e.g. accelerometer), real-time clocks, SD card modules, etc. The ATtiny85 is chosen because of its cost which is around $1 and can be easily bought in electronics stores and online shops. C. Radio Frequency Transceiver The nRF24L01+ (see Figure 2) is an RF transceiver that operates at the 2.4 GHz industrial, scientific and medical (ISM) radio band and uses the Enhanced ShockBurst™ protocol engine for ultra-low power wireless applications [14]. Some of the key features of Enhanced ShockBurst™ are:  1 to 32 bytes dynamic payload length  Automatic packet handling  Auto packet transaction handling  Auto acknowledgement  Auto retransmission  6 data pipe MultiCeiver™ for 1:6 star networks. It is also a low power device consuming only 11.3 mA when in transmitting mode and 12.3 mA at 2 Mbps receiving mode. The nRF24L01+ transceiver can be powered with 1.9 V – 3.6 V. In standby mode, the nRF24L01+ uses 22 μA and is disabled with 900 nA current consumption when in power-down mode. The air data rate, output power and frequency channel settings are user- programmable via SPI. It can be used with speeds of 1Mbps or 2Mbps. This RF transceiver utilizes a minimum of 7 pins, 4 I/O pins for SPI interfacing, 1 pin as enable and 2 pins for the supply. This means that all the available I/O ports of the ATtiny85 will be used by the RF transceiver alone. The nRF24L01+ transceiver is available for less than $1 which makes it suitable for the low cost WSN design. D. Sensor and Transmitter Module Design In order to gather data regarding the motion of the subject, ADXL345 accelerometer is used. The ADXL345 is a three-axis accelerometer that measures static acceleration of gravity, as well as Figure 2. nRF24L01+ transceiver circuit schematic M.C.A. Carasco et al. / J. Mechatron. Electr. Power Veh. Technol 06 (2015) 1–8 4 dynamic acceleration resulting from motion. It has a supply range of 2 V – 3.6 V and consumes 23 μA in measuring mode and 0.1 μA in standby mode with 2.5 V input. It has a user-selectable measurement range of ±2 g, ±4 g, ±8 g, and ±16 g and output resolution of up to 13-bit at ±16 g [15]. The accelerometer can be interfaced to the microcontroller via SPI (3-wire and 4-wire) and I2C. For this application, the ADXL345 accelerometer is accessed by the microcontroller via 4-wire SPI and selects the full range ±16 g resolution. Since all the pins for one microcontroller is being used by the RF transceiver alone, a second ATtiny85 is utilized. Figure 3 shows the block diagram for the solution to lack of pins in the microcontroller. The first microcontroller (MCU1) accesses the accelerometer via SPI and passes the data gathered to another microcontroller via RX/TX. The accelerometer uses the 4 I/O pins of the microcontroller leaving one free I/O pin that is used as TX line to the second microcontroller. The second microcontroller will then retrieve the data serially then pass it on to the RF transceiver for final relaying of data to the receiving module. The fuse of the second microcontroller (MCU2) is altered from the default settings in order to use Reset pin as “weak” I/O port to free up one I/O pin for serial communications. The RSTDISBL is programmed to use pin 1 as an I/O port. Figure 4 shows the flow chart of the hardware program for the two microcontrollers (MCU1 and MCU2). The two programs in each MCUs run simultaneously once the transmitter module is powered. RX TX ADXL345 Accelerometer SCK MOSI MISO CS ATtiny85 microcontroller ATtiny85 microcontroller SCK MOSI MISO CS nRF24L01+ RF transceiver Figure 3. Block diagram of the transmitter module Figure 4. Flow chart for the transmitter module hardware program M.C.A. Carasco et al. / J. Mechatron. Electr. Power Veh. Technol 06 (2015) 1–8 5 E. Receiver Module Design The receiver module uses the same microcontroller and transceiver for data reception. Shown in Figure 5 is the block diagram of the receiver module. After receiving the data from the transmitter module, the microcontroller passes it now to the PC for data storage and analysis via RX/TX to USB connection. F. Data Handling and Storage The data sent from the RX/TX lines of the PC are saved in a file for later analysis. Python, a general-purpose, high-level (HLL) programming language, is used to read the data from the serial line, and store the time-stamped data locally in the computer. III. TESTING AND RESULTS Figure 6 shows the prototype developed for the transmitter module. The prototype is modular and compact. It is powered by a CR2032 3-volts coin battery. The prototype is tested by placing the transmitter module onboard a toy car and then measuring the triaxial acceleration of the toy car when pulled/pushed and when let down on an inclined plane. Figure 7 shows the triaxial acceleration when pulling then pushing the toy car with the attached sensor along the y-axis. The acceleration along the z axis does not change since the subject does not experience acceleration due to motion and is affected only by the earth’s pull. The negative values denote that the subject is moving along the positive direction of the y-axis. On the other hand, the negative values denote that the subject is moving in the opposite side of the y-axis. Although the expectation is that no acceleration is present for the x-axis, the plot shows that there are readings at some points. This is due to the movement of the axle of the toy car’s wheels which is not fixed. Also, the ideal straight line path of the toy car is not possible RX TX nRF24L01+ RF transceiver SCK MOSI MISO CS ATtiny85 microcontroller Computer Figure 5. Block diagram of the receiver module Figure 6. Prototype of the transmitter module M.C.A. Carasco et al. / J. Mechatron. Electr. Power Veh. Technol 06 (2015) 1–8 6 with this type of front wheels. Hence, the readings in x-axis. Also, in order to test if the transmitter is working along the z-axis, the toy car with the attached sensor is made to go down an inclined plane. Figure 8 shows the acceleration when in an inclined plane with 21.3 degrees. Figure 9 shows the result for an inclination of 36.06 degrees. It is shown in the Figures 8 and 9 that the value of acceleration at z-axis is changing when the subject is on an inclined plane. Also the value of the acceleration at y-axis varies since the forward movement of the subject is not only towards z-axis but also aligned with y-axis. While the accelerations at x-axis is low since there is no significant movement along this axis. The graphs above are only preliminary tests which show that the wireless accelerometer is working and behaves as expected. The device can now be calibrated as a next step. Figure 7. Acceleration vs time for pushing/pulling of toy car Figure 8. Acceleration vs time for inclined plane with Ө = 21.38 degrees M.C.A. Carasco et al. / J. Mechatron. Electr. Power Veh. Technol 06 (2015) 1–8 7 IV. CONCLUSION The wireless sensor network developed is capable of determining the kinematics of an object moving on a flat and inclined surface along the three axes. Also, other properties of an object’s motion such as pitch and roll, and free fall detection, can be obtained and analyzed from the stored raw data. The integration of wireless technology to kinematic analysis delivers a more efficient way of data gathering. Such sensor network can be applied to physics laboratory experiments for educational purposes. This kind of technological advancement for science education would lead to the realization of the goal of VISSER. For further improvements, a user-interface which can set when to start and stop data gathering can be included in the system. ACKNOWLEDGEMENT This paper is a part of the Versatile Instrument System for Science Education and Research (VISSER), a project funded by the Department of Science and Technology (DOST) and University of the Philippines Emerging Interdisciplinary Research (UP EIDR). REFERENCES [1] R. Roman, et al., “Do wireless sensor networks need to be completely integrated into the internet?” Future Internet of People, Things and Services (IoPTS) eco- Systems, Brussels. 2nd, December. 2009. [2] F.L. Lewis, “Wireless sensor networks,” Smart Environments: Technologies, Protocols, and Applications, New York, 2004. [3] Y. Lee, et al., “Implementation PF accelerometer sensor module and fall detection monitoring system based on wireless sensor network,” Proceedings of the 29 th Annual International Conference of the IEEE EMBS, Cite Internationale, Lyon, France, August. 2007. [4] H. Chan, et al., “Wireless body area network for physical-activity classification and fall detection,” 5th International Summer School and Symposium on Medical Devices and Biosensors, June. 2008. [5] Z. Zhang and X. Hu, “ZigBee based wireless sensor networks and their use in medical and health care domain,” Seventh International Conference on Sensing Technology, 2013. [6] Y. Zhu, et al., “Design of wireless multi- point temperature transmission system based on nRF24L01,” International Conference on Business Management and Electronic Information (BMEI), 2011. [7] H. Liu, et al., “A wireless sensor network for cropl and environmental monitoring,” International Conference on Networks, Security, Wireless Communications and Trusted Computing, 2009. [8] R. Mittal and M.P.S. Bhatia, “Wireless sensor networks for monitoring the environmental activities,” IEEE 2010. Figure 9. Acceleration vs time for inclined plane with Ө = 36.03 degrees M.C.A. Carasco et al. / J. Mechatron. Electr. Power Veh. Technol 06 (2015) 1–8 8 [9] L. Hou and W. Bergmann, “Novel industrial wireless sensor networks for machine condition and fault diagnosis,” IEEE Transactions on Instrumentation and Measurement, Vol. 61 No. 10, October 2012. [10] F. Salvadori, et al., ”Monitoring and diagnosis in industrial systems using wireless sensor networks,” IEEE, 2007. [11] S. Panela. (2012, Sept. 17). Do top PHL schools' low world rankings reflect state of science ed in country? [Online]. Available: http://www.gmanetwork.com/news/story/27 4398/scitech/science/do-top-phl-schools- low-world-rankings-reflect-state-of-science- ed-in-country [12] Philippine-American Academy of Science and Engineering. VISSER: Versatile instrumentation system for science education and research. [Online], 2011, Available: http://www.paase.org/visser.html [13] Atmel, “Atmel 8-bit AVR microcontroller with 2/4/8 K Bytes in-system programmable flash,” ATtiny85 datasheet, 2013. [14] Nordic Semiconductor, “nRF24L01+ single chip 2.4 GHz transceiver preliminary product specification v1.0,” nRF24L01+ datasheet, March 2008. [15] Analog Devices, “3-Axis, ±2 g/±4 g/±8 g/±16 g digital accelerometer,” ADXL345 data sheet, 2013.