2020-10-14, 11:10 PM
If I turn the pypilot it immediately shows the new compass reading. My esp32 continues to show the old reading for 30secs or more. Checking port 20220 with opencpn debug shows the correct readings, so the problem is with the esp, maybe my code?
void loop() {
WiFiClient client;
if (!client.connect(host, port)) {
Serial.println("Connection to host failed");
delay(4000);
return;
} // end if
Serial.println("Connected to server successful!");
while (client.connected()){
if (client.available()) {
String NMEAline = client.readStringUntil('\n'); //Read one line of the NMEA output
if(NMEAline.startsWith("$APHDM")){ //Check if it is the APHDM one which contains the info I want
Serial.println(NMEAline); //Print it out over serial
delay(500);
} // end if
} // end while
} // end line if
} // end loop
void loop() {
WiFiClient client;
if (!client.connect(host, port)) {
Serial.println("Connection to host failed");
delay(4000);
return;
} // end if
Serial.println("Connected to server successful!");
while (client.connected()){
if (client.available()) {
String NMEAline = client.readStringUntil('\n'); //Read one line of the NMEA output
if(NMEAline.startsWith("$APHDM")){ //Check if it is the APHDM one which contains the info I want
Serial.println(NMEAline); //Print it out over serial
delay(500);
} // end if
} // end while
} // end line if
} // end loop