Android MQTT Client Setup

Text Copied

Introduction

Developers can integrate MQTT into Android projects using libraries like Eclipse Paho Android Service.

However, for quick testing and practical use, you don’t always need to build an app from scratch. Instead, you can use IoT MQTT Panel, a free Android app available on the Play Store, to connect, subscribe, publish, and monitor MQTT topics. This guide walks you through using the app to work with an MQTT broker.

Pre-requisites

Before you begin, make sure you have:

MQTT Connect

Make sure you have the broker details (hostname, port, username/password, CA certificate) handy.

  • Open IoT MQTT Panel.
  • Tap “+” to add a new connection.
  • Fill in the following fields:

    • Connection Name: Any friendly name (e.g., Test1).
    • Client ID: A unique identifier (e.g., Testclient-104).
    • Broker Address: (e.g., crystalmq.bevywise.com)
    • Port: 1883 (default for non-TLS).
    • Network Protocol: Usually TCP.
    • Additional Options: Enter Username & Password if required.
  • Tap Create to save the connection.
  • Select the connection and tap Connect Status will change to Connected if successful.
  • Create a Dashboard for this device.
Add connection


Add dashboard

MQTT Subscribe

  • Once connected, open your connection’s dashboard.
  • Tap “+” Add Panel → Choose Line Graph Panel.
  • Fill in the fields:
    • Panel Name: e.g., TempTrend.
    • Topic: sensor/temp.
    • Label: e.g., Temperature.
    • Graph Options: Configure time window, axis scaling, and auto-scroll as needed.
  • Tap Save.
  • The panel will now plot all numeric values published on sensor/temp.
Select panel type


Edit panel

MQTT Publish

  • On the dashboard, tap “+” Add Panel → Choose Text Input Panel.
  • Fill in the fields:
    • Panel Name: e.g., PublishTemperature.
    • Topic: sensor/temp.
    • QoS: Select QoS level (default = 0).
    • Retain: Toggle ON if you want the broker to retain the last published value.
    • Payload Options:
      • Timestamp: Auto-insert current time.
      • JSON: Wrap input as JSON.
      • Or leave as plain text for numeric input.
  • Tap Save.
  • To publish: enter a value (e.g., 25) and press Send.
  • The Line Graph Panel will instantly update with the new data point.
Edit Panel


Dashboard

MQTT Disconnect

Clean disconnection ensures the broker releases resources tied to the session and avoids lingering socket connections.


  • From the main connection list, tap your broker connection.
  • Select Disconnect (Cloud Icon).
  • The app will stop publishing/subscribing until reconnected.

Troubleshooting

  • Can’t connect to broker

    • Check broker IP/hostname, port, and network protocol.
    • Verify network connectivity.
    • Ensure Client IDs are unique.
  • Not receiving messages

    • Confirm topic matches exactly (sensor/temp is case-sensitive).
    • Ensure data is numeric for Line Graph panel to display correctly.
    • Check QoS mismatch (try QoS 0 first).
  • Can’t connect to broker

    • Double-check username/password.
    • Some brokers require TLS/SSL – use port 8883 and proper certificates.

Real-Time IoT at Your Fingertips!

Turn your phone into a
live IoT dashboard

Connect, subscribe, and publish data effortlessly with IoT MQTT Panel powered by our broker.