---
title: "How to use MQTTPUB or MQTTPUBSEND to send binary data?"
url: "https://maker.wiznet.io/forum/14999"
markdown_url: "https://maker.wiznet.io/forum/14999/md"
type: "Forum topic"
category: "Wireless"
author: "willy"
created: "2023-08-03T09:24:20+09:00"
last_activity: "2023-08-04T00:15:48+09:00"
language: "en"
views: 249
replies: 1
source: "WIZnet Makers forum (https://maker.wiznet.io/forum/)"
---

# How to use MQTTPUB or MQTTPUBSEND to send binary data?

## Question

Asked by willy on 2023-08-03 in Wireless.

I’m using wizfi360 module, with fw version 1.1.2.0
it is correctly connected on MQTT server.
1-MQTTPUBSEND=15\r\n return always ERROR
2-MQTTPUB=“xxxxxx”\r\n alway work correctly if xxxxx is an ASCII string, if i try to send binary data I have a lot problems: I can’t trasmit 0x00,0x08,0x0A

this is my code
tx_stringa_wifi(“AT+MQTTPUB=,\0”);
tx_dato_wifi(0x22);
for (i = 1; i &lt; 256; i++) {
if (i != 10 && i != 8)
tx_dato_wifi(i);
}
tx_dato_wifi(48);
tx_dato_wifi(0x22);
tx_dato_wifi(0x0D);
tx_dato_wifi(0x0A);
It works correctly if I don’t send 0,8,10 otherways it stops sending.

How can i solve this problem?

## Replies

### Reply 1 by scarlet, 2023-08-04

Hello, this is scarlet.
First of all, [MQTTPUB] is a command used for general strings.
It is correct to use the [MQTTPUBSEND] command for binary data.
I am attaching the screen that I tested here.
![image](https://maker.wiznet.io/forum_uploads/wiznet/original/2X/4/40625f10556fd88bc6f71866e47187de5c67eae1.png)

It appears that you have written code to send a message from the MCU via UART.
If you’re using a module, have you tried sending commands using a serial program (ex. tera term)?
When developing with WizFi360, we recommend verifying the command transmission process with a serial program before proceeding with development on the MCU side.
If there’s an issue when testing with the serial program, please attach the log and feel free ask to me.

---

Source: https://maker.wiznet.io/forum/14999
