> For the complete documentation index, see [llms.txt](https://docs.eseye.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.eseye.com/modules/cinterion-r-els61-wireless-module/mqtt-at-commands/emqpublish-publish-data-to-a-message-topic.md).

# EMQPUBLISH – publish data to a message topic

Publish data to a created message topic. Data is sent to your thing in the cloud.

| Type      | Syntax                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     | Returned Result                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| --------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| **Test**  | `AT+EMQPUBLISH=?`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          | <p><code>OK</code></p><p><code>+EMQPUBLISH: (0-7),(0-1),\<pubdata></code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| **Read**  | `AT+EMQPUBLISH?`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           | `OK`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| **Write** | <p><code>AT+EMQPUBLISH=(0-7),(0-1),\<pubdata></code></p><p>where:</p><ul><li><code>(0-7)</code> is the publish index number</li><li><p><code>(0-1)</code> is the Quality of Service, either:</p><ul><li><code>0</code> – sends the message without guaranteeing message receipt. The message is not stored on the sender, and is not acknowledged.</li><li><code>1</code> – guarantees the message is delivered at least once.</li></ul></li><li><p><code>\<pubdata></code> – is the published message. The maximum payload length is 1000 characters. All characters must be printable.</p><p>AnyNet SMARTconnect™ handles <code>\<pubdata></code> as ASCII-hex if it contains an even number of valid ASCII-hex characters (<code>0</code>-<code>9</code>, <code>a</code>-<code>f</code>, <code>A</code>-<code>F</code>). ASCII-hex is converted to binary for transmission.</p><p>AnyNet SMARTconnect™ handles all other data as text. For text messages, <code>\</code> (escape characters) are removed.</p></li></ul> | <p><code>OK</code> – successfully wrote the command</p><p><code>ERROR</code> – the command failed. Check your syntax, and that you have already set up the publish topic using <code>at+emqpubopen?</code>.</p><p><code>SEND OK</code> – send confirmation relating to Quality of Service. This response is for:</p><ul><li><code>QoS=0</code> – message is published</li><li><code>QoS=1</code> – MQTT broker generates a <code>PUBACK</code> to confirm receipt of the MQTT message</li></ul><p><code>SEND FAIL</code> - send failure for <code>QoS=1</code> only.</p> |

#### Example

```
AT+EMQPUBLISH=1,1,"{\"BatteryPower\": \"Low\"}"
OK

SEND OK
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.eseye.com/modules/cinterion-r-els61-wireless-module/mqtt-at-commands/emqpublish-publish-data-to-a-message-topic.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
