Seatalk1 to NMEA0183 with Arduino - Printable Version +- OpenMarine (https://forum.openmarine.net) +-- Forum: OpenPlotter (https://forum.openmarine.net/forumdisplay.php?fid=1) +--- Forum: How I did it (https://forum.openmarine.net/forumdisplay.php?fid=6) +--- Thread: Seatalk1 to NMEA0183 with Arduino (/showthread.php?tid=2501) Pages:
1
2
|
Seatalk1 to NMEA0183 with Arduino - jontys - 2020-04-13 In response to requests on the How Do I Thread about Seatalk1 to NMEA0183. Here's a few details of what I've done with an Arduino Mega. My implementation is to be an interface between an ONWA plotter using NMEA V3 and a B&G autohelm using NMEA V1.5. I will write it up more thoroughly when I've finished it. The Onwa has an environmental screen which displays wind vector, temperature, humidity etc., So, I am providing that data too. My wind instrument is a Raymarine I60 outputting Seatalk1. Using snippets of code from the Seatalk display code on http://berreizeta.blogspot.com/2017/02/seatalk-35-480x320-tft-monitor.html It's a relatively simple task to extract the wind speed and angle. then build NMEA sentences. I'm currently using a rather rough and ready seatalk interface of a 4k7 resistor and a couple of diodes to clamp the input voltage to 0.6v of the arduino supply rails. The I60 output is 5 to 6 volts anyway, but, I intend improving the spike protection before using this in anger. The input feeds directly into the receive pin of Serial port1. I'm using Nick Gammon's 9 bit serial library. NB: you do need to use no newer than V1.6.9 of the Arduino IDE for this library. And, if you already have a newer version installed, it can be a hunt to find the right location to place Nicks library! Output to the ONWA is via Serial port2 and a MAX485 adaptor. Output to Openplotter is via the USB Serial Port. Code Below: /*Seatalk 1 Input to NMEA MWV sentence output * Requires 9 bit serial support, which only compiles correctly on Arduino IDE V1.6.9 or earlier */ char SeaTalkData[256] , index; int z, inbyte , windangle; float windspeed; String NMEA = " "; byte CRC=0; void setup () { Serial.begin (4800); // debugging prints Serial1.begin (4800, SERIAL_8N1,true); // 9 bit mode. Serial port1 input connected to seatalk data out from Raymarine I60 via 4k7 resistor. Serial2.begin(4800); //Output to NMEA Plotter via MAX485 convertor. TX/RX held High Serial.println ("--- starting ---"); } // end of setup void loop() { if (Serial1.available ()) { inbyte = (Serial1.read()); if (inbyte & 0x100){ datagram(); index = 0 ; } if (index == 0) { //Serial.println() ; } // end 0x100 SeaTalkData[index++] = inbyte ; } // end serial } // end loop void datagram(){ //----------------------------------------------------------------- // Apparent Wind Angle (AWA): 10 01 XX YY if (SeaTalkData[0] == 0x10){ windangle = (makeWord(SeaTalkData[2] , SeaTalkData[3]))/2; if (windangle > 360){ windangle = 360;} } // end 0x10 //----------------------------------------------------------------- // Apparent Wind Speed (AWS): 11 01 XX 0Y // (XX & 0x7F) + YY/10 = speed // XX&0x80=0 = knots (default) // XX&0x80=0x80 = meters/second if (SeaTalkData[0] == 0x11){ windspeed = ((SeaTalkData[2] & 0x7F) + (float(SeaTalkData[3]) / 0x0A)); if (windspeed > 99){ windspeed = 99;} if (windspeed < 0){ windspeed = 0;} //------------------------------------------------------------------- //Generate wind sentence NMEA="XXMWV,"; //Wind angle & speed NMEA=NMEA+ String(windangle); //wind angle 0 to 359 NMEA=NMEA+",R,"; //Relative or True NMEA=NMEA+String(windspeed); // Wind Speed NMEA=NMEA+",N,A"; //Units Km/Metre/kNots and Valid indicator CalcCRC(); Serial2.println(NMEA); Serial.println(NMEA); } // end 0x11 } void CalcCRC(){ //Using the NMEA string without Dollar sign and asterix //Create a CRC by doing bitwise XOR with each character in the string. CRC=0; for(z=0;z<NMEA.length();z++){ CRC=CRC ^ NMEA[z]; } NMEA="$"+NMEA; //Place Dollar at the start of string NMEA=NMEA+"*"; //Place asterix at the end of string if(CRC<16)NMEA=NMEA+"0"; //If CRC is less than 16 then the Hex output would be 1 charcter - Pad the 1st character with zero NMEA=NMEA+String(CRC,HEX); //Append the CRC } RE: Seatalk1 to NMEA0183 with Arduino - xfactor99 - 2020-04-13 (2020-04-13, 11:36 AM)jontys Wrote: In response to requests on the How Do I Thread about Seatalk1 to NMEA0183. Here's a few details of what I've done with an Arduino Mega.Thanks a lot .... Save sailing Andreas RE: Seatalk1 to NMEA0183 with Arduino - PaddyB - 2020-04-14 I wonder if there's a library for ESP32 that will do 9 bit serial, arduino or micropython... anyone know? RE: Seatalk1 to NMEA0183 with Arduino - holgerw - 2020-04-21 (2020-04-14, 04:04 AM)PaddyB Wrote: I wonder if there's a library for ESP32 that will do 9 bit serial, arduino or micropython... anyone know? The normal SoftwareSerial Drivers on the ESP should have an 9 Bit Option, but i did not find an Example Sourcecode. Look into the Description in the Git. I would also like to adapt my old STalk Hardware with some wireless ESP Tool. Many Greetings, Holger RE: Seatalk1 to NMEA0183 with Arduino - olewsaa - 2020-05-13 (2020-04-21, 06:38 PM)holgerw Wrote:(2020-04-14, 04:04 AM)PaddyB Wrote: I wonder if there's a library for ESP32 that will do 9 bit serial, arduino or micropython... anyone know? I am also working on this, I want to use a ESP8266 module NodeMCU 12-E to convert the ST1 to SignalK and send it wireless to the SignalK server. So far I ahve not figured out how to use the SoftwareSerial in 9 bit mode. The SoftwareSerial works nicely in normal 8 bit mode. It should be doable to flip it into 9 bit mode (it's software !) and decoding the ST1 messages is already documented. Today I'm using a ST1 to USB-NMEA, but I really want to get rid of the cabels. Ole RE: Seatalk1 to NMEA0183 with Arduino - PaddyB - 2020-05-13 (2020-05-13, 08:08 AM)olewsaa Wrote: I am also working on this, I want to use a ESP8266 module NodeMCU 12-E to convert the ST1 to SignalK and send it wireless to the SignalK server. Interesting. Today I've got the hardware uarts 1 & 2 seeming to work solid on an esp32 with micropython but they won't do 9 bit. Not sure if there's a software serial for micropython, google came up with talk of uS timing problems. PyBoards do 9 bit hardware, it says... https://docs.micropython.org/en/latest/library/machine.UART.html RE: Seatalk1 to NMEA0183 with Arduino - olewsaa - 2020-05-13 (2020-05-13, 03:03 PM)PaddyB Wrote:(2020-05-13, 08:08 AM)olewsaa Wrote: I am also working on this, I want to use a ESP8266 module NodeMCU 12-E to convert the ST1 to SignalK and send it wireless to the SignalK server. The esp32 is a far more capable board, dual core processor etc (in addition to much more). The modified serial libraray out there could probably be converted to run on esp32 with its two UARTs. I still think that to modify the SoftwareSerial library should be the simplest, as this is purely done in software. If you program in Python and not in Arduino C it might be a bit different. I you succeed I'll be happy to use Python. Ole RE: Seatalk1 to NMEA0183 with Arduino - abarrow - 2020-05-14 it appears that someone has already done a 9bit version of SoftwareSerial for ESP. https://github.com/ionini/espsoftwareserial RE: Seatalk1 to NMEA0183 with Arduino - olewsaa - 2020-05-15 Cool, it just show the benfit of more eyes and working together, it's often just a question of using the right search string. I installed the library in question, but it fails to build even its own examples. This is sometimes a sign the building environment is incompatable, I use the Arduino IDE 1.8.12 which is fairly new. The errors are related to parameters in the function calling to some basic functions in the Arduino IDE framework. However, we are one the right track. The next challenge is to get the examples to build. RE: Seatalk1 to NMEA0183 with Arduino - richardonaboat - 2020-06-11 (2020-05-14, 03:25 PM)abarrow Wrote: it appears that someone has already done a 9bit version of SoftwareSerial for ESP. https://github.com/ionini/espsoftwareserial espsoftwareserial works well for me on my web based autopilot controller. Set up 8bit Mark/space parity. Parity bit will be mark for command bytes. Call readParity to check. |