Introduction: How to Use NMEA-0183 With Raspberry Pi
NMEA-0183 Is an electrical standard to connect GPS, SONAR, sensors, auto pilot units etc. in ships and boats. In difference to the newer NMEA 2000 standard (based on CAN) the NMEA 0183 is based on EIA RS422 (some older and/or simple systems use RS-232, or a single wire).
I want to show you how to connect a Raspberry Pi 3B to any NMEA-0183 device with differential output. Although the standard calls for isolated inputs and outputs its useful to use a RS422 / RS485 HAT with isolated interface.
Step 1: Tools and Software
Materials:
Raspberry Pi
a serial NMEA0183 device
Software:
Raspbian Stretch
Step 2: Connection to NMEA 0183
In the picture above you can see a typical NMEA device with differential output. The terminals are NMEA OUT+ and NMEA OUT- or TX+ or TX-. The NMEA IN+ and NMEA IN- wires are optional.
if you have a single transmit wire from your device (most likely labeled
TX or NMEA OUT or something like that), then your device uses the RS-232 protocol. In this case you will need a simple RS232 converter.
Step 3: DIP Switch Settings
Step 4: Free Up the Serial Line and Enable UART of the Raspberry Pi
The easiest way is to use the raspi-config tool to switch the UART to the GPIO14/15 pins.
take a fresh Raspbian image
sudo raspi-config
goto '5 Interfacing Options'
goto 'P6 Serial'
'Would you like a login shell to be accessible over serial?' --> NO
'Would you like the serial port hardware to be enabled?' --> YES
Finish raspi-config
reboot the Raspberry Pi
Now you can access the UART via /dev/serial0
Step 5: Firmware
You can find a lot of different NMEA-0183 software Python stacks for Raspberry Pi A very simple solution is the NMEA library by Nick Sweeting:
https://github.com/nsweeting/NMEA0183
Please note: pyserial is required for serial connections:
Step 6: Test Run
The Python program will decode incoming NMEA protocols. If you have no NMEA device at home, you can also use a Simulator on your PC and a simple USB to RS485 adaptor instead of a real device.
6 Comments
Question 6 months ago
Hi! Thanks for the infos, really interesting writing, but I probably have a rs232 device (only one wind sensor for apparent wind angle and speed). Could you recommend me a converter for this situation? I've tried to figure it out myself, but there are too many similar items. It would be very helpful if you could give me a bit more detailed guide for this situation:
"if you have a single transmit wire from your device (most likely labeled
TX or NMEA OUT or something like that), then your device uses the RS-232 protocol. In this case you will need a simple RS232 converter."
In the mast, there is only one cable coming down from the sensor with 3 wires inside.
Thanks!
Question 1 year ago on Introduction
Can i use this as well as the AIS receiver HAT? they don't look stackable?
Reply 1 year ago
I don't know the AIS receiver HAT, but our HAT is available with standard headers and stacked headers...
Question 3 years ago on Introduction
How do you add more than one device. Can you just piggy back them into the same connection on the hat, seeing as its a network and each item Tx's its own data packet.
Answer 1 year ago
nmea 0183 is a network so you just need to connect to that network and you will pick up all of the devices connected to that network
Question 3 years ago on Step 6
I get an error module is not callable ?