{"id":17966148,"url":"https://github.com/umer0586/sensagram","last_synced_at":"2025-03-25T07:31:24.521Z","repository":{"id":258337934,"uuid":"868883522","full_name":"umer0586/SensaGram","owner":"umer0586","description":"Stream real-time Android sensor data over UDP with low-latency","archived":false,"fork":false,"pushed_at":"2024-10-21T17:11:53.000Z","size":448,"stargazers_count":8,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-10-22T05:58:30.382Z","etag":null,"topics":["accelerometer","accelerometer-and-gyroscope","android","android-app","android-application","android-sensors","gyroscope","imu","iot","motion-sensors","sensor-data","sensor-fusion","sensor-streaming","sensors","sensors-data-collection","sensors-readings","udp","udp-client","udp-protocol"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/umer0586.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-10-07T10:57:44.000Z","updated_at":"2024-10-21T21:52:43.000Z","dependencies_parsed_at":"2024-10-23T13:33:55.788Z","dependency_job_id":null,"html_url":"https://github.com/umer0586/SensaGram","commit_stats":null,"previous_names":["umer0586/sensagram"],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/umer0586%2FSensaGram","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/umer0586%2FSensaGram/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/umer0586%2FSensaGram/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/umer0586%2FSensaGram/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/umer0586","download_url":"https://codeload.github.com/umer0586/SensaGram/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":222052532,"owners_count":16922720,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["accelerometer","accelerometer-and-gyroscope","android","android-app","android-application","android-sensors","gyroscope","imu","iot","motion-sensors","sensor-data","sensor-fusion","sensor-streaming","sensors","sensors-data-collection","sensors-readings","udp","udp-client","udp-protocol"],"created_at":"2024-10-29T13:07:59.285Z","updated_at":"2025-03-25T07:31:24.512Z","avatar_url":"https://github.com/umer0586.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n \n# SensaGram\n\n \n\u003cimg src=\"https://github.com/umer0586/SensaGram/blob/main/app/src/main/ic_launcher-playstore.png\" width=\"200\"\u003e\n\n[\u003cimg src=\"https://github.com/user-attachments/assets/0f628053-199f-4587-a5b2-034cf027fb99\" height=\"100\"\u003e](https://github.com/umer0586/SensaGram/releases) [\u003cimg src=\"https://fdroid.gitlab.io/artwork/badge/get-it-on.png\" alt=\"Get it on F-Droid\" height=\"100\"\u003e](https://f-droid.org/packages/com.github.umer0586.sensagram/)\n\n![GitHub License](https://img.shields.io/github/license/umer0586/SensaGram?style=for-the-badge) ![Android Badge](https://img.shields.io/badge/Android-5.0+-34A853?logo=android\u0026logoColor=fff\u0026style=for-the-badge) ![Jetpack Compose Badge](https://img.shields.io/badge/Jetpack%20Compose-4285F4?logo=jetpackcompose\u0026logoColor=fff\u0026style=for-the-badge) ![Static Badge](https://img.shields.io/badge/protocol-UDP-teal?style=for-the-badge) ![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/umer0586/SensaGram/build.yml?style=for-the-badge\u0026logo=appveyor)\n ![GitHub Release](https://img.shields.io/github/v/release/umer0586/SensaGram?include_prereleases\u0026style=for-the-badge)\n\n### Stream real-time Android sensor data using [UDP (User Datagram Protocol)](https://en.wikipedia.org/wiki/User_Datagram_Protocol), a connectionless transport layer protocol designed for low-latency, fast data transmission without establishing a persistent connection.\n\n\u003cimg src=\"https://github.com/user-attachments/assets/0f8476cd-add4-4f19-8124-64db871e2e9b\" width=\"250\"\u003e\n\u003cimg src=\"https://github.com/user-attachments/assets/098bc959-ab34-449a-90d8-cdfdc1056e83\" width=\"250\"\u003e\n\u003cimg src=\"https://github.com/user-attachments/assets/bab0c973-4f08-4bfc-bae9-ac8acf3202ae\" width=\"250\"\u003e\n\u003cimg src=\"https://github.com/user-attachments/assets/54cb7935-4306-4c69-a6b6-24a195345a3a\" width=\"250\"\u003e\n\n\u003c/div\u003e\n\n## Usage\nIn the app, select the desired sensors from the list and tap the \"Stream\" button. This will begin transmitting sensor data to the specified address. To receive the data, you'll need to set up a UDP server. The app sends the data in JSON format.\n\nNote : _**You can dynamically control the data stream by selecting or deselecting sensors from the list during active streaming.This allows for flexible management of sensor data transmission.**_\n\n```json\n{\n \"type\": \"android.sensor.accelerometer\",\n \"timestamp\": 3925657519043709,\n \"values\": [0.31892395,-0.97802734,10.049896]\n}\n```\n\n![axis_device](https://user-images.githubusercontent.com/35717992/179351418-bf3b511a-ebea-49bb-af65-5afd5f464e14.png)\n\nwhere\n\n| Array Item  | Description |\n| ------------- | ------------- |\n| values[0]  | Acceleration force along the x axis (including gravity)  |\n| values[1]  | Acceleration force along the y axis (including gravity)  |\n| values[2]  | Acceleration force along the z axis (including gravity)  |\n\nAnd [timestamp](https://developer.android.com/reference/android/hardware/SensorEvent#timestamp) is the time in nanoseconds at which the event happened\n\nUse `JSON` parser to get these individual values.\n\n \n**Note** : *Refer to the following official Android documentation links to understand what each value in the **values** array represents.*\n- For motion sensors [/topics/sensors/sensors_motion](https://developer.android.com/guide/topics/sensors/sensors_motion)\n- For position sensors [/topics/sensors/sensors_position](https://developer.android.com/guide/topics/sensors/sensors_position)\n- For Environmental sensors [/topics/sensors/sensors_environment](https://developer.android.com/guide/topics/sensors/sensors_environment)\n\n## Python example\n\nThe following Python code allows you to receive sensor data from the Sensagram app. The server will listen on all available network interfaces, which is indicated by the address `0.0.0.0`. To set up the server, follow these steps:\n\n#### 1. Clone the Gist repository:\nsee : [udpserver.py](https://gist.github.com/umer0586/1331ac524c525bae7b1c94667ed571de)\n```bash\ngit clone https://gist.github.com/umer0586/1331ac524c525bae7b1c94667ed571de example\ncd example\n```\n\n#### 2. Create a Python file (e.g., server.py) in the example directory and add the following code:\n\n```python\nfrom udpserver import UDPServer\nimport json\n\n\ndef onData(data):\n    jsonData = json.loads(data)\n    sensorType = jsonData[\"type\"]\n    timestamp = jsonData.get(\"timestamp\")\n    values = jsonData.get(\"values\")\n    \n    if sensorType == \"android.sensor.accelerometer\":\n        x, y, z = values\n        print(f\"accelerometer : x = {x}, y = {y}, z = {z} timestamp = {timestamp} \")\n    \n    if sensorType == \"android.sensor.gyroscope\":\n        x, y, z = values\n        print(f\"gyroscope : x = {x}, y = {y}, z = {z} timestamp = {timestamp} \")\n\n    if sensorType == \"android.gps\":\n        longitude, latitude, altitude = jsonData[\"longitude\"], jsonData[\"latitude\"], jsonData[\"altitude\"]\n        bearing, accuracy, speed, time\t= jsonData[\"bearing\"], jsonData[\"accuracy\"], jsonData[\"speed\"], jsonData[\"time\"]\n        \n        print(f\"longitude = {longitude} latitude = {latitude} altitude = {altitude}\")\n        \n        # Fields only for Android 8.0 and above.\n        speedAccuracyMetersPerSecond = jsonData.get(\"speedAccuracyMetersPerSecond\")\n        bearingAccuracyDegrees = jsonData.get(\"bearingAccuracyDegrees\")\n        elapsedRealtimeNanos = jsonData.get(\"elapsedRealtimeNanos\")\n        verticalAccuracyMeters = jsonData.get(\"verticalAccuracyMeters\")\n                \n\n# Initialize the server to listen on all network interfaces (0.0.0.0) and port 8080\nserver = UDPServer(address=(\"0.0.0.0\", 8080))\nserver.setDataCallBack(onData)\nserver.start()\n\n```\nfor GPS data description see [GPS Data Description](https://github.com/umer0586/SensaGram/wiki/GPS-Data-Description)\n\n#### 3 Run the script on the machine you want to receive data on:\n```bash\npython server.py\n```\n#### 4. Configure the Sensagram app:\nIn the app's settings, enter the IP address of the machine running this script. To find your machines's IP address:\n- On **Windows**, use the `ipconfig` command.\n- On **Linux**, use the `ifconfig` command.\n\n## Stream On Boot\nThe app can stream sensor data to a specified address upon device boot. For devices running Android 9 or lower, the app automatically enables Wi-Fi on boot and starts the data stream. However, for devices running Android 10 and later, apps cannot directly control Wi-Fi settings. Therefore, you need to ensure your device's Wi-Fi is enabled before shutting down or restarting. This allows the system to automatically restore the Wi-Fi state when the device boots up. Additionally, make sure the app is not restricted from performing background activities, which you can adjust through your device's system settings.\n\n### Video Demo\nA demonstration of Sensagram's sensor data streaming capabilities via UDP, utilizing a Python script within Blender to map phone orientation and dynamically control the rotation of a 3D object. See [rotate.py](https://gist.github.com/a5b1247b1999848fe16dda340335dfe6.git)\n\n[![IMAGE ALT TEXT HERE](https://img.youtube.com/vi/IxHCX9Im31A/0.jpg)](https://www.youtube.com/watch?v=IxHCX9Im31A)\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fumer0586%2Fsensagram","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fumer0586%2Fsensagram","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fumer0586%2Fsensagram/lists"}