Hello everybody!
I need some help. I'm using a LilyGO TTGO T3 LoRa32 433MHz V1.6.1 ESP32 board and i made a connection to the Arduino IoTCloud. This works! I get my data and everything. But after 30 minutes the board disconnects from the cloud and i get the following error message:
17:12:33.357 -> ArduinoIoTCloudTCP::handle_Disconnect MQTT client connection lost
17:12:33.404 -> Disconnected from Arduino IoT Cloud
17:12:33.404 -> Connection to "WIFI Extender 7" lost.
17:12:33.450 -> Attempting reconnection
17:12:34.422 -> WiFi.status(): 6
17:12:38.437 -> Connected to "WIFI Extender 7"
17:12:38.899 -> ArduinoIoTCloudTCP::handle_ConnectMqttBroker could not connect to iot.arduino.cc:8884 Error: -2
TimeServiceClass::getRemoteTime cannot get time from NTP, fallback on connection handler
After this the message is looped for ever.
Can somebody help me with this problem?
Thank you in advanced.
I will link my code below.
#include "arduino_secrets.h"
#include "thingProperties.h"
//Libraries for LoRa
#include <SPI.h>
#include <LoRa.h>
//Libraries for OLED Display
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
//define the pins used by the LoRa transceiver module
#define SCK 5
#define MISO 19
#define MOSI 27
#define SS 18
#define RST 23
#define DIO0 26
//433E6 for Asia
//866E6 for Europe
//915E6 for North America
#define BAND 433E6
//OLED pins
#define OLED_SDA 21
#define OLED_SCL 22
//#define OLED_RST 16
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire);
int inC, inT, inH, inD;
String loRaMessage;
void setup() {
// Initialize serial and wait for port to open:
Serial.begin(9600);
// This delay gives the chance to wait for a Serial Monitor without blocking if none is found
delay(1500);
// Defined in thingProperties.h
initProperties();
// Connect to Arduino IoT Cloud
ArduinoCloud.begin(ArduinoIoTPreferredConnection);
/*
The following function allows you to obtain more information
related to the state of network and IoT Cloud connection and errors
the higher number the more granular information you’ll get.
The default is 0 (only errors).
Maximum is 4
*/
setDebugMessageLevel(2);
ArduinoCloud.printDebugInfo();
//initialize OLED
Wire.begin(OLED_SDA, OLED_SCL);
if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3c, false, false)) { // Address 0x3C for 128x32
Serial.println(F("SSD1306 allocation failed"));
for(;;); // Don't proceed, loop forever
}
display.clearDisplay();
display.setTextColor(WHITE);
display.setTextSize(1);
display.setCursor(0,0);
display.print("LORA RECEIVER v1");
display.display();
Serial.println("LoRa Receiver Test");
//SPI LoRa pins
SPI.begin(SCK, MISO, MOSI, SS);
//setup LoRa transceiver module
LoRa.setPins(SS, RST, DIO0);
if (!LoRa.begin(BAND)) {
Serial.println("Starting LoRa failed!");
while (1);
}
// Change sync word (0xF3) to match the receiver
// The sync word assures you don't get LoRa messages from other LoRa transceivers
// ranges from 0-0xFF
LoRa.setSyncWord(0xFF);
Serial.println("LoRa Initializing OK!");
display.setCursor(0,10);
display.println("LoRa Initializing OK!");
display.display();
}
void loop() {
ArduinoCloud.update();
//try to parse packet
int packetSize = LoRa.parsePacket();
if (packetSize) {
//received a packet
Serial.print("Received packet ");
//read packet
while (LoRa.available()) {
LoRaData = LoRa.readString();
Serial.print(LoRaData);
}
//print RSSI of packet
int rssi = LoRa.packetRssi();
Serial.print(" with RSSI ");
Serial.println(rssi);
// Get readingID, temperature and soil moisture
int pos1 = LoRaData.indexOf('/');
int pos2 = LoRaData.indexOf('&');
int pos3 = LoRaData.indexOf('#');
readingID = LoRaData.substring(0, pos1);
temperature = LoRaData.substring(pos1 +1, pos2);
humidity = LoRaData.substring(pos2+1, pos3);
waterDistance = LoRaData.substring(pos3+1, LoRaData.length());
Serial.println(readingID);
Serial.println(temperature);
Serial.println(humidity);
Serial.println(waterDistance);
// Dsiplay information
display.clearDisplay();
display.setCursor(0,0);
display.print("LORA RECEIVER");
display.setCursor(0,20);
display.print("Received packet:");
display.setCursor(0,30);
display.print(LoRaData);
display.setCursor(0,40);
display.print("RSSI:");
display.setCursor(30,40);
display.print(rssi);
display.display();
}
}