-
Notifications
You must be signed in to change notification settings - Fork 35
/
PubSub_Treoublshooting
32 lines (23 loc) · 1.21 KB
/
PubSub_Treoublshooting
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
First, ensure you are using the correct ESP8266 sketch depending on your Arduino Board Manager (above or below 3.0)
The IDE requires different sketches for different versions of the Arduino Board manager for it to connect to AWS IoT Core.
--------------------
If your data payload coming to or from the device via MQTT PubSub isn’t coming through, it may be your sprintf char buffer is too large (exceeds 128 chars), issue is discussed here: https://github.com/knolleary/pubsubclient/issues/110
To view your current buffer size; example below:
//------------------------------------------
int bufferSizeTest = snprintf(fakeData, sizeof(fakeData), "{\"uptime\":%lu,\"temp\":%d,\"humid\":%d,\"lattitude\":%2.7f,\"longitude\":%3.7f}", millis() / 1000, t, h, latt, lon );
Serial.println('\n');
Serial.println(bufferSizeTest);
Serial.println('\n');
//-------------------------------------------
to fix this problem see below:
Arduino-->libraries-->PubSub folder-->src-->PubSubClient.h
change-->
// MQTT_MAX_PACKET_SIZE : Maximum packet size
#ifndef MQTT_MAX_PACKET_SIZE
#define MQTT_MAX_PACKET_SIZE 128
#endif
to-->
// MQTT_MAX_PACKET_SIZE : Maximum packet size
#ifndef MQTT_MAX_PACKET_SIZE
#define MQTT_MAX_PACKET_SIZE 512
#endif