Sunday, September 27, 2015

How to Connect any NMEA-0183 Device to an Arduino


NMEA-0183 uses 12V signals to communicate with each other. The oldest instruments use RS-232, or a single wire that sends a high voltage followed by a low voltage, to indicate on or off. Newer NMEA-0183 devices us the RS-422 protocol, which uses two wires (a positive and a negative) that alternate between high and low to achieve the same effect, with greater accuracy and less chance for error. But the point is, both use 12 volts along their wires, and that will fry your Arduino if you plug it directly in.

EDIT 24 May, 2016: Apparently this is incorrect. 5V is the industry standard for RS-422, and 10V is the max voltage allowed for open circuits. See Max44's comments below the entry for more.

Recommended Gear

NMEA-0183: RS-232 or RS-422 or RS-485?

This part is really easy. If you have a single transmit wire from your device (most likely labeled TX or NMEA OUT or something like that), then it uses the RS-232 protocol, and you need the respective converter. If your device has two wires coming out (typically labeled NMEA OUT+ and NMEA OUT- or TX+ or TX-), then you have RS-422. What about RS-485? For our purposes, it's the same thing as RS-422. The difference is that with 485, you can connect a bunch of different devices that can all talk to each other, which is cool and all, but not applicable for our NMEA device. For our purposes, treat RS-485 the same as RS-422, since the protocal is identical (just RS-485 can support a lot more devices than RS-422, like on the order of 80 or so more).

Wiring Diagrams for NMEA-0183 and Arduino devices

There are way too many converters out there to cover them all, but I'll cover a few here. You are basically looking at a simple system: the NMEA-0183 device sends a signal to the converter (either a single wire or two), and that tones the signal down to 3-5V for the Arduino, and pipes that signal out to the input on the Arduino itself. For the most part, you don't need power since most NMEA-1083 devices require 12V, something the Arduino can't put out. So here are a few examples:

SparkFun MAX3232 Wiring Diagram (for RS-232)

NMEA-0183MAX3232ARDUINO
TXT1 OUT

R1 OUTReceive Pin

SparkFun RS232 Shifter (No DB9) (for RS-232)

NMEA-0183RS-232 ShifterARDUINO
TXPin 2 (right next to the square hole)
TX-OReceive Pin

RS-422/485 Shifter

NMEA-0183RS-422/485 ShifterARDUINO
NMEA+B
NMEA-A
VCC5V
GNDGround
REGround
ROReceive Pin

It also goes without saying that you need to ensure your device is powered through the boat's electrical system. Now that we have our device physically connected, let's work through the code.

My super hi-tech test bed

The NMEA-0183 Arduino Library

Marten Laamer's has done a fantastic job building this useful and lightweight library. You'll need to download his library and check out his website over here first. There are hundreds of tutorials out there to get a GPS working (including some that come with the library), which is useful but pretty easy to figure out, so I'm going to show how to use his library to parse any NMEA sentence.

First, you must open up nmea.h and change this line

 #include "WConstants.h"  

to this

 #include "arduino.h"  

Then open up nmea.cpp and change this line

 #include "WProgram.h"  

to this

 #include "arduino.h"  

The most basic application is to receive an NMEA sentence, and then send it without doing anything. Here's a quick sketch for doing just that (remember, you must have the NMEA library included).

 #include <nmea.h>   
     
  NMEA nmeaDecoder(ALL);   
     
  void setup() {   
  Serial.begin(4800);   
  Serial2.begin(4800);   
  }   
     
  void loop() {   
  if (Serial2.available()) {                 // if something is incoming through the Serial Port
   if (nmeaDecoder.decode(Serial2.read())) { // if it's a valid NMEA sentence   
    Serial.println(nmeaDecoder.sentence());  // print it   
    }   
   }   
  }  

Pretty boring and basic. Here's what the Serial Monitor output looks like. So if you connect this to your chart plotter, this is what it will see. If you connect more than one instrument, then just include each "If Serial is Available" loop for each appropriate Serial Port.

If you have no clue what's going on, this basically scans the Serial port that we plugged our converter into (the Receiver Pin in the wiring diagrams above). We're using Serial Port 2 as our input for my DST-800, which is using the RS-422 converter. If you are using an RS-232 device (with only one NMEA Transmit wire), then you actually have to get a little more fancy because the converter inverts your signal. So if you are using an RS-422 device, and you're not getting good output, then maybe just swap the A and B wires and try again.

But you can't just do that with an RS-232 signal, since there's only one wire. So what you have to do is use the Software Serial Library. Here's a sample sketch that uses an RS-232 NMEA-0183 device.

 #include <SoftwareSerial.h>  
 #include <nmea.h>  
   
 SoftwareSerial nmeaSerial(10,11,true); // RX pin, TX pin (not used), and true means we invert the signal  
 NMEA nmeaDecoder(ALL);   
   
 void setup()  
 {  
  Serial.begin(4800);  
  nmeaSerial.begin(4800);  
 }  
   
 void loop()  
 {  
   if (nmeaSerial.available() > 0 ) {  
     if (nmeaDecoder.decode(nmeaSerial.read())) {  
     Serial.println(nmeaDecoder.sentence());  
    }  
   }
 }  

