<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Problem with Mosquitto Topic]]></title><description><![CDATA[<p dir="auto">Hi everyone,</p>
<p dir="auto">I need to change serial communication for a Mosquitto on an existing project. There is one PC and 3 ESP32 without radio-frequency To put be simply, there is a PC which controls ESP32 by the network. On the current project, the node ID is the number of ESP between 1 and 3.<br />
<img src="/assets/uploads/files/1556451959137-esp.png" alt="0_1556451961142_ESP.png" class="img-markdown  img-fluid" /></p>
<p dir="auto">However, when a try to set up the MQTT gateway, the first topic is always 0. If I'm used message.setDestination(1), this message is not sending (return 0).</p>
<p dir="auto">I'm using this following code to my ESP32:</p>
<pre><code>#define MY_DEBUG
#define MY_NODE_ID 2
/**********************************************
*     Ethernet Gateway Transport Defaults    */
#define MY_GATEWAY_MQTT_CLIENT
#define MY_GATEWAY_ESP32

/** Configuration of WiFi */
#define MY_WIFI_SSID "Test"
#define MY_WIFI_PASSWORD "qwerty1234"
#define MY_HOSTNAME "Boss2"

/** MQTT Configuration **/
#define MY_MQTT_PUBLISH_TOPIC_PREFIX "sendToPc"
#define MY_MQTT_SUBSCRIBE_TOPIC_PREFIX "getToPc"
#define MY_MQTT_CLIENT_ID "Boss2"
#define MY_CONTROLLER_IP_ADDRESS 192, 168, 56, 101
#define MY_PORT 1883
/**********************************************/

#include &lt;MySensors.h&gt;

#define MY_BAUD_RATE 115200
#define OPEN 1
#define CLOSE 0
#define CHILD_ID 1

MyMessage msg;

uint8_t value = OPEN;

void presentation() {
  present(CHILD_ID, S_DOOR);
}

void setup(){
  Serial.begin(115200);
  msg.setType(V_TRIPPED);
  msg.setSensor(CHILD_ID);
}

void loop() {
  value = value == OPEN ? CLOSE : OPEN;
  send(msg.set(value));
  delay(1000);
}

</code></pre>
<p dir="auto">And on serial terminal I have :</p>
<pre><code>20182 GWT:TPC:CONNECTING...
20684 GWT:TPC:CONNECTING...
20686 GWT:TPC:IP=192.168.137.160
20691 MCO:BGN:STP(20693 MCO:REG:NOT NEEDED
20695 MCO:BGN:INIT OK,TSP=NA
20697 GWT:TPC:IP=192.168.137.160
20700 GWT:RMQ:MQTT RECONNECT
20723 GWT:RMQ:MQTT CONNECTED
20725 GWT:TPS:TOPIC=sendToPc/0/255/0/0/17,MSG SENT
20733 GWT:TPS:TOPIC=sendToPc/0/1/0/0/0,MSG SENT
20740 GWT:TPS:TOPIC=sendToPc/0/1/1/0/16,MSG SENT
21745 GWT:TPS:TOPIC=sendToPc/0/1/1/0/16,MSG SENT
22751 GWT:TPS:TOPIC=sendToPc/0/1/1/0/16,MSG SENT
</code></pre>
<p dir="auto">Rather than</p>
<pre><code>20740 GWT:TPS:TOPIC=sendToPc/2/1/1/0/16,MSG SENT
</code></pre>
<p dir="auto">Do you have a solution?</p>
<p dir="auto">Thank you</p>
]]></description><link>https://forum.mysensors.org/topic/10351/problem-with-mosquitto-topic</link><generator>RSS for Node</generator><lastBuildDate>Wed, 11 Nov 2026 09:49:43 GMT</lastBuildDate><atom:link href="https://forum.mysensors.org/topic/10351.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 28 Apr 2019 12:02:06 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Problem with Mosquitto Topic on Tue, 30 Apr 2019 15:38:24 GMT]]></title><description><![CDATA[<p dir="auto">Thank you for your all answers.<br />
I have made some tests and even if I don't have results for the moment, the best solution for me seems using (in accordance with <a class="plugin-mentions-user plugin-mentions-a" href="/user/bgunnarb" aria-label="Profile: bgunnarb">@<bdi>bgunnarb</bdi></a>):</p>
<pre><code>MY_MQTT_PUBLISH_TOPIC_PREFIX ESP-topic/ESP-number
</code></pre>
<p dir="auto">Yes, it's can be a good idea <a class="plugin-mentions-user plugin-mentions-a" href="/user/mfalkvidd" aria-label="Profile: mfalkvidd">@<bdi>mfalkvidd</bdi></a></p>
]]></description><link>https://forum.mysensors.org/post/98888</link><guid isPermaLink="true">https://forum.mysensors.org/post/98888</guid><dc:creator><![CDATA[exblematique]]></dc:creator><pubDate>Tue, 30 Apr 2019 15:38:24 GMT</pubDate></item><item><title><![CDATA[Reply to Problem with Mosquitto Topic on Sun, 28 Apr 2019 20:12:53 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/mfalkvidd" aria-label="Profile: mfalkvidd">@<bdi>mfalkvidd</bdi></a> said in <a href="/post/98843">Problem with Mosquitto Topic</a>:</p>
<blockquote>
<p dir="auto">MY_MQTT_PUBLISH_TOPIC_PREFIX</p>
</blockquote>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/exblematique" aria-label="Profile: exblematique">@<bdi>exblematique</bdi></a><br />
I am using three different MQTT gateways in three different geographical locations and have done so for years. Each having their own MY_MQTT_PUBLISH_TOPIC_PREFIX. It works perfectly!</p>
]]></description><link>https://forum.mysensors.org/post/98857</link><guid isPermaLink="true">https://forum.mysensors.org/post/98857</guid><dc:creator><![CDATA[bgunnarb]]></dc:creator><pubDate>Sun, 28 Apr 2019 20:12:53 GMT</pubDate></item><item><title><![CDATA[Reply to Problem with Mosquitto Topic on Sun, 28 Apr 2019 18:11:06 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/exblematique" aria-label="Profile: exblematique">@<bdi>exblematique</bdi></a> <a href="https://github.com/mysensors/MySensors/issues/1212" rel="nofollow ugc">https://github.com/mysensors/MySensors/issues/1212</a> might be of interest to you as well. There hasn't been any activity lately, but maybe you can join forces with other people that are interested.</p>
]]></description><link>https://forum.mysensors.org/post/98854</link><guid isPermaLink="true">https://forum.mysensors.org/post/98854</guid><dc:creator><![CDATA[mfalkvidd]]></dc:creator><pubDate>Sun, 28 Apr 2019 18:11:06 GMT</pubDate></item><item><title><![CDATA[Reply to Problem with Mosquitto Topic on Sun, 28 Apr 2019 16:09:51 GMT]]></title><description><![CDATA[<p dir="auto">Thank you for your quick answers.<br />
I will try with this new information</p>
]]></description><link>https://forum.mysensors.org/post/98850</link><guid isPermaLink="true">https://forum.mysensors.org/post/98850</guid><dc:creator><![CDATA[exblematique]]></dc:creator><pubDate>Sun, 28 Apr 2019 16:09:51 GMT</pubDate></item><item><title><![CDATA[Reply to Problem with Mosquitto Topic on Sun, 28 Apr 2019 12:11:45 GMT]]></title><description><![CDATA[<p dir="auto">Welcome to the forum <a class="plugin-mentions-user plugin-mentions-a" href="/user/exblematique" aria-label="Profile: exblematique">@<bdi>exblematique</bdi></a><br />
A MySensors gateway (which is what each of your esp32 are technically) always has node id 0 by design.<br />
SetDestination is used to send to another node in the MySensors network, so it can't be used to achieve what you want.</p>
<p dir="auto">There are two ways to differentiate different gateways: MY_MQTT_CLIENT_ID and MY_MQTT_PUBLISH_TOPIC_PREFIX.</p>
]]></description><link>https://forum.mysensors.org/post/98843</link><guid isPermaLink="true">https://forum.mysensors.org/post/98843</guid><dc:creator><![CDATA[mfalkvidd]]></dc:creator><pubDate>Sun, 28 Apr 2019 12:11:45 GMT</pubDate></item></channel></rss>