forked from sborsay/Serverless-IoT-on-AWS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPubSub_Troubleshooting
32 lines (21 loc) · 979 Bytes
/
PubSub_Troubleshooting
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
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