# MQTT | Push data to Device

**Prerequisites**

1. Have MQTT FX software. If you don't have it, please go to the following [link MQTT FX.](https://softblade.de/en/download-2/)

#### Steps

1. Login to your Antares account via Antares Console [https://console.antares.id](https://console.antares.id/)

   <figure><img src="https://content.gitbook.com/content/7cujmJ5QHdJaAjH815aZ/blobs/fcKgf5Y2WWFwTfJvexcn/LOG%20IN.png" alt=""><figcaption></figcaption></figure>
2. Save Access Keys, you can view Access Keys on the **API Keys page**

<figure><img src="https://3873791589-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7cujmJ5QHdJaAjH815aZ%2Fuploads%2FS0sJe2JzxQvePfzEEvC8%2Fimage.png?alt=media&#x26;token=6a057bab-e118-4e27-90aa-caa860dfcb00" alt=""><figcaption></figcaption></figure>

3. Create an App, if you already have one, ignore it to proceed to the next process.

<figure><img src="https://3873791589-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7cujmJ5QHdJaAjH815aZ%2Fuploads%2FpIgpLwkLP4OBpdfvwafT%2Fimage.png?alt=media&#x26;token=35ca0b9d-a580-44c5-9223-af5a58347b0d" alt=""><figcaption></figcaption></figure>

4. Create Device, if you already have one, ignore it to proceed to the next process.

<figure><img src="https://3873791589-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7cujmJ5QHdJaAjH815aZ%2Fuploads%2FzByQt5dfhLXbQCKRBcPR%2Fimage.png?alt=media&#x26;token=425720e2-ba15-4776-91be-c6252f5e4508" alt=""><figcaption></figcaption></figure>

5. Open the MQTT FX software. The user interface is shown in the following figure.<br>

<figure><img src="https://content.gitbook.com/content/7cujmJ5QHdJaAjH815aZ/blobs/SDVHkQ1jO3v7OF3xUY5z/image.png" alt=""><figcaption></figcaption></figure>

6. Firstly, you need to configure so that you can connect with our MQTT Broker. The configuration is shown below.

<figure><img src="https://content.gitbook.com/content/7cujmJ5QHdJaAjH815aZ/blobs/aduND18PQ8w0EXVSzsGf/image.png" alt=""><figcaption></figcaption></figure>

1. When you successfully connect, a green icon will appear on the top right.

   <figure><img src="https://content.gitbook.com/content/7cujmJ5QHdJaAjH815aZ/blobs/iGs9XPQ5N0d8uNGa9AKD/image.png" alt=""><figcaption></figcaption></figure>
2. Click Subscribe, then run subscribe a topic by following this format:\ <mark style="color:red;">`/oneM2M/resp/antares-cse/your-access-key/choose-a-serialization-format`</mark>\
   The <mark style="color:red;">choose-a-serialisation-format</mark> parameter can have 2 values:<mark style="color:red;">`xml`</mark> untuk format XML

   * <mark style="color:red;">`json`</mark> for JSON format

   In this step, it means that you will get a message/notification when a change happens to your account. In this tutorial, we use MQTT FX tools to subscribe, but in the real case scenario, it will be the device that subscribes to the topic.

   <figure><img src="https://content.gitbook.com/content/7cujmJ5QHdJaAjH815aZ/blobs/TdROsHWnoE6yiwi6nlR0/image.png" alt=""><figcaption></figcaption></figure>
3. This step, we will emulate requests coming from mobile apps. It also uses MQTT FX as a tool. Start publishing to the following topics:

   <mark style="color:red;">`/oneM2M/req/your-access-key/antares-cse/choose-a-serialization-format`</mark>\
   The <mark style="color:red;">`choose-a-serialization-format`</mark> parameter can have 2 values:

   * <mark style="color:red;">`xml`</mark> for XML format
   * <mark style="color:red;">`json`</mark> for JSON format

   Example:\
   Topic: <mark style="color:red;">`/oneM2M/req/your-access-key/antares-cse/json`</mark>\
   Contents

   <pre class="language-json" data-line-numbers><code class="lang-json"><strong>  {
   </strong>  "m2m:rqp": {
       "fr": "your-access-key",
       "to": "/antares-cse/antares-id/application-name/device-name",
       "op": 1,
       "rqi": 123456,
       "pc": {
         "m2m:cin": {
           "cnf": "message",
           "con": "on"
         }
       },
       "ty": 4
     }
   }
   </code></pre>

All data in **"con"** is defined by yourself. You can create your own format data.<br>

<figure><img src="https://content.gitbook.com/content/7cujmJ5QHdJaAjH815aZ/blobs/62UjKVG5Glx3LCp43D3c/image.png" alt=""><figcaption></figcaption></figure>

**Congratulations! You have just received your first request using the MQTT API.**
