> 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/smartconnect/at-command-reference/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=?`            | Available topic indexes, QoS values, and `OK` |
| Read  | `AT+EMQPUBLISH?`             | `OK`                                          |
| Write | `AT+EMQPUBLISH=(0-7),(0-1),` | `OK`, `ERROR`, `:SEND OK`, or `:SEND FAIL`    |

For the Write command:

* Set the publish topic index from `0` through `7`.
* Set QoS to `0` for at-most-once delivery or `1` for at-least-once delivery.
* Send an unquoted message as unmodified text.
* Limit the payload to `1000` printable characters.
* Send quoted ASCII-hex data with an even number of characters from `0-9`, `a-f`, or `A-F`.
* Start quoted JSON data with `{` immediately after the opening quote. AnyNet SMARTconnect™ does not validate JSON.

The module returns `:SEND OK` when it publishes the message. For QoS `1`, the broker sends a `PUBACK` to confirm receipt. `:SEND FAIL` applies only to QoS `1`. If the module returns `ERROR`, check that [EMQPUBOPEN – create a publish message topic](/smartconnect/at-command-reference/mqtt-at-commands/emqpubopen-create-a-publish-message-topic.md) has configured the topic and [ETMSTATE – check current state](/smartconnect/at-command-reference/management-at-commands/etmstate-check-current-state.md) has started MQTT.

#### 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/smartconnect/at-command-reference/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.
