0% found this document useful (0 votes)
5 views9 pages

Real

This project outlines a real-time acceleration monitoring system using an Arduino Uno and an ADXL345 accelerometer, which transmits data to a computer for visualization via a Python script. The system has applications in motion tracking, vibration analysis, and structural health monitoring. Future enhancements include data logging, GUI integration, and wireless transmission capabilities.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views9 pages

Real

This project outlines a real-time acceleration monitoring system using an Arduino Uno and an ADXL345 accelerometer, which transmits data to a computer for visualization via a Python script. The system has applications in motion tracking, vibration analysis, and structural health monitoring. Future enhancements include data logging, GUI integration, and wireless transmission capabilities.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 9

Real-Time Acceleration Monitoring Using

Arduino UNO and ADXL345


Abstract
This project focuses on real-time acceleration monitoring using an Arduino Uno microcontroller
interfaced with an ADXL345 accelerometer. The sensor data is transmitted to a computer via
serial communication and visualized using a Python script. This real-time system enables
accurate tracking and plotting of acceleration values along the X, Y, and Z axes. It has
applications in motion tracking, vibration monitoring, and structural analysis.

1. Introduction
With advancements in embedded systems and sensors, motion detection and tracking have
become increasingly efficient and cost-effective. The ADXL345 is a widely-used three-axis
accelerometer, suitable for high-resolution and low-power motion sensing. In this project, the
ADXL345 is interfaced with the Arduino Uno using I2C communication. The captured
acceleration data is sent to a computer, where a Python script processes and visualizes it in real
time.
This system can be deployed in academic research, sports science, industrial machinery
monitoring, and other domains requiring real-time acceleration feedback.

2. Objective
The main objective of this project is to:
 Interface the ADXL345 accelerometer with the Arduino Uno using I2C protocol.
 Read real-time acceleration data from the sensor.
 Transmit this data via serial to a host computer.
 Visualize acceleration in real-time on the host machine using Python.

3. Applications
 Motion Tracking: Useful in sports and robotics to analyze movement in real time.
 Vibration Analysis: Detect vibrations in engines or structural components.
 Wearable Devices: Integration into wearable tech for health and activity monitoring.
 Vehicle Dynamics: Used in automotive systems to study acceleration forces.
 Structural Health Monitoring: Identify real-time stress or strain responses in buildings.

4. System Overview
Components Required

Arduino UNO Jumper wires

ADXL345 Accelerometer Module USB Cable (for Arduino-PC connection)

4.2 Circuit Diagram and Connections


The ADXL345 operates on 3.3V and communicates via I2C. The connection between the
Arduino and ADXL345 is as follows:
ADXL345 Pin Arduino Uno Pin

VCC 3.3V

GND GND

SDA A4

SCL A5

CS 3.3V

SDO GND (optional)

Circuit diagram for Arduino and adxl345 (accelerometer connections)

5. Arduino Code
The Arduino code initializes the ADXL345 and reads acceleration data along X, Y, and Z axes.
This data is transmitted via serial port in CSV format.

