This is an Android application built with Jetpack Compose that demonstrates how to use the device's accelerometer sensor to collect and display sensor data, store the data in a local Room database, and visualize the data using the MPAndroidChart library.
- Collects accelerometer data (x, y, z values) at a specified rate
- Displays the current accelerometer values on the main screen
- Stores the accelerometer data in a local Room database
- Exports the database data to a CSV file
- Displays line charts for the x, y, and z accelerometer values over time
- Android Studio
- Android device or emulator
-
Clone the repository:
git clone https://github.com/Sarthak-100/Sensor_App.git
-
Open the project in Android Studio.
-
Build and run the app on your Android device or emulator.
-
When the app starts, it will display the current accelerometer values on the main screen.
-
To export the database data to a CSV file, click the "Export Data" button. The exported file will be saved in the app's external files directory with the name "database_export.csv".
-
To view the line charts of the accelerometer data over time, click the "Go to Graph" button. This will navigate to a new screen displaying three charts: one for the x-axis, one for the y-axis, and one for the z-axis.
-
You can zoom in and out of the charts by pinching the screen.
MainActivity.kt
: The main activity of the app, responsible for setting up the Jetpack Compose UI, handling sensor events, and managing the Room database.AccelerometerData.kt
: The data class representing an accelerometer data entry, annotated with@Entity
for Room database integration.AccelerometerDao.kt
: The Data Access Object interface for interacting with the Room database.AppDatabase.kt
: The Room database class, providing access to theAccelerometerDao
.SensorDataDisplay.kt
: A Composable function that displays the current accelerometer values and provides buttons for exporting data and navigating to the graph screen.GraphScreen.kt
: A Composable function that displays line charts for the x, y, and z accelerometer values over time, using the MPAndroidChart library.
This project uses the following dependencies:
- Jetpack Compose
- Room
- MPAndroidChart
- OpenCSV
Contributions are welcome! If you find any issues or have suggestions for improvements, please open an issue or submit a pull request.
This project is licensed under the MIT License.