This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Pypilot heading display
I have managed to use to use an esp32 to read  HDM from port 20220 but cant create a loop that will give me a continuously updated stream. The string looks like 192.123, the numbers after the decimal point continuously change but the 192 is only correct when I first connect.  Is it necessary for me to send a request to update the reading?
Thanks for your help  John
So if you reconnect the socket you get a new number? Did the compass move? Is it calibrated? Does pitch and roll give the same?

I will play with this more.
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");
 } // 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
    } // end if
  } // end while
  } // end line if
} // end loop
I would check netcat and then just dump the raw data over serial to see if you are getting the data.

You had me worried it was my bug Smile
I think my problem is caused by the buffer filling up with data, it is then read and displayed, so I always see data that is 20sec to 2min old. The usual Arduino TCP functions dont seem to be able to handle that. Any suggestions? 
Ive given up on TCP, I have converted the TCP data to UDP in opencpn. It now works ok with about 4sec delay.  
Thanks for your help -  John

Forum Jump:

Users browsing this thread: 1 Guest(s)