Note that this includes the SoftwareSerial Library. This is basically taking a Serial signal, and instead of plugging it into a Serial Port, we're plugging it into a digital pin and simulating a Serial Port. We have to do it this way because this is the only way to invert the Serial Signal on an Arduino. I suppose you could get another converter, and wire two of them together to invert the signal twice (ending with the original signal), but that's wholly unnecessary.

Something else to note with this is that I tried hooking up my wireless wind vane to it, but the signal kept getting garbled. Unfortunately, I don't know if it was the converter not doing it's job, or if it was the unit itself. It occasionally spat out a wind sentence, but it wasn't usable because it was one constant stream of meaningless characters interspersed with a valid sentence. I ended up returning the wind vane, and hopefully the next one works fine. But it DID put out valid sentences for the first week; so I know it works with the Max3232 converter.

But now let's get a little more complicated. Here's a sample sketch that parses the sentence, and allows you do manipulate it how you want. Then we reconstruct it as a valid sentence, including a checksum function. A huge thanks goes to Tom over at https://mechinations.wordpress.com/ for guiding me in the right direction for the sentence creation on an Arduino. I highly recommend you go over there to check out his cool stuff (especially this post).

 #include <nmea.h>  
   
 NMEA nmeaDecoder(ALL);  
   
 void setup() {  
  Serial.begin(4800);  
  Serial2.begin(4800);  
 }  
   
 void loop() {  
 if (Serial2.available()) {  
   if (nmeaDecoder.decode(Serial2.read())) {  // if we get a valid NMEA sentence  
     Serial.println(nmeaDecoder.sentence());  
     char* t0 = nmeaDecoder.term(0);  
     char* t1 = nmeaDecoder.term(1);  
     char* t2 = nmeaDecoder.term(2);  
     char* t3 = nmeaDecoder.term(3);  
     char* t4 = nmeaDecoder.term(4);  
     char* t5 = nmeaDecoder.term(5);  
     char* t6 = nmeaDecoder.term(6);  
     char* t7 = nmeaDecoder.term(7);  
     char* t8 = nmeaDecoder.term(8);  
     char* t9 = nmeaDecoder.term(9);  
     Serial.print("Term 0: ");  
     Serial.println(t0);  
     Serial.print("Term 1: ");  
     Serial.println(t1);  
     Serial.print("Term 2: ");  
     Serial.println(t2);  
     Serial.print("Term 3: ");  
     Serial.println(t3);  
     Serial.print("Term 4: ");  
     Serial.println(t4);  
     Serial.print("Term 5: ");  
     Serial.println(t5);  
     Serial.print("Term 6: ");  
     Serial.println(t6);  
     Serial.print("Term 7: ");  
     Serial.println(t7);  
     Serial.print("Term 8: ");  
     Serial.println(t8);  
     Serial.print("Term 9: ");  
     Serial.println(t9);  
     Serial.println("--------");  
     }  
   }  
 }  

And here's the output:


As you can see, we can extract different terms from the sentence quite easily, and manipulate them if need be (but be careful--if you don't redeclare each term, then it will reflect the previous sentence if the new sentence doesn't have one). For example, my DST-800 has a temperature sensor on it which gives out the YXMTW NMEA sentence, which is the Mean Temperature of the Water (the first two characters, "YX," are largely meaningless for NMEA-0183--they just designate the name of the device transmitting. You could put anything there and it would still work fine). A good place to start for NMEA sentences is this page here, and we see that the MTW sentence format is as follows:

          1  2  3   
          |  |  |   
  $--MTW,x.x,C*hh  
 1. Temperature  
 2. Units  
 3. Checksum  
In order to print our own NMEA sentence, we will also need the PString Library available over here. Let's go ahead and change that Fahrenheit, with the following sketch:

 #include <PString.h>  
 #include <nmea.h>  
   
 NMEA nmeaDecoder(ALL);  
   
 void setup() {  
  Serial.begin(4800);  
  Serial2.begin(4800);  
 }  
   
 // calculate checksum function (thanks to https://mechinations.wordpress.com)  
 byte checksum(char* str)   
 {  
   byte cs = 0;   
   for (unsigned int n = 1; n < strlen(str) - 1; n++)   
   {  
     cs ^= str[n];  
   }  
   return cs;  
 }  
   
 void loop() {  
 if (Serial2.available()) {  
   if (nmeaDecoder.decode(Serial2.read())) {  
     char* title = nmeaDecoder.term(0);  
     if (strcmp(title,"YXMTW") == 0) {            // only run the following code if the incoming sentence is MTW  
      Serial.println(nmeaDecoder.sentence());     // prints the original in Celsius  
      float degc = atof(nmeaDecoder.term(1));     // declares a float from a string  
      float degf = degc*1.8+32;                   // and converts it to F  
       
      // Time to assemble the sentence  
      char mtwSentence [18];                      // the MTW sentence can be up to 18 characters long  
      byte cst;  
      PString strt(mtwSentence, sizeof(mtwSentence));  
      strt.print("$YXMTW,");  
      strt.print(degf);  
      strt.print(",F*");  
      cst = checksum(mtwSentence);  
      if (cst < 0x10) strt.print('0');            // Arduino prints 0x007 as 7, 0x02B as 2B, so we add it now  
      strt.print(cst, HEX);  
      Serial.println(mtwSentence);  
     }  
    }  
   }  
 }  

