Android app to stream real-time device sensor data to an MQTT broker. Select sensors, configure broker settings, and publish seamlessly.
- Configure your broker settings.
- Press Connect to start streaming the selected sensor data in real time.
- 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
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:
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.