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:
GPS data is sent in following json format
{
"type": "android.gps",
"longitude": 155.9011,
"latitude": 81.4278,
"altitude": 217.5,
"bearing": 135.0,
"accuracy": 5.2,
"speed": 2.8,
"time": 1727845963000
}
where:
Field | Description |
---|---|
longitude | Longitude in degrees. |
latitude | Latitude in degrees. |
altitude | The altitude of the location in meters above the WGS84 reference ellipsoid. |
bearing | Bearing at the time of this location in degrees. Bearing is the horizontal direction of travel and is unrelated to device orientation. The bearing is guaranteed to be in the range [0, 360). |
accuracy | Estimated horizontal accuracy radius in meters of this location at the 68th percentile confidence level. |
speed | Speed at the time of this location in meters per second. |
time | The Unix epoch time of this location fix, in milliseconds since the start of the Unix epoch (00:00:00 January 1, 1970 UTC). |
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.
Appreciate the project? Here's how you can help:
- Star: Give it a star at the top right. It means a lot!
- Contribute: Found an issue or have a feature idea? Submit a PR.
- Feedback: Have suggestions? Open an issue or start a discussion.