Skip to content

Android app to stream real-time device sensor data to an MQTT broker. Select sensors, configure broker settings, and publish seamlessly.

License

Notifications You must be signed in to change notification settings

UmerCodez/SensorSpot

Repository files navigation

GitHub License Jetpack Compose Badge MQTT Android GitHub Release Material 3

Sensor Spot

Android app to stream real-time device sensor data to an MQTT broker. Select sensors, configure broker settings, and publish seamlessly.

⚠️ The App only supports MQTT v5 for now

Usage

  1. Configure your broker settings.
  2. Press Connect to start streaming the selected sensor data in real time.
  3. App allows user to select or deselect sensors while connected, with the published data automatically updating to reflect the new choices.

The data is published to the topic android/sensor in the following JSON format:

{
  "type": "android.sensor.accelerometer",
  "timestamp": 3925657519043709,
  "values": [0.31892395, -0.97802734, 10.049896]
}

This format is similar to one used in SensaGram

image

Explanation

Array Item Description
values[0] Acceleration force along the x-axis (including gravity)
values[1] Acceleration force along the y-axis (including gravity)
values[2] Acceleration force along the z-axis (including gravity)
  • timestamp: The time (in nanoseconds) when the event occurred. See the timestamp.

Note: For more details about other sensors data and what the values array represent, refer to the official Android documentation:

Limitation on Android 14+ devices

Starting with Android 14, background execution restrictions are more strict. When you connect to the broker, the app starts a foreground service to publish sensor data in real time. However, if you leave the app for more than 5 seconds (e.g., switch to another app or close it), the system may stop this foreground service, causing a disconnection from the broker. This occurs even if background activity is allowed for the app.

To avoid this issue, keep the app running in the foreground while connected.