1. #include <Wire.h>
2. #include <Adafruit_ADXL345_U.h>
3.
4. Adafruit_ADXL345_Unified accel = Adafruit_ADXL345_Unified(12345);
5.
6. void setup() {
7. Serial.begin(9600);
8. if (!accel.begin()) {
9. Serial.println("No ADXL345 detected");
10. while (1);
11. }
12. accel.setRange(ADXL345_RANGE_16_G); // max range
13. }
14.
15. void loop() {
16. sensors_event_t event;
17. accel.getEvent(&event);
18.
19. // Send data over serial in CSV format: timestamp(ms), x, y, z
20. unsigned long t = millis();
21. Serial.print(t);
22. Serial.print(",");
23. Serial.print(event.acceleration.x);
24. Serial.print(",");
25. Serial.print(event.acceleration.y);
26. Serial.print(",");
27. Serial.println(event.acceleration.z);
28.
29. delay(100); // 10 Hz sampling
30. }
6. Python Script for Real-Time Visualization
This Python script uses pyserial and matplotlib libraries to receive serial data and display it
dynamically in a scrolling plot.
1. import serial
2. import time
3. import matplotlib.pyplot as plt
4. from collections import deque
5.
6. # === CONFIGURATION ===
7. PORT = 'COM3' # Change as needed
8. BAUD = 9600
9. MAX_TIME = 10 # seconds of data to show on screen
10. REFRESH_RATE = 0.1 # how often the graph updates (in sec)
11.
12. # Connect to Arduino
13. ser = serial.Serial(PORT, BAUD, timeout=1)
14. time.sleep(2)
15. print(f"Connected to {PORT}")
16.
17. # Buffer size (number of data points based on time and refresh rate)
18. buffer_size = int(MAX_TIME / REFRESH_RATE)
19.
20. # Rolling buffers
21. time_buf = deque(maxlen=buffer_size)
22. x_buf = deque(maxlen=buffer_size)
23. y_buf = deque(maxlen=buffer_size)
24. z_buf = deque(maxlen=buffer_size)
25.
26. # Setup plot
27. plt.ion() # interactive mode on
28. fig, (ax1, ax2, ax3) = plt.subplots(3, 1, figsize=(10, 8))
29.
30. def update_plot():
31. ax1.clear()
32. ax2.clear()
33. ax3.clear()
34.
35. ax1.plot(time_buf, x_buf, 'r')
36. ax2.plot(time_buf, y_buf, 'g')
37. ax3.plot(time_buf, z_buf, 'b')
38.
39. ax1.set_title("X Axis Acceleration")
40. ax2.set_title("Y Axis Acceleration")
41. ax3.set_title("Z Axis Acceleration")
42.
43. for ax in (ax1, ax2, ax3):
44. ax.set_xlabel("Time (s)")
45. ax.set_ylabel("Accel (m/s²)")
46. ax.grid(True)
47.
48. plt.tight_layout()
49. plt.pause(0.01)
50.
51. # === Main loop ===
52. start_time = time.time()
53. while True:
54. try:
55. line = ser.readline().decode().strip()
56. if not line:
57. continue
58.
59. parts = line.split(',')
60. if len(parts) != 4:
61. continue
62.
63. t_ms, x, y, z = map(float, parts)
64. t = (t_ms / 1000.0) - (start_time) # make time relative to script start
65.
66. time_buf.append(t)
67. x_buf.append(x)
68. y_buf.append(y)
69. z_buf.append(z)
70.
71. update_plot()
72.
73. time.sleep(REFRESH_RATE)
74.
75. except KeyboardInterrupt:
76. print("Exiting...")
77. break
78. except Exception as e:
79. print("Error:", e)
80.
81. ser.close()

7. Results and Discussion


The system successfully visualizes real-time acceleration data on three separate plots
corresponding to the X, Y, and Z axes. The use of deque allows for efficient data handling with a
rolling buffer. This makes the system responsive and efficient for use in long-term monitoring
setups.
By observing changes in the acceleration plots, users can correlate movements or vibrations with
the environment in which the ADXL345 is placed. The responsiveness of the system allows it to
be used in dynamic situations like sports movements or mechanical stress testing.
8. Conclusion
This project demonstrates the real-time acquisition and visualization of acceleration data using
an Arduino Uno and ADXL345 accelerometer. With simple hardware and open-source software,
a powerful motion tracking system can be built and customized for a wide range of applications.
The modularity and real-time features make it an excellent base for further development in both
educational and industrial domains.
9. Future Enhancements
 Logging data to a CSV file for offline analysis
 Adding GUI elements using PyQt or Tkinter
 Implementing wireless data transmission using Bluetooth or WiFi
 Performing real-time FFT for vibration frequency analysis
 Estimating velocity and displacement via integration

You might also like