And this is the output:


And there it is! We have parsed the sentence, converted it to Fahrenheit, and then printed out a new NMEA sentence. Pretty simple, right?

Final Thoughts on NMEA-0183 Devices and Arduino

This means we can do a lot of cool things, such as: convert our speed to miles per hour, or extract our latitude/longitude for any sort of application. Or even filter our wind speed using the MPU-9150. Or anything, really, and then make our own sentence with whatever data we want. This unlocks a huge amount of possibilities for chart plotting, sailing, and taking charge of your own sailboat.


67 comments:

  1. Would you know whether the TTL/RS232 conversion and signal inversion can be done with an opto-isolator? I'm using an Arduino Due for multiplexing N0183 and that is limited to 3.3v so was going to use an o/i to ensure the voltages on the Due side are kept below that value, whereas typical network signal voltages are - i think - about 5v.
    The o/i inverts the signal anyway (no need then for Softwareserial) and I assume the change of voltage (upwards when outputting multiplexed signal back to 0183 network from Due) will be readable by network?

    ReplyDelete
    Replies
    1. I do not know. However, I do know that any of those standard converters that I linked to above step down the voltage from +/-12 to TTL levels (I think +/- 3v).

      I have also connected my depth sounder directly to a Serial Port on the Arduino Mega, and it read it no problem. That's kind of dangerous, though... my depth sounder, even though it outputs it's NMEA signal at RS-422 levels (+/-12V), actually only output signals at up to +/- 5V (I connected the lines to a voltmeter), and thus the RS-422 to TTL converter wasn't necessary. But that may have just been a one time fluke, so I got the converter above just in case. Otherwise I'd have to buy a new Arduino.

      But to answer your question... I don't actually know what an opto-isolator is. But I do believe all you have to do is step the overall voltage down--the actual signal itself should remain the same.

      Delete
    2. I'm currently working with a NAVMAN Depth 3100 and a standard through hull transducer.
      The NAVMAN has a NMEA output (single wire).
      I'm going to try to get the information from this to my Arduino.

      But:
      Is there a way to directly connect the transducer to the Arduino?

      Delete
  2. Hi sir, would you give me schematic of Arduino to RS485 and RS485 to Airmar DST800. I have do try it but it didn't give me serial output in my Arduino Serial Monitor. By the way, I used Arduino Mega 2560. Thank you.

    ReplyDelete
    Replies
    1. I have it connected exactly as in the table in the blog post, using this RS-422/485 Shifter (http://amzn.to/1M4WSso). DST800+ to ShifterB, DST800 to ShifterA. Then I have the ShifterVCC to Arduino5V, the Ground to Ground (obviously, nothing special here). Then I ALSO have ShifterRE to ArduinoGround, and then finally the ShifterRO to the ArduinoRx pin, whichever port you use.

      Delete
    2. I have buy 485 shifter. After I wire it with my Arduino, seems like on your blog, my 485 shifter getting warm. I don't know why, so I decide to buy a MAX485 IC. But it still won't show on my Serial Monitor. Do you know why is it? By the way, what version of your Arduino IDE and how about supply for DST800? Is it 12V, higher or lower? Thank you. Please help me.
      This is my email: novitiyono.54@gmail.com

      Delete
    3. The DST-800 is powered by 12v. I'm not sure what else could be happening. You may want to read the comments in this post here: http://kingtidesailing.blogspot.com/2015/10/the-king-tide-sailing-arduino-nmea-0183.html

      Also, I no longer use the Arduino. I use a Raspberry Pi now, which I think is better and cheaper.

      Delete
    4. Last night I try to see the data and it show. But only one time. I think I have a problem with the circuit. The program is OK. Thank you very much

      Delete
  3. I have it connected exactly as in the table in the blog post, using this RS-422/485 Shifter (http://amzn.to/1M4WSso). DST800+ to ShifterB, DST800 to ShifterA. Then I have the ShifterVCC to Arduino5V, the Ground to Ground (obviously, nothing special here). Then I ALSO have ShifterRE to ArduinoGround, and then finally the ShifterRO to the ArduinoRx pin, whichever port you use.

    ReplyDelete
    Replies
    1. I use an oscilloscope, and the signal from my IC came out. But my serial monitor still won't show the data. I think I have a problem with my program. I have download NMEA library and change it.

      Delete
  4. Hi, I found your site and think it is fantastic. I would like to use your Arduino programming to control a 12V winch so that the depth information from the transducer will be sent to the Arduino which in turn will raise or lower the winch so that I can keep the terminal end of the winch the same distance from the bottom. Do you think your coding will work for this? I have no computer skills so I'm relying on talented folks like yourself to guide me. On a related note, I keep having difficulty returning to your post "Connect Any NMEA 0183 to an Arduino". I see it for a second then I get redirected to your Raspberry Pi post. Any help with my project would be greatly appreciated. Cheers, Mark

    ReplyDelete
    Replies
    1. I think that's a fantastic idea! I was working on figuring my next project, and I think this is a good way for me to spend more time with the boat. Though I'm not sure how to implement it, you'd need some sort of rotational sensor on your winch that would tick up every rotation, and then you'd know (by the diameter of the winch) how much line has gone down, and how much has wound up.

      So yes, this code would work for that application. But I'm not sure how to implement it. Probably a hall effect sensor installed NEXT to the winch, with a magnet on the winch itself. Something along those lines. And then it would keep track of how much line has gone out by writing that number to the EEPROM data on the Arduino. Whew, this is already beyond my capabilities.

      And try the new layout. I hated the other one, and I kind of hate this one, but at least it works.

      Delete
    2. Thanks for getting back to me. The new layout is working better. It just seemed to be some sort of bug as I could get in but not every time. What are the chances you are on the Weest Coast of Canada as your blog URL is .ca? I would love to give you way more detail in an email if that is possible? Im happy to share it with others but too much for a blog post. my coordinates are: the4thzeke'at'gmail.... Send me a PM if that works for you? If not we can toggle back and forth here.

      Delete
    3. Nope, I'm in California. I think google automatically changes the url to your country you're viewing in.

      I'd prefer to keep everything in the comments, so as to help anyone else who is looking. That's actually how I figured out the DST-800 to Arduino--it was from a comments section.

      Delete
    4. Not a problem I'm up north in Vancouver. What I am doing is working on linking my sounder to my downrigger for fishing near the bottom The downrigger will need to raise and lower with the contour of the bottom. Im pretty good woth mechanicalthings but hopeless with writing code as Im over 50 years old! The plan is to use the Arduino to control the downrigger, a linear actuator, a optical?? counter and hopefully a IR remote. Pretty ambitious - I know - but fun to build. Thestumbling block for me was getting the depth info into the Arduino (as well as all the other coding) so I have been watching hour after hour of YouTube to try and learn this stuff Im open to any help others can provide and gain from this.

      Delete
    5. My last sentence was supposed to be "and have others gain from this". So other people can do the same based on what I can piece together.

      Delete
    6. That's a pretty clever implementation of this. I do not know exactly how to do it, but I'd start with this. Get the Arduino code from some example somewhere to control a motor, and adapt that to control your winch motor somehow. Then once you've that figured out, figure out how to measure how much line is out on the winch using two hall effect sensors (or a paddle wheel?) so you can know if it's extending line or retracting line. THEN incorporate the above code to tell it how far to extend or retract the line.

      I'm sure you already figured out that's the direction you should go, but that's about all I can do for you.

      Delete
    7. This may be a little late as i have only just seen this link.
      An anchor winch controller is somethinig i am working on. You will need a reed switch or hall effect device. I am using a micro reed for r&d. Pull up resistor and input diode protection to filter transients and clamp voltage. I am trying differens display types due to bright outdoor lighting, including 8x8 led matrix.
      I am using a high current relay for the up and down control. When i get the pulses from the reed, i check to see if the up or down button is being pressed, in order to work out the direction..ie..adding or subtracting. To get the ammount of chain calculation, i am using Pi function and some math, in order to work out how much chain per click on the reed switch. Its not hard at all. I am just making a standalone unit to i can singlehand my liveaboard in Australia. Sorting out NMEA standard is a harder item i am trying to learn. So much miss information on the net. My chain counter is standalone. The NMEA is for my wind speed and direction home made unit. Converting all to WiFi so i can feed data into my navionix app on my android TAB. Also for kpen pn on my tablet. Marine electro ics is so expensive and plays of lack of players in the market. I am developing a range of products for the retired persons cruiser market. Wind speed $1000 upwards, chain counter $450 upwards...what a joke.

      Delete
  5. I was looking more for a "is this possile or not " so I don't waste many more hours learning code for something that is impossible. I think your work with the sounder already gave me the confidence to try it so I cant thank you enough. I will update you as I make progress. Thanks for being my launching pad!

    ReplyDelete
    Replies
    1. Oh yeah, it's definitely possible. Keep me updated on your progress!

      Delete
  6. Hi Connor! Is there any chance you know why I would be getting the following error when I run the program " "Serial2 was not declared in this scope'. I am stumped. Im wondering if it is because you used an older IDE? Any help would be greatly appreciated.

    ReplyDelete
  7. Me again, After working on this for most of the night I think I have solved the issue - the Uno does not accept a Serial2 but the Mega does. I'll test this theory later today and let you know.

    ReplyDelete
    Replies
    1. Yes, you are correct. I believe the Uno only has one serial port, hence there is no Serial2 available to connect to.

      Delete
  8. I read your posts with lots of interest. I'm looking to make a device that gives direct nmea input to my autopilot computer. Am I correct this setup wil not work since there wil not be a 12v NMEA output?

    ReplyDelete
    Replies
    1. I believe it should work. All you have to do is follow this guide in reverse--instead of receiving NMEA data from the serial port (like I have described above), all you have to do is print to the serial port. I don't know if it could be bi-directional though. But it will output at 12V for NMEA instruments no problem.

      Delete
  9. Why are there a lot of comments about RS422 and RS485 being at 12Vdc level. 5V is used in industry. 10V is the maximum open circuit voltage, set by the standard. I am looking at making a NMEA device and have been doing my research. NMEA standard2 says to use opto isolators...no problem. I was wondering why people are using off the shelf converters which have a Vcc of 5v. Google max485 chip as this is a common industry multidrop chip. Note maximum input voltages. I realise 422 is ot the same as 485, but the electrical framework is the same.

    ReplyDelete
    Replies
    1. Thanks for the knowledge. Like I mentioned above, I really don't know what I'm doing--most of this info I pulled from various places around the web. 5V being the standard level makes sense then, since when I plugged my depth sounder directly into the Serial Port, it didn't fry it. Also, the 485 converter I linked to above--I believe that's the max485 chip, is that the one you're referring to?

      Delete
  10. You are correct. Most of the informatiin on the web does say 12 volt. Seatalk (version 1) is 12volt. RS 232 is +-12volt. The correct IEEE standard for RS485 is 5 volt. What fully complient NMEA standards say the input and output...talker or listeners are to be opto isolated. Most RS485 converters have a resistor and zenner diode over voltage protection circuit on the input and output. This is what has stopped your devices from blowing up. In saying this, even some manufacturers use serial/RS232 at five or twelve volts. I worked for years as an RandD enguneer in industrial electronics. RS485 and fibre optics was a common design for us. This is why i know the standard so well. Its great w all share information even if some of it, i suspect, has been put on the web as disinformation by those not wishing to allow end users to make thier own devices. Thanks for sharing guys.

    ReplyDelete
  11. You are correct. Most of the informatiin on the web does say 12 volt. Seatalk (version 1) is 12volt. RS 232 is +-12volt. The correct IEEE standard for RS485 is 5 volt. What fully complient NMEA standards say the input and output...talker or listeners are to be opto isolated. Most RS485 converters have a resistor and zenner diode over voltage protection circuit on the input and output. This is what has stopped your devices from blowing up. In saying this, even some manufacturers use serial/RS232 at five or twelve volts. I worked for years as an RandD enguneer in industrial electronics. RS485 and fibre optics was a common design for us. This is why i know the standard so well. Its great w all share information even if some of it, i suspect, has been put on the web as disinformation by those not wishing to allow end users to make thier own devices. Thanks for sharing guys.

    ReplyDelete
  12. Hi, I was wondering if you could please help. I am trying the first sketch with a lowrance dsi transducer. I bought the same RS485>TTL shield and did the wiring as above, but nothing is being received. From the pinout for the transducer it seems there is XDR+/XDR- & XDR Shield. Should the Shield be connected to ground?

    This blog gave me inspiration to try this, feeling a bit frustrated as it looked pretty easy :)

    Cheers!

    ReplyDelete
    Replies
    1. Ok follow up, i connected directly to the com port 1 of the fish finder it was reading the data successfully! So my wiring for coms etc is fine.

      My issue seems to be there is no power on the transducer without the chartplotter connected. Without cutting the cable, how can I get power to the transducer?

      The pinout: http://65.38.22.198/Lowrance/Images/DSI-pwr-pinout.jpg

      Can i somehow short it or is it actually not getting any power?

      Delete
    2. It's not too difficult, fortunately. I'm doing the same thing but with a Furuno RD30 display unit, though mine came with no cord. After a few trial and error attempts, I figured out which pins are which on the unit. To my luck (and probably yours too), the jumper cables I use fit perfectly onto the pins.

      I'm talking about these (http://amzn.to/1TYkUew) and I'm guessing if you take the male/pin end, it will fit just fine into the cord. For me, I'm using the female end of the jumper cable to fit over the pins.

      You can, of course, short it by touching the Batt+ and Batt- wires together. As far as the shield, you can ignore that (I think...). As far as I understand, the shield is just there to create a sort of magnetic shield field around the cord so that other cords or magnets don't change the voltage in the wires (if you recall from physics, any electricity moving through wires generates a magnetic field... and a magnetic field can generate voltage in those wires). So you can safely cut that shield and not worry about connecting it to anything.

      However, you will have to connect the Batt+ and Batt- to the respective battery terminals. Let me know if this helps.

      Delete
  13. Hi Connor,

    Thanks for getting back to me, I actually want to try power the transducer without connecting it to the fishfinder. I the lowrance power cord runs next to the data lines and meet at the lug which I posted earlier with the pinout. I though initially it did get power, but doesn't seem to be the case.

    Any suggestions without having to cut open the data lines to see where the power returns?

    Cheers

    ReplyDelete
    Replies
    1. Can you post model numbers so I can have a better idea? It sounds like you three components: the Fishfinder (the display, right?), the transducer in the water, and the cord which you posted that connects the fishfinder to the actual transducer. Is that right? And where does the Arduino fit into this setup?

      Delete
  14. Hi Connor,

    It is the Elite 4-Dsi.

    So the transducer and the power cord are attached to each other, but they only meet at the plug which connects to the display. Only when I turn on the display, the transducer starts "ticking". I want to connect the arduino directly to the transducer, without using the display or having it attached. I assumed in your initial post you had the same setup, the arduino directly connected to the transducer?

    Here is an image of what I mean, not the same model, but the same cable less a few data lines

    http://www.panbo.com/assets_c/2015/04/Digital_Yacht_Sonar_Server_Lowrance_Elite4_wiring_diagram_aPanbo-11193.html

    From your picture it seems your transducer could be powered directly, somehow I should be able to do the same


    ReplyDelete
    Replies
    1. Oh, I see what you're saying. I'm not really sure how to implement that without cutting the cable... I think the best way is the same way I have mine... in that I cut the cable that is directly attached to the transducer, and connected the appropriate wires (Batt+/-, NMEA+/-, and a Shield, although I don't have the shield connected to anything. Just the Batt and the NMEA).

      Delete
    2. I didn't want to cut as it would mean it is a permanent installation, but maybe it is a good time to tell the wife I need a new unit :)

      I will keep you posted, planning to get two Arduinos to send/read the data via RF.

      Cheers

      Delete
    3. Ok, feedback again. I cut my friends old humminbird and only discovered two wires and a bare wire. A quick google and I found this pinout, last picture on the first page:
      http://www.crappie.com/crappie/fishing-electronics-and-photography/113856-quick-humminbird/

      Seems no power cables run into the transducer?

      Delete
  15. This comment has been removed by the author.

    ReplyDelete
  16. Hi, very interesting tutorial but is this also applicable to Airmar B122 Smart™ Sensor? I was hoping to use this sensor to measure the depth of a river.

    I plan to connect the sensor to the arduino and monitor the measurements through the Arduino IDE in my laptop.

    ReplyDelete
    Replies
    1. Yes, that will work. Just make sure you have the NMEA-0183 version of the B122. The NMEA-0183 version is this:

      Furuno NMEA 0183—235DHT-LMSE——Airmar—44-082-1-01

      The NMEA-2000 version is this:

      Furuno NMEA 2000®—235-MSLF——Airmar—44-151-1-02

      However, I'm not too familiar with the wires on this one. If there are two NMEA output wires, you're in luck, because it'll work very well per above. If there's only one NMEA output wire, then it'll still work, but it'll be much more prone to errors and you'll have to follow the RS-232 section above.

      Also keep in mind that you'll only have these sentences:

      $SDDBT - Depth
      $SDDPT - Depth
      $YXMTW - Water Temperature

      Delete
    2. I see, I changed my mind, I'll also just use Airmar DST-800 since you already tested it.

      Did you try measuring the depth of a water? in your code, your output is the temperature, how can I make it output the measured depth in meters?

      Delete
    3. I only recommend getting the DST800 over the B122 if you want the paddle wheel as well. It'll probably be cheaper and less complicated, but in any case, they'll work the same with the same code. Just be sure to get the NMEA-0183 version of the DST-800:

      Manufacturer Part Numbers—NMEA 0183
      Furuno Plastic—235DST-PSE——Airmar—44-072-1-41
      Furuno Bronze—235DST-MSE——Airmar—44-072-1-51
      Garmin—010-11051-10——44-072-2-01

      And then you just have to change the void loop() section above to read this:

      void loop()
      if (Serial2.available() > 0 ) {
      if (nmeaDecoder.decode(Serial2.read())) {
      char* title = nmeaDecoder.term(0);
      if (strcmp(title,"SDDPT") == 0) {
      char dptSentence [22];
      byte csd;
      PString strd(dptSentence, sizeof(dptSentence));
      strd.print("$SDDPT,");
      strd.print(nmeaDecoder.term_decimal(1));
      strd.print(",");
      strd.print(!!TDO!!);
      strd.print("*");
      csd = checksum(dptSentence);
      if (csd < 0x10) strd.print('0');
      strd.print(csd, HEX);
      Serial.println(dptSentence);
      }
      }

      and replace

      !!TDO!!

      with your transducer offset in meters (if it's .5 meters from the waterline, put .5 but if it's .5 meters from the keel, put -.5). Also please note that this may not be formatted correctly since I just copied/pasted from my other post here:

      http://kingtidesailing.blogspot.com/2015/10/the-king-tide-sailing-arduino-nmea-0183.html

      Let me know how it works.

      Delete
    4. Do I really need to be in a boat to use this sensor? because i only want to mount the device on a pole and dip it underwater for it to measure the river depth. My problem is the power supply since there are no outlets outside, will ordinary 12v batteries work?

      http://ep.yimg.com/ca/I/theshorelinemarket_2424_694957635

      The reason why I plan to use Airmar DST800 is because it works underwater and also compatible with Arduino. Ultrasonic sensors like HC-SR04 or Maxbotix only works in air thus it wont read well in Water.

      Delete
  17. You absolutely don't need to use a boat. I stuck mine in a bucket of water when I was making this code, but it actually works fine out of water too. But yes you can just stick it on a pole and stick that in the water and it'll work fine, although you'll want to change the code to this:

    void loop()
    if (Serial2.available() > 0 ) {
    if (nmeaDecoder.decode(Serial2.read())) {
    char* title = nmeaDecoder.term(0);
    if (strcmp(title,"SDDBT") == 0) {
    Serial.println(nmeaDecoder.sentence());
    }
    }
    }

    That will output this sentence:

    DBT - Depth below transducer
    $--DBT,x.x,f,x.x,M,x.x,F*hh
    Which gives depth in:

    f = feet

    M = meters

    F = Fathoms

    again, I haven't debugged that code, so it might not work quite correctly. Try it out and let me know.

    As far as that 12V battery goes, I think it'll work okay, but it probably won't last very long. If it doesn't work, you'd probably want to attach it to your car battery and set it up until it does work so at least you know the DST and code works fine.

    ReplyDelete
    Replies
    1. Thanks a lot, i want to try it out but i don't have a sensor yet.

      Is this sensor the same as yours? http://www.imarineusa.com/AirmarDST800PV-S.aspx

      Ive been looking around the net and some DST800 have a different cable than yours. I mean your cable have 5 colored wires while some DST800 on the net have a connector plug. Like this one http://rcdn-1.fishpond.co.nz/0042/420/866/147901665/6.jpeg


      Delete
    2. Negative, that sensor you linked to is the NMEA-2000 version, which will not work. (the NMEA-2000 Manufacturer Part Number is 44-072-2-02, while the NMEA-0183 Manufacturer Part Number is 44-072-2-01.

      Also no worries about that plug... you just cut the cord and now you have the wires!

      Delete
    3. Oh I see, how about this one?
      http://www.p2marine.com/catalog/product_info.php?products_id=17612

      Just to be sure.

      Delete
    4. Yes, that appears to be the compatible NMEA-0183 version.

      Delete
  18. I didn't use any commercial level converter to hookup my Garmin Etrex Vista to the arduino pin 10 configured as serial RX input. I connected ground and the signal via a simple voltage :2 divider by cutting the 6-7 volts signal in half through 2 x 10 k-ohms resistors. Works neat and is pretty cheap !

    ReplyDelete
    Replies
    1. it outputs $ GPRMB,GPRMC, PGRME, PGRMZ, PGRMM all fine!

      Delete
  19. Lowrance MArk-4 :
    it took me 2 days to figure out how NMEA is arranged at this cheap fishfinder. Actually, at power & skimmer-side, the XDCR-cable is talking RS-422, in & out, which I couldn't directly bring to my Arduino without symmetrical voltage to asymatric level convertors I haven't got right now.
    But bringing the Mark-4 into advanced mode setting, it lets you configure the extra 4-pins speed/temp connector into a NMEA-0183 TX & RX port. I just managed to get it to talk @4800 baud to my Uno with my simple 2-resistor voltage-divider !

    ReplyDelete
    Replies

    1. Now all I need to find is a Lowrance NMEA-cable with a plug on one side which can be soldered to the Arduino ports, because I used some primitive wiring to hook it up! Looks like http://www.gpscity.com/lowrance-nmea-0183-adapter-cable.html is the right one but I think it's a bit expensive, plus, on the shop comments page a user reported thwo hidden diodes of which one was soldered backwards ?!
      Anyone getting a better alternative, like the connector alone ?

      Delete
    2. ... and yes, indeed, now we're talking RS-232 and I'm getting plenty of phrases: $ GPGLL, GPGSV, GPRMC, GPAPB, GPBWC, and even exactly what I was looking to get: $ SDDBT, SDMTW and SDDPT so I can finally have depth and water temperature logged in function of gps-readings...
      (it's good to know that this is the only way to output depth data, since on the Mark-4, the tracklog neither the waypoints provide enough info to be used as depth logs!)

      Delete
    3. Hi V-King, could you perhaps help me out regarding the symmetrical voltage to asymmetric level converters, required to link the lowrance transducer directly? My whole idea was to make my lowrance wireless, but after discovering that it is not that simple to get the transducer firing standalone, I gave up.

      Delete
    4. hi George,
      If you've got symmetrical voltages (so you're talking RS-422 or RS-485), I recommend using standard RS-... to TTL converters. Grounding the negative terminal of the transducer's TX- port running down to -15 volts) might shortcircuit its output chips, so it's not recommended. The right converter board for your wireless/zigb/arduino is pretty cheap, usually not more than a few bucks. Like this one: http://yourduino.com/sunshop2/index.php?l=product_detail&p=323 used in this example: https://arduino-info.wikispaces.com/SoftwareSerialRS485Example
      Good luck !

      Delete
    5. BTW: I received my Lowrance NMEA NDC-4 cable from http://www.nootica.fr/cable-de-liaison-nmea-0183-lowrance-pour-elite-mark.html
      I can confirm what I've heard about it: indeed, it's got a hidden diode shrinkwrapped on the yellow (TX>RX)-line at the loose-cable end (I didn't cut the connector apart, but I'm sure the 2nd one will be soldered there between GND and the RX<TX line!).
      But this should be no problem at all: the reason the diodes are 'soldered backwards' is simply because they are protecting the data-lines against reverse polarity. However, I remarked a slight voltage drop in the output of my new cable, and therefore I had to adapt my voltage divider to 8.2 Kohms over 12 Kohms because the NMEA-signal picked up by my Arduino was slightly under-voltaged to get a clean input. All is working fine, even without cutting the diodes away (as some webpages on this NDC-4 cable might suggest).
      The best solution is on the way: I've ordered a few RS-232 to TTL converters, so there will be no more need to experiment with voltage dividers as the Max-232 series chips are intelligent enough to cope with voltage levels! http://fr.aliexpress.com/item/RS232-To-TTL-Converter-Module-MAX3232CPE-MAX232-Transfer-Chip-Serial-Port-232-to-TTL-Communication-Module/1873008503.html?isOrigTitle=true

      Delete
    6. Hi V-King, I see your first post is exactly what I also got working some time ago. I was under the impression you had managed to connect the transducer directly to the Arduino. Have you explored that option?

      Delete
  20. Hi,
    it's can work with this transducer hummlinbird [url]http://www.navicom.fr/plaisance/sondeurs/accessoire-sondeurs/sondes/sonde-tableau-arriere-temp-tous-modeles-sauf-quadri-3d-si#panel-features[/url].
    i would like to connect to android with arduino !
    well done !
    thank

    ReplyDelete
    Replies
    1. Hi Philippe,
      Nice transducers, I think you could get them to talk to Arduino with the right coding.
      But I was lucky enough to buy a new Mark-4 at decathlon for the price of only the transducer:)
      Good luck & keep us informed. I'll try to find some code for you.

      Delete
    2. Re Finalement je viens de m'apercevoir que mon sondeur à une sortie nmea0183. Je vais donc m'orienter vers un multiplexeur wifi. Sais-tu si je dois utiliser le module RS-485, j'ai 3 fils ?

      Delete
    3. Its an international site. English pls :)

      Delete
    4. Philippe: Parfois, pour RS485 il y a un NMEA + , NMEA - , et une masse, mais vous ne devez pas connecter le sol à quoi que ce soit. Je suis désolé pour mon mauvais français, je suis en utilisant Google Translate.

      Delete
    5. hi Philippe,
      if your sounder has an NMEA-0183 output, and you have only 3 wires, the shield goes to ground (écran ou noir = masse); the yellow or blue is TX so goes to the Receive(RX) or Data-input of your module; orange or green is RX so goes to the Send(TX)or Data-output of your module.
      If you are sure it talks RS-422 (or RS485) then normally, there should be 4 or 5 wires (s'il n'y a pas 4 ou 5 fils, peu de chance que c'est du RS-422 ou 485)

      Delete
  21. This comment has been removed by the author.

    ReplyDelete
  22. Hi, what software do you recommend me to use to create a depth map, since dr. depth is not available anymore?

    ReplyDelete
    Replies
    1. I've thought about this before, and I think it would be really cool to make a plugin for OpenCPN to do this. However, I don't know enough coding to do that.

      But perhaps you can start here and this will give you somewhere to look?

      https://www.robotshop.com/letsmakerobots/sea-rendering?page=4

      Delete