Arduino Uno WIFI and MQTT / Unwanted messages at startup

Hi

I bought a new Arduino Uno WIFI and want to use MQTT together with a Adafruit motor shield:

Everything looks fine…Wifi is working and motor control is working as well. But: Each time when I download the Sketch or disconnect/connect the DC-Power from Arduino I get 2 MQTT-Messages at startup. Tried also with this example here:

/*
File: MqttPub.ino

This example subscribes a MQTT channel and reads published data, then prints it
into the serial monitor. Please configure the MQTT server address via Uno WiFi
Web Panel. Topics are automatically created (or subscribed) via api calls into
the sketch. You can use a maximum of 3 topics.

Note: works only with Arduino Uno WiFi Developer Edition.
*/

#include <Wire.h>
#include <UnoWiFiDevEd.h>

#define CONNECTOR “mqtt”
#define TOPIC “arduino/data”

void setup() {
Ciao.begin();
Serial.begin(9600);
}

void loop(){
CiaoData data = Ciao.read(CONNECTOR, TOPIC);
if (!data.isEmpty()){
const char* value = data.get(2);
Serial.println(value);
}
}

As soon as I download the sketch and open the serial monitor I see two times the message from “arduino/data” (without sending). At the end I want to control my boiler temperature with a stepper motor and it’s not really usable with this initial moving.

Is this a bug or is there anything that I didn’t understand? Something like a “restore” function from the mosquittto broker installed on Raspi?

Any ideas?

Thanks a lot
Michael

and did you "configure the MQTT server address via Uno WiFi Web Panel. "?

Yes, exactly!

and your topic is on mqtt server called "arduino/data"?

what is logged on the debug console in web panel?

I didn't configure something server-side.
Just installed mosquitto on raspi and sending from openHAB (MQTT Client) the message 1 or 2 to the topic "arduino/data"

ok. and the debug console?

Topic is now "boiler/temp" and the values "High" and "Normal".

This happens as soon as I open the serial monitor:

967643> MQTT: Recv type=PINGRESP id=0000 len=2; Pend type=NULL id=00
2160> CMD_parse_packet: cmd=1(RESET) argc=0 cb=0x00000000 ret=0
2160> CMD_Exec: Dispatching cmd=RESET
2160> CMD_Exec: no response (0)
3176> CMD_parse_packet: cmd=2(IS_READY) argc=0 cb=0x00000000 ret=1
3177> CMD_Exec: Dispatching cmd=IS_READY
3177> CMD_Exec: Response: 0x1, cmd: 2

3286> CMD_parse_packet: cmd=4(MQTT_SETUP) argc=9 cb=0x00000000 ret=1
3286> CMD_Exec: Dispatching cmd=MQTT_SETUP
3286> CMD_Exec: Response: 0xf00df00d, cmd: 4

3356> CMD_parse_packet: cmd=11(REST_SETUP) argc=3 cb=0x000003ac ret=1
3357> CMD_Exec: Dispatching cmd=REST_SETUP
3357> REST: setup #1 host=google.com port=80 security=0
3357> CMD_Exec: Response: 0xbeef0001, cmd: 11

3420> CMD_parse_packet: cmd=12(REST_REQUEST) argc=3 cb=0x00000000 ret=0
3420> CMD_Exec: Dispatching cmd=REST_REQUEST
3420> REST: request #1 method=GET path=/ bodyLen=0 hdrLen=146 totLen=146 data=0x3fff9188 hdrLen=133
3421> REST: pCon state=0
3421> REST: Connect to host google.com:80
3421> CMD_Exec: no response (0)
3502> REST DNS: found ip 172.217.21.238
3502> REST: connecting...
3522> REST #1: connected
3522> REST #1: sending 133
3654> REST: Sent
3655> REST: status=302, body=268

t: cmd=8(MQTT_SUBSCRIBE) argc=3 cb=0x00000000 ret=0
6585> CMD_Exec: Dispatching cmd=MQTT_SUBSCRIBE
6585> MQTT: MQTTCMD_Subscribe topic=boiler/temp, qos=0
6585> MQTT: Subscribe, topic: "boiler/temp"
6585> MQTT: Send type=SUBSCRIBE id=0007 len=18
6586> CMD_Exec: no response (0)
6587> MQTT: Recv type=SUBACK id=0007 len=5; Pend type=SUBSCRIBE id=07
6635> CMD_parse_packet: cmd=8(MQTT_SUBSCRIBE) argc=3 cb=0x00000000 ret=0
6636> CMD_Exec: Dispatching cmd=MQTT_SUBSCRIBE
6636> MQTT: MQTTCMD_Subscribe topic=boiler/temp, qos=0
6636> MQTT: Subscribe, topic: "boiler/temp"
6636> MQTT: Send type=SUBSCRIBE id=0008 len=18
6637> CMD_Exec: no response (0)
6637> CMD_parse_packet: cmd=8(MQTT_SUBSCRIBE) argc=3 cb=0x00000000 ret=0
6637> CMD_Exec: Dispatching cmd=MQTT_SUBSCRIBE
6637> MQTT: MQTTCMD_Subscribe topic=boiler/temp, qos=0
6637> MQTT: Subscribe, topic: "boiler/temp"
6637> CMD_Exec: no response (0)
6638> MQTT: Recv type=PUBLISH id=0000 len=19; Pend type=SUBSCRIBE id=08
6639> MQTT: Recv PUBLISH qos=0 boiler/tempHighpHigh
6677> MQTT: Recv type=SUBACK id=0008 len=5; Pend type=SUBSCRIBE id=08
6677> MQTT: Recv type=PUBLISH id=0000 len=19; Pend type=NULL id=00
6677> MQTT: Recv PUBLISH qos=0 boiler/tempHighpHigh
6677> MQTT: Send type=SUBSCRIBE id=0009 len=18
6679> MQTT: Recv type=SUBACK id=0009 len=5; Pend type=SUBSCRIBE id=09
6801> MQTT: Recv type=PUBLISH id=0000 len=19; Pend type=NULL id=00
6802> MQTT: Recv PUBLISH qos=0 boiler/tempHighpHigh

When I open the serial monitor I always get 2 times the last sent message to the broker :confused:

serial monitor restarts Arduino, sometimes two times.

the Uno WiFi factory firmware is buggy and discontinued. I use WiFi Link, but it has no mqtt support. It is for general networking.

try the esp-link firmware