{"id":20804399,"url":"https://github.com/umer0586/sensorserver","last_synced_at":"2025-05-16T13:06:02.381Z","repository":{"id":41899274,"uuid":"423570329","full_name":"umer0586/SensorServer","owner":"umer0586","description":"Android app which let you stream various phone's sensors to websocket clients ","archived":false,"fork":false,"pushed_at":"2025-02-02T09:58:30.000Z","size":7510,"stargazers_count":302,"open_issues_count":2,"forks_count":33,"subscribers_count":11,"default_branch":"main","last_synced_at":"2025-04-03T09:08:24.068Z","etag":null,"topics":["accelerometer","accelerometer-and-gyroscope","android","android-app","android-sensor","android-sensors","android-sensortypes","gps","imu","internet-of-things","iot","iot-application","iot-sensors","motion-sensors","sensor","sensor-streaming","sensors","sensors-data","sensors-data-collection","websocket"],"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":"2021-11-01T18:16:16.000Z","updated_at":"2025-03-25T17:43:06.000Z","dependencies_parsed_at":"2024-10-23T18:44:44.739Z","dependency_job_id":"7ab6e5f8-8f2d-42e7-abb5-f5c75b4b51c1","html_url":"https://github.com/umer0586/SensorServer","commit_stats":null,"previous_names":[],"tags_count":38,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/umer0586%2FSensorServer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/umer0586%2FSensorServer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/umer0586%2FSensorServer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/umer0586%2FSensorServer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/umer0586","download_url":"https://codeload.github.com/umer0586/SensorServer/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248530877,"owners_count":21119654,"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-sensor","android-sensors","android-sensortypes","gps","imu","internet-of-things","iot","iot-application","iot-sensors","motion-sensors","sensor","sensor-streaming","sensors","sensors-data","sensors-data-collection","websocket"],"created_at":"2024-11-17T19:09:10.911Z","updated_at":"2025-05-16T13:06:02.373Z","avatar_url":"https://github.com/umer0586.png","language":"Kotlin","readme":"\u003cdiv align=\"center\"\u003e\n\n# SensorServer\n![GitHub](https://img.shields.io/github/license/umer0586/SensorServer?style=for-the-badge) ![GitHub release (latest SemVer)](https://img.shields.io/github/v/release/umer0586/SensorServer?style=for-the-badge) ![GitHub all releases](https://img.shields.io/github/downloads/umer0586/SensorServer/total?label=GitHub%20downloads\u0026style=for-the-badge) ![Android](https://img.shields.io/badge/Android%205.0+-3DDC84?style=for-the-badge\u0026logo=android\u0026logoColor=white) ![F-Droid](https://img.shields.io/f-droid/v/github.umer0586.sensorserver?style=for-the-badge) ![Websocket](https://img.shields.io/badge/protocol-websocket-green?style=for-the-badge)\n\n[\u003cimg src=\"https://github.com/user-attachments/assets/0f628053-199f-4587-a5b2-034cf027fb99\" height=\"100\"\u003e](https://github.com/umer0586/SensorServer/releases) [\u003cimg src=\"https://fdroid.gitlab.io/artwork/badge/get-it-on.png\"\n    alt=\"Get it on F-Droid\"\n    height=\"100\"\u003e](https://f-droid.org/packages/github.umer0586.sensorserver)\n\n \n### SensorServer transforms Android device into a versatile sensor hub, providing real-time access to its entire array of sensors. It allows multiple Websocket clients to simultaneously connect and retrieve live sensor data.The app exposes all available sensors of the Android device, enabling WebSocket clients to read sensor data related to device position, motion (e.g., accelerometer, gyroscope), environment (e.g., temperature, light, pressure), GPS location, and even touchscreen interactions.\n\n\u003cimg src=\"https://github.com/umer0586/SensorServer/blob/main/fastlane/metadata/android/en-US/images/phoneScreenshots/01.png\" width=\"250\" heigth=\"250\"\u003e \u003cimg src=\"https://github.com/umer0586/SensorServer/blob/main/fastlane/metadata/android/en-US/images/phoneScreenshots/02.png\" width=\"250\" heigth=\"250\"\u003e \u003cimg src=\"https://github.com/umer0586/SensorServer/blob/main/fastlane/metadata/android/en-US/images/phoneScreenshots/03.png\" width=\"250\" heigth=\"250\"\u003e \u003cimg src=\"https://github.com/umer0586/SensorServer/blob/main/fastlane/metadata/android/en-US/images/phoneScreenshots/04.png\" width=\"250\" heigth=\"250\"\u003e \u003cimg src=\"https://github.com/umer0586/SensorServer/blob/main/fastlane/metadata/android/en-US/images/phoneScreenshots/05.png\" width=\"250\" heigth=\"250\"\u003e \u003cimg src=\"https://github.com/umer0586/SensorServer/blob/main/fastlane/metadata/android/en-US/images/phoneScreenshots/06.png\" width=\"250\" heigth=\"250\"\u003e\n\u003cimg src=\"https://github.com/umer0586/SensorServer/blob/main/fastlane/metadata/android/en-US/images/phoneScreenshots/07.png\" width=\"250\" heigth=\"250\"\u003e\n\n\u003c/div\u003e\n\n\n\nSince this application functions as a Websocket Server, you will require a Websocket Client API to establish a connection with the application. To obtain a Websocket library for your preferred programming language click [here](https://github.com/facundofarias/awesome-websockets). \n \n \n \n \n # Usage\n To receive sensor data, **Websocket client**  must connect to the app using following **URL**.\n \n                 ws://\u003cip\u003e:\u003cport\u003e/sensor/connect?type=\u003csensor type here\u003e \n \n \n  Value for the `type` parameter can be found by navigating to **Available Sensors** in the app. \n \n For example\n \n * For **accelerometer** `/sensor/connect?type=android.sensor.accelerometer` .\n \n * For **gyroscope** `/sensor/connect?type=android.sensor.gyroscope` .\n \n * For **step detector**  `/sensor/connect?type=android.sensor.step_detector`\n\n * so on... \n \n Once connected, client will receive sensor data in `JSON Array` (float type values) through `websocket.onMessage`. \n \n A snapshot from accelerometer.\n \n ```json\n{\n  \"accuracy\": 2,\n  \"timestamp\": 3925657519043709,\n  \"values\": [0.31892395,-0.97802734,10.049896]\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** : *Use  following links to know what each value in **values** array corresponds to*\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## Undocumented (mostly QTI) sensors on Android devices\nSome Android devices have additional sensors like **Coarse Motion Classifier** `(com.qti.sensor.motion_classifier)`, **Basic Gesture** `(com.qti.sensor.basic_gestures)` etc  which are not documented on offical android docs. Please refer to this [Blog](https://louis993546.medium.com/quick-tech-support-undocumented-mostly-qti-sensors-on-android-devices-d7e2fb6c5064) for corresponding values in `values` array  \n\n## Supports multiple connections to multiple sensors simultaneously\n\nMultiple WebSocket clients can connect to a specific type of sensor. For example, by connecting to `/sensor/connect?type=android.sensor.accelerometer` multiple times, separate connections to the accelerometer sensor are created. Each connected client will receive accelerometer data simultaneously.\n\nAdditionally, it is possible to connect to different types of sensors from either the same or different machines. For instance, one WebSocket client object can connect to the accelerometer, while another WebSocket client object can connect to the gyroscope. To view all active connections, you can select the \"Connections\" navigation button.\n \n## Example: Websocket client (Python) \nHere is a simple websocket client in python using [websocket-client api](https://github.com/websocket-client/websocket-client) which receives live data from accelerometer sensor.\n\n```python\nimport websocket\nimport json\n\n\ndef on_message(ws, message):\n    values = json.loads(message)['values']\n    x = values[0]\n    y = values[1]\n    z = values[2]\n    print(\"x = \", x , \"y = \", y , \"z = \", z )\n\ndef on_error(ws, error):\n    print(\"error occurred \", error)\n    \ndef on_close(ws, close_code, reason):\n    print(\"connection closed : \", reason)\n    \ndef on_open(ws):\n    print(\"connected\")\n    \n\ndef connect(url):\n    ws = websocket.WebSocketApp(url,\n                              on_open=on_open,\n                              on_message=on_message,\n                              on_error=on_error,\n                              on_close=on_close)\n\n    ws.run_forever()\n \n \nconnect(\"ws://192.168.0.103:8080/sensor/connect?type=android.sensor.accelerometer\") \n\n```\n *Your device's IP might be different when you tap start button, so make sure you are using correct IP address at client side*\n\n Also see [\nConnecting to Multiple Sensors Using Threading in Python](https://github.com/umer0586/SensorServer/wiki/Connecting-to-Multiple-Sensors-Using-Threading-in-Python) \n\n\n## Connecting To The Server without hardcoding IP Address and Port No\nIn networks using DHCP (Dynamic Host Configuration Protocol), devices frequently receive different IP addresses upon reconnection, making it impractical to rely on hardcoded network configurations. To address this challenge, the app supports Zero-configuration networking (Zeroconf/mDNS), enabling automatic server discovery on local networks. This feature eliminates the need for clients to hardcode IP addresses and port numbers when connecting to the WebSocket server. When enabled by the app user, the server broadcasts its presence on the network using the service type `_websocket._tcp`, allowing clients to discover the server automatically. Clients can now implement service discovery to locate the server dynamically, rather than relying on hardcoded network configurations.\n\nSee complete python Example at [Connecting To the Server Using Service Discovery](https://github.com/umer0586/SensorServer/wiki/Connecting-To-the-Server-Using-Service-Discovery) \n \n## Using Multiple Sensors Over single Websocket Connection\nYou can also connect to multiple sensors over single websocket connection. To use multiple sensors over single websocket connection use following **URL**.\n\n                 ws://\u003cip\u003e:\u003cport\u003e/sensors/connect?types=[\"\u003ctype1\u003e\",\"\u003ctype2\u003e\",\"\u003ctype3\u003e\"...]\n\nBy connecting using above URL you will receive JSON response containing sensor data along with a type of sensor. See complete example at [Using Multiple Sensors On Single Websocket Connection](https://github.com/umer0586/SensorServer/wiki/Using-Multiple-Sensors-On-Single-Websocket-Connection). Avoid connecting too many sensors over single connection\n\n## Reading Touch Screen Data\nBy connecting to the address `ws://\u003cip\u003e:\u003cport\u003e/touchscreen`, clients can receive touch screen events in following JSON formate.\n\n|   Key   |   Value                  |\n|:-------:|:-----------------------:|\n|   x     |         x coordinate of touch           |\n|   y     |         y coordinate of touch          |\n| action  | ACTION_MOVE or ACTION_UP or ACTION_DOWN |\n\n\"ACTION_DOWN\" indicates that a user has touched the screen.\n\"ACTION_UP\" means the user has removed their finger from the screen.\n\"ACTION_MOVE\" implies the user is sliding their finger across the screen.\nSee [Controlling Mouse Movement Using SensorServer app](https://github.com/umer0586/SensorServer/wiki/Controlling-Mouse-Using-SensorServer-App)\n\n## Getting Device Location Using GPS\nYou can access device location through GPS using following URL.\n\n                 ws://\u003cip\u003e:\u003cport\u003e/gps\n                 \nSee [Getting Data From GPS](https://github.com/umer0586/SensorServer/wiki/Getting-Data-From-GPS) for more details\n\n\n\n## Real Time plotting\nSee [Real Time Plot of Accelerometer (Python)](https://github.com/umer0586/SensorServer/wiki/Real-Time-Plot-Example-(-Python)) using this app\n\n![result](https://user-images.githubusercontent.com/35717992/208961337-0f69757e-e85b-4637-8c39-fa5554d85921.gif)\n\n\n\nhttps://github.com/umer0586/SensorServer/assets/35717992/2ebf865d-529e-4702-8254-347df98dc795\n\n## Testing in a Web Browser\nYou can also view your phone's sensor data in a Web Browser. Open the app's navigation drawer menu and enable `Test in a Web Browser`.Once the web server is running, the app will display an address on your screen. This address will look something like `http://\u003cip\u003e:\u003cport\u003e`.On your device or another computer on the same network, open a web browser and enter that address. The web browser will now display a list of all the sensors available on your device. The web interface have options to connect to and disconnect from individual sensors, allowing you to view their real-time data readings.\n\n\u003cimg width=\"742\" src=\"https://github.com/user-attachments/assets/6ddac5cc-dc88-4ab2-aca9-b53fbd57a9c2\"\u003e\n\n![plotting](https://github.com/user-attachments/assets/297a001a-ed88-4299-9cf1-31451fff2c18)\n\n\n\n\nThis web app is built using Flutter and its source could be found under [sensors_dashboard](https://github.com/umer0586/SensorServer/tree/main/sensors_dashboard). However, there's one current limitation to be aware of. The app is built with Flutter using the `--web-renderer canvaskit` option. This means that the resulting app will have some dependencies that need to be downloaded from the internet. This means that any device accessing the web app through a browser will require an internet connection to function properly.\n\nThe web app is built and deployed to Android's assets folder via `python deploy_web_app.py`\n\n\n## Connecting over Hotspot :fire:\nIf you don't have Wifi network at your work place you can directly connect websocket clients to the app by enabling **Hotspot Option** from settings. Just make sure that websocket clients are connected to your phone's hotspot\n\n\n## Connecting over USB (using ADB)\nTo connect over USB make sure `USB debugging` option is enable in your phone and `ADB` (android debug bridge) is available in your machine\n* **Step 1 :** Enable `Local Host` option in app\n* **Step 2** : Run adb command `adb forward tcp:8081 tcp:8081` (8081 is just for example) from client\n* **Step 3** : use address `ws://localhost:8081:/sensor/connect?type=\u003csensor type here\u003e` to connect \n\nMake sure you have installed your android device driver and `adb devices` command detects your connected android phone.\n\n## Links To Projects Utilizing SensorServer\n1. Utilizing smartphone IMU sensors for controlling a robot via ROS ([http://www.rc.is.ritsumei.ac.jp/FILES/PBL5/2024/IMU_based_control/](http://www.rc.is.ritsumei.ac.jp/FILES/PBL5/2024/IMU_based_control/))\n2. Use smartphone as \"sensor\" into RTMaps studio ([https://github.com/Intempora/smartphone-sensors](https://github.com/Intempora/smartphone-sensors))\n3. Streams IMU and GPS data via WebSocket from Android app and integrates with MinIO CSI server for building-scale WiFi sensing testbeds. ([https://github.com/WS-UB/WiSense-Mobile-Client](https://github.com/WS-UB/WiSense-Mobile-Client))\n4. SLAM System with IMU and Wifi Synchronization. ([https://github.com/WS-UB/imu_publisher](https://github.com/WS-UB/imu_publisher))\n5. Middleware for Streaming Real Device Sensor Data to Android Emulators. ([https://github.com/ingmarfjolla/android-sensor-injection](https://github.com/ingmarfjolla/android-sensor-injection))\n6. A Python graphical user interface to visualize real-time data streams from a generic WebSocket \u0026 HTTP source ([https://github.com/AlyShmahell/robolytics](https://github.com/AlyShmahell/robolytics))\n7. Tool designed to address the current limitations of passthrough mode in modern virtual reality (VR) headsets.([https://github.com/LucasHartmanWestern/Screen-Sight](https://github.com/LucasHartmanWestern/Screen-Sight))\n8. Real-Time Sensor Data Streaming, Storage, and Visualization System with Kafka, InfluxDB, and Grafana.([https://github.com/TouradBaba/Iot_sensors_streaming](https://github.com/TouradBaba/Iot_sensors_streaming))\n9. A project that uses data from IMU, GPS and Barometer modules to estimate position based on space state filters implementation [https://github.com/Peterex08/IMUGPS](https://github.com/Peterex08/IMUGPS)\n10. A Windows desktop application that transforms a smartphone into a gesture‑based remote control. It streams real‑time sensor (gyroscope) data over WebSockets, recognizes swipe gestures, and maps them to system or media actions on the desktop [https://github.com/Guerric9018/Frogmote](https://github.com/Guerric9018/Frogmote)\n11. PHASETIMER ([https://github.com/zenbooster/phasetimer](https://github.com/zenbooster/phasetimer))\n12. Score real-time walking data of users wearing an Andriod device. ([https://github.com/eliasHw/BME450W_Fall2022](https://github.com/eliasHw/BME450W_Fall2022))\n13. Wireless Steering wheel using python and android with paddles and breaks. ([https://rutube.ru/video/03d53de54054337a8c54b825f7fcc3fe/](https://rutube.ru/video/03d53de54054337a8c54b825f7fcc3fe/))\n14. [https://github.com/strets123/walking-pictionary](https://github.com/strets123/walking-pictionary)\n\nIf you're using this app in a project and would like to share the link, feel free to submit a pull request with the link and a brief description so that it can be helpful to others.\n\n# My Other Android Projects\n1. [SensaGram](https://github.com/umer0586/SensaGram). For streaming realtime sensor data over UDP\n2. [DroidPad](https://github.com/umer0586/DroidPad). Android app for creating customizable control interfaces for Bluetooth Low energy,WebSocket, MQTT, TCP, and UDP protocols. \n\n## Found this useful\n\u003ca href=\"https://www.buymeacoffee.com/umerfarooq\" target=\"_blank\"\u003e\u003cimg src=\"https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png\" alt=\"Buy Me A Coffee\" style=\"height: 60px !important;width: 217px !important;\" \u003e\u003c/a\u003e\n\nSend Bitcoin at 1NHkiJmjUdjqbCKJf6ZksGKMvYu52Q5tew \n\nOR\n\nScan following QR code with bitcoin wallet app to send bitcoins\n\n[\u003cimg src=\"https://github.com/umer0586/SensorServer/assets/35717992/11cd8194-6e9c-469c-a09f-06fd1bc93acd\" height=\"200\"\u003e](https://github.com/umer0586/SensorServer/assets/35717992/11cd8194-6e9c-469c-a09f-06fd1bc93acd)\n\n\n","funding_links":["https://www.buymeacoffee.com/umerfarooq"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fumer0586%2Fsensorserver","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fumer0586%2Fsensorserver","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fumer0586%2Fsensorserver/lists"}