{"id":63,"date":"2014-02-06T20:14:36","date_gmt":"2014-02-06T19:14:36","guid":{"rendered":"https:\/\/www.skrue.de\/wp\/?p=63"},"modified":"2021-03-08T15:53:13","modified_gmt":"2021-03-08T14:53:13","slug":"marine-electronics-nmea-and-arduino","status":"publish","type":"post","link":"https:\/\/www.skrue.de\/wp\/?p=63","title":{"rendered":"Marine electronics, NMEA and Arduino"},"content":{"rendered":"\n<div class=\"wp-block-image\"><figure class=\"alignright\"><a href=\"https:\/\/www.skrue.de\/wp\/wp-content\/uploads\/2014\/02\/Arduino-Medium.jpg\"><img loading=\"lazy\" decoding=\"async\" width=\"150\" height=\"150\" src=\"https:\/\/www.skrue.de\/wp\/wp-content\/uploads\/2014\/02\/Arduino-Medium-150x150.jpg\" alt=\"Arduino UNO\" class=\"wp-image-89\"\/><\/a><\/figure><\/div>\n\n\n\n<p><strong>When it comes to connecting navigation equipment and marine electronics, <a href=\"http:\/\/en.wikipedia.org\/wiki\/NMEA_0183\" target=\"_blank\" rel=\"noopener\">NMEA 0183<\/a> is a still very wide-spread standard (although some devices also feature its successor <a href=\"http:\/\/en.wikipedia.org\/wiki\/NMEA_2000\" target=\"_blank\" rel=\"noopener\">NMEA 2000<\/a>). So why not hook up an <a href=\"http:\/\/www.arduino.cc\" target=\"_blank\" rel=\"noopener\">Arduino<\/a> to your boat&#8217;s NMEA network for logging purposes, troubleshooting or as a bluetooth ga<\/strong><strong>teway for your tablet device?<\/strong><\/p>\n\n\n\n<p>On two of our club-owned sailing yachts, we use <a href=\"http:\/\/www.nexusmarine.se\/products\/marine-instruments\/nx2-systems\/\" target=\"_blank\" rel=\"noopener\">Nexusmarine NX2<\/a> instrument range and the corresponding <a href=\"http:\/\/www.nexusmarine.se\/wp-content\/uploads\/2011\/11\/Server-Man.pdf\" target=\"_blank\" rel=\"noopener\">NX2 server<\/a>, which basically collects data from all kinds of sensors and distributes it to the Nexus network and its connected instruments on the one hand, and to different NMEA outputs on the other hand.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"alignleft\"><a href=\"https:\/\/www.skrue.de\/wp\/wp-content\/uploads\/2014\/02\/NMEA-RS-232-Port-Medium.jpg\"><img loading=\"lazy\" decoding=\"async\" width=\"150\" height=\"150\" src=\"https:\/\/www.skrue.de\/wp\/wp-content\/uploads\/2014\/02\/NMEA-RS-232-Port-Medium-150x150.jpg\" alt=\"NMEA RS-232 Port (Medium)\" class=\"wp-image-94\"\/><\/a><\/figure><\/div>\n\n\n\n<p>The server features one standard RS-232 output for hooking it up to your laptop computer, using a DB9 connector. You can use it with Nexusmarine&#8217;s own &#8222;Nexus Race&#8220; software, which will set the communication protocol to FDX instead of NMEA and receive more precise sensor data. Or you may use any other navigation software&#8230; there are literally hundreds.<br>Unfortunately on both our boats this port is already in use with a computer and can&#8217;t be aquired as an Arduino playground. Bummer!<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"alignright\"><a href=\"https:\/\/www.skrue.de\/wp\/wp-content\/uploads\/2014\/02\/NMEA-Output-A-B-Medium.jpg\"><img loading=\"lazy\" decoding=\"async\" width=\"150\" height=\"150\" src=\"https:\/\/www.skrue.de\/wp\/wp-content\/uploads\/2014\/02\/NMEA-Output-A-B-Medium-150x150.jpg\" alt=\"NMEA Output A B (Medium)\" class=\"wp-image-93\"\/><\/a><\/figure><\/div>\n\n\n\n<p>But wait, there&#8217;s one more NMEA output. The pins 3 and 4 on the Nexus server are labeled &#8222;NMEA Output A&#8220; and &#8222;NMEA Output B&#8220;. This output uses the RS-422 standard which is very similar to RS-485 (RS-422: one transmitter, multiple receivers \/ RS-485: multiple transmitters, multiple receivers). Therefore we need some sort of RS-485 receiver on the Arduino side. You may build your own circuit around a MAX485 or just get one of <a href=\"https:\/\/www.google.com\/search?q=max485+arduino+module\" target=\"_blank\" rel=\"noopener\">these 2$ modules<\/a> from eBay like I did. They come with all neccessary resistors fitted but are, layout-wise, not exactly breadboard friendly.<br><em>Side note:<\/em> I also tried hooking up the Arduino to the Nexus network (which is also RS-485, pins 6 and 7 on the server are the data pins) but haven&#8217;t yet been able to figure out the right settings to get correct FDX data. Maybe the protocol on the network bus is even slightly different from FDX&#8230; But as &#8222;Nexus Race&#8220; seems to be the only software talking FDX, it&#8217;s not of much interest for Arduino projects anyway.<\/p>\n\n\n\n<p>To get the NMEA sentences from the RS-422 bus into your Arduino, wire everything up like this:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td><strong>RS-485 module<\/strong><\/td><td><strong>Arduino UNO<\/strong><\/td><\/tr><tr><td>GND<\/td><td>GND<\/td><\/tr><tr><td>VCC<\/td><td>+3.3V (!)<\/td><\/tr><tr><td>RE<\/td><td>GND<\/td><\/tr><tr><td>RO<\/td><td>Pin 13<\/td><\/tr><tr><td>A<\/td><td>Nexus server Pin 4 (NMEA output B)<\/td><\/tr><tr><td>B<\/td><td>Nexus server Pin 3 (NMEA output A)<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"alignright\"><a href=\"https:\/\/www.skrue.de\/wp\/wp-content\/uploads\/2014\/02\/MAX485-2-Medium.jpg\"><img loading=\"lazy\" decoding=\"async\" width=\"150\" height=\"150\" src=\"https:\/\/www.skrue.de\/wp\/wp-content\/uploads\/2014\/02\/MAX485-2-Medium-150x150.jpg\" alt=\"MAX485 2 (Medium)\" class=\"wp-image-92\"\/><\/a><\/figure><\/div>\n\n\n\n<p>Note that A and B are swapped! Of course you may change the Arduino RX pin from 13 to anything you like. But don&#8217;t forget to update it in the sketch. Since we don&#8217;t want to transmit any data (remember: RS-422 = only one transmitter which is the NX2 server), set the TX pin in the sketch to any unused pin to prevent strange behaviour of your setup&#8230; just in case. If you use your own MAX485 circuit you will need additional resistors and stuff, but I assume you know that.<\/p>\n\n\n\n<p>Now, upload this really dead simple sketch to your Arduino:<\/p>\n\n\n\n<div class=\"wp-block-group\"><div class=\"wp-block-group__inner-container is-layout-flow wp-block-group-is-layout-flow\">\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"c\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"true\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">#include &lt;SoftwareSerial.h>\n\nSoftwareSerial nmeaSerial(13, 9); \/\/ RX, TX\n\nvoid setup()  \n{\n  Serial.begin(9600);\n  Serial.println(\"Waiting for incoming NMEA data.\");\n  nmeaSerial.begin(4800);\n}\n\nvoid loop()\n{\n  if (nmeaSerial.available())\n    Serial.write(nmeaSerial.read());\n}<\/pre>\n<\/div><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"alignright\"><a href=\"https:\/\/www.skrue.de\/wp\/wp-content\/uploads\/2014\/02\/Arduino-NMEA-01.png\"><img loading=\"lazy\" decoding=\"async\" width=\"150\" height=\"150\" src=\"https:\/\/www.skrue.de\/wp\/wp-content\/uploads\/2014\/02\/Arduino-NMEA-01-150x150.png\" alt=\"Arduino NMEA 01\" class=\"wp-image-90\" srcset=\"https:\/\/www.skrue.de\/wp\/wp-content\/uploads\/2014\/02\/Arduino-NMEA-01-150x150.png 150w, https:\/\/www.skrue.de\/wp\/wp-content\/uploads\/2014\/02\/Arduino-NMEA-01-300x299.png 300w, https:\/\/www.skrue.de\/wp\/wp-content\/uploads\/2014\/02\/Arduino-NMEA-01.png 379w\" sizes=\"auto, (max-width: 150px) 100vw, 150px\" \/><\/a><\/figure><\/div>\n\n\n\n<p>Power up your Nexus server, open the serial port monitor and watch the NMEA sentences fly by&#8230;<\/p>\n\n\n\n<p>As it doesn&#8217;t get you very far to just <em>watch<\/em> the NMEA data, you may now add any functionality you like. Data logging to SD-Card (I&#8217;m still waiting for my SD shield to arrive&#8230;), streaming everything to a bluetooth transmitter for using the NMEA data on your tablet device (also pretty simple &#8211; coming up next) or hooking up a LCD display for basic NMEA network troubleshooting (I have done this as well and will write about it soon).<\/p>\n\n\n\n<p>Although I used the Nexus NX2 server as an example, this should work with almost every marine electronics device capable of outputting NMEA data like GPS devices, chart plotters, etc. etc. As far as I know, may AIS receivers use a higher bit rate, so take that into account if you want to use AIS NMEA data.<\/p>\n\n\n\n<p>In case you have more than one NMEA source that you want to read (maybe an additional AIS receiver or something) you should probably get an Arduino Mega 2560 or Arduino Due which provide four UART (hardware serial) ports. Working with multiple SoftwareSerial ports on the Uno will probably not work out very well in terms of performance and therefore leave you with mostly mashed up, useless data (feel free to prove me wrong).<\/p>\n\n\n\n<p><em>Disclaimer:<\/em> When building anything like this based on my write-up, you do it at your own risk. Please be careful not to destroy any of your expensive marine electronics.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>When it comes to connecting navigation equipment and marine electronics, NMEA 0183 is a still very wide-spread standard (although some devices also feature its successor NMEA 2000). So why not hook up an Arduino to your boat&#8217;s NMEA network for logging purposes, troubleshooting or as a bluetooth gateway for your tablet device? On two of [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":89,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,2,1],"tags":[],"class_list":["post-63","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-arduino","category-basteln","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/www.skrue.de\/wp\/index.php?rest_route=\/wp\/v2\/posts\/63","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.skrue.de\/wp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.skrue.de\/wp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.skrue.de\/wp\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.skrue.de\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=63"}],"version-history":[{"count":28,"href":"https:\/\/www.skrue.de\/wp\/index.php?rest_route=\/wp\/v2\/posts\/63\/revisions"}],"predecessor-version":[{"id":163,"href":"https:\/\/www.skrue.de\/wp\/index.php?rest_route=\/wp\/v2\/posts\/63\/revisions\/163"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.skrue.de\/wp\/index.php?rest_route=\/wp\/v2\/media\/89"}],"wp:attachment":[{"href":"https:\/\/www.skrue.de\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=63"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.skrue.de\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=63"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.skrue.de\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=63"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}