3
3
4
4
This example connects to a MQTT broker and subscribes to a single topic,
5
5
it also publishes a message to another topic every 10 seconds.
6
- When a message is received it prints the message to the serial monitor ,
6
+ When a message is received it prints the message to the Serial Monitor ,
7
7
it uses the callback functionality of the library.
8
8
9
9
It also demonstrates how to set the will message, get/set QoS,
10
10
duplicate and retain values of messages.
11
11
12
12
The circuit:
13
- - Arduino MKR 1000, MKR 1010 or Uno WiFi Rev.2 board
13
+ - Arduino MKR 1000, MKR 1010 or Uno WiFi Rev2 board
14
14
15
15
This example code is in the public domain.
16
16
*/
26
26
27
27
#include " arduino_secrets.h"
28
28
// /////please enter your sensitive data in the Secret tab/arduino_secrets.h
29
- char ssid[] = SECRET_SSID; // your network SSID (name)
29
+ char ssid[] = SECRET_SSID; // your network SSID (name)
30
30
char pass[] = SECRET_PASS; // your network password (use for WPA, or use as key for WEP)
31
31
32
32
// To connect with SSL/TLS:
@@ -56,7 +56,7 @@ void setup() {
56
56
; // wait for serial port to connect. Needed for native USB port only
57
57
}
58
58
59
- // attempt to connect to Wifi network:
59
+ // attempt to connect to WiFi network:
60
60
Serial.print (" Attempting to connect to WPA SSID: " );
61
61
Serial.println (ssid);
62
62
while (WiFi.begin (ssid, pass) != WL_CONNECTED) {
@@ -68,7 +68,7 @@ void setup() {
68
68
Serial.println (" You're connected to the network" );
69
69
Serial.println ();
70
70
71
- // You can provide a unique client ID, if not set the library uses Arduin -millis()
71
+ // You can provide a unique client ID, if not set the library uses Arduino -millis()
72
72
// Each client must have a unique client ID
73
73
// mqttClient.setId("clientId");
74
74
@@ -79,8 +79,8 @@ void setup() {
79
79
// you can disable this behaviour by using
80
80
// mqttClient.setCleanSession(false);
81
81
82
- // set a will message, used by the broker when the connection dies unexpectantly
83
- // you must know the size of the message before hand , and it must be set before connecting
82
+ // set a will message, used by the broker when the connection dies unexpectedly
83
+ // you must know the size of the message beforehand , and it must be set before connecting
84
84
String willPayload = " oh no!" ;
85
85
bool willRetain = true ;
86
86
int willQos = 1 ;
@@ -110,7 +110,7 @@ void setup() {
110
110
Serial.println ();
111
111
112
112
// subscribe to a topic
113
- // the second parameter set's the QoS of the subscription,
113
+ // the second parameter sets the QoS of the subscription,
114
114
// the the library supports subscribing at QoS 0, 1, or 2
115
115
int subscribeQos = 1 ;
116
116
@@ -129,7 +129,7 @@ void loop() {
129
129
// send MQTT keep alives which avoids being disconnected by the broker
130
130
mqttClient.poll ();
131
131
132
- // avoid having delays in loop, we'll use the strategy from BlinkWithoutDelay
132
+ // to avoid having delays in loop, we'll use the strategy from BlinkWithoutDelay
133
133
// see: File -> Examples -> 02.Digital -> BlinkWithoutDelay for more info
134
134
unsigned long currentMillis = millis ();
135
135
0 commit comments