---
title: "Problem - MQTT WizFi310 publish to thingspeak channels"
url: "https://maker.wiznet.io/forum/13033"
markdown_url: "https://maker.wiznet.io/forum/13033/md"
type: "Forum topic"
category: "Wireless"
author: "petesmart"
created: "2018-08-22T03:34:27+09:00"
last_activity: "2018-08-23T06:45:36+09:00"
language: "en"
views: 956
replies: 1
source: "WIZnet Makers forum (https://maker.wiznet.io/forum/)"
---

# Problem - MQTT WizFi310 publish to thingspeak channels

## Question

Asked by petesmart on 2018-08-22 in Wireless.

Dear Wiznet support,

I am currently attempting to use your WizFi310 EVB device to communicate and publish data to thingsspeak using the MQTT AT commands.

I have easily achieved

- Connection to Wi-Fi

- MQTT connection with the thingspeak channel - MQTT indicates [OK] - so everything is working .

My next step is to publish to a channel/field. I would appreciate if you could help me with the correct syntax for the MQTTpub command please.

I have verified via MQTT.fx that I can publish data to think speak using the following syntax.

Here is a log example if the message successfully published to the thingspeak channel a few minutes ago

```
sucessfully published message field1=100&field2=160&status=sent to topic channels/254968/publish/XXZZ11SHLHX5EXX (QoS 0, Retained: false)
```

How do I use AT+MQTTPUB to send the data to the channel fields on thingspeak? what is the correct way to form the command text?

many thanks for your assistance

all the best

Pete

## Replies

### Reply 1 by wizdaniel, 2018-08-23

there is a way to connect to MQTT broker and publish data.
please refer to the following MQTT Commands in WizFi310.

WizFi310 Version 1.0.3.6 (WIZnet Co.Ltd)

at+wset=0,Dap

[OK]

at+wsec=0,00001111

[OK]

at+wnet=1

[OK]

at+wjoin

[Link-Up Event]

IP Addr : 192.168.1.35

Gateway : 192.168.1.1

[OK] *# finish association with AP*

[AT+SDNAME=iot.eclipse.org](http://AT+SDNAME=iot.eclipse.org)
*# set Broker Domain if you want to use DNS*

[OK]

AT+MQTTSET=tefdf,tesdfdf,60

[OK]

AT+MQTTSET=tefdf,tesdfdf,300

[OK]

AT+MQTTSET=tefdf,tesdfdf,301
*# now we provide MQTT keep alive time 30s ~ 300s*

[ERROR: INVALID INPUT]

AT+MQTTCON=1,0.0.0.0,1883,0
*# set broker IP to "0.0.0.0" if you want to use DNS*

[MQTT CONNECT]

[OK]

AT+MQTTSUB=1,channels/254968/publish/XXZZ11SHLHX5EXX
*# subscribe topic "channels/254968/publish/XXZZ11SHLHX5EXX"*

[OK]

AT+MQTTPUB=channels/254968/publish/XXZZ11SHLHX5EXX,33
*# publish 33-bytes data to your topic "channels/254968/publish/XXZZ11SHLHX5EXX"*

[33]
*# you have to input your data(33-bytes) after "[33]" message. 33 is a length of your data*

[OK]
*# if you fill the data you decided to publish, you can find "[OK]" response.*

{Q,channels/254968/publish/XXZZ11SHLHX5EXX,33}field1=100&field2=160&status=sent
*# this is a message that WizFi310 received, because you already have subscribed to the same topic with publish*

---

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