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
Waveshare USB-CAN-A → SignalK bridge (Python)
#1
I wrote a small Python bridge to get NMEA 2000 data into SignalK using a Waveshare USB-CAN-A adapter.

The problem: SignalK's N2K provider (canbus-canboatjs) only works with SocketCAN interfaces (PiCAN, MCP2515 hats) or serial protocol gateways (Actisense NGT-1, YDWG-02, iKonvert, MiniPlex). The Waveshare USB-CAN-A uses a proprietary 15-byte serial protocol (0xAA/0x55 markers at 2M baud) that doesn't match any of these formats. I checked on GitHub — the SignalK team has indicated supporting this adapter isn't planned, due to low demand.

What the bridge does: reads frames from the Waveshare via its CH340 serial port, parses the 15-byte protocol, and writes standard CAN frames onto vcan0. SignalK's existing canboatjs provider consumes them as if they came from a physical CAN interface — no changes to SignalK needed.

Repo: https://github.com/spidgrou/nmea2000-can-bridge

Hardware setup and SignalK config are in the README. Also includes an offline parser test for validation without hardware.

Current status: running 24/7 on my boat for about 9 days (as a systemd service). Stats so far:
  • ~13.6M valid frames, zero invalid/dropped
  • ~17.5 frames/s average
  • No memory leak (stable at ~17 MB RSS)
  • Zero errors

If anyone else has a Waveshare USB-CAN-A lying around and wants to give it a try, I'd be glad to hear how it works on different setups. 

PRs welcome.
Reply
#2
Thank you so much for putting this together and sharing it with the community. Finding a way to bypass expensive proprietary marine gateways using an eighteen dollar Waveshare adapter is a massive win for DIY boaters, saving everyone hundreds of dollars. Your work on this bridge is incredibly impressive, and the fact that it has processed over thirteen million frames with zero drops over nine days is phenomenal.

For anyone looking at this as an alternative to a standard PiCAN-M HAT, it is helpful to note a few physical differences. While the PiCAN-M can power a Raspberry Pi directly from the network bus and includes an NMEA 0183 port, your solution strips away that unnecessary complexity for those who only need clean, reliable NMEA 2000 data. It is worth mentioning to future builders that the base USB-CAN-A lacks galvanic isolation, so anyone looking for industrial-grade protection on a complex electrical system might want to consider the USB-CAN-B variant with your script, but for standard setups, your approach is perfect.

The absolute best part about your method is the sheer cost savings when wiring it up. Instead of buying expensive, specialized marine connectors, a user can just take a standard, inexpensive NMEA 2000 drop cable, cut one end off, and wire the bare cables directly into the green terminal block on the Waveshare. Matching the white wire to CAN High and the blue wire to CAN Low creates a complete hardware interface for under twenty dollars. That is an unbelievable eighty percent reduction in hardware costs compared to standard commercial gateways.Since your initial performance data looks so rock-solid, I would love to hear your thoughts on how the hardware and software handle long-term marine conditions. Have you noticed any impact on data transmission or physical connection stability from engine vibrations or moisture over time?

Also, if the network gets flooded with high-frequency data like fast heading sensors or engine diagnostics, does the proprietary serial framing or the Python translation layer experience any latency, or does it keep up effortlessly?Thank you again for dedicating your time to solving this problem and making marine data accessibility so much more affordable for the rest of us.
Skipper Don

AtMyBoat.com
skipperdon@atmyboat.com

I watched enough Gilligan’s Island as a kid to explain this
 
Reply
#3
Don,
Thanks for the feedback. And yeah, you're bang on about galvanic isolation — on a boat with all sorts of electrical noise floating around, it's not optional.

The USB-CAN-B would be the cleanest solution but at ~$50 it adds up. 
I went with this ADUM3160 USB isolator in series instead and it's been solid so far:
https://a.aliexpress.com/_mK0FBfD

I live on the boat full-time so this thing is getting real-world tested 24/7 — engine vibes, humidity, the works. I'll post an update once it's had some more time under its belt. More stats coming shortly.

-----
Max
www.youtube.com/@Y2KSailing
www.y2ksblog.com
Reply
#4
Max do you have a link to the USB-CAN-A adapter that you used?
Skipper Don

AtMyBoat.com
skipperdon@atmyboat.com

I watched enough Gilligan’s Island as a kid to explain this
 
Reply
#5
Don,
I bought it from AliExpress, here the link: https://s.click.aliexpress.com/e/_mPWSzKn

In Australia, where I'm now is the cheapest supplier, I'm sure you can buy in other places.

Ciao

-----
Max
www.youtube.com/@Y2KSailing
www.y2ksblog.com
Reply
#6
Hey Max,
Thanks again — seriously, you’ve helped me out a ton and I really appreciate it.

I’m looking at alternatives to the PiCAN‑M HAT right now, so I just want to make sure I fully understand your setup. Did you take a standard NMEA 2000 drop cable and plug it directly into that adapter you bought from AliExpress, and then run that into your system?

Just confirming the exact connection path you used.

Ciao,
Don
Skipper Don

AtMyBoat.com
skipperdon@atmyboat.com

I watched enough Gilligan’s Island as a kid to explain this
 
Reply
#7
Don wrote:
>> I’m looking at alternatives to the PiCAN‑M HAT right now, so I just want to make sure I fully understand your setup. Did you take a standard NMEA 2000 drop cable and plug it directly into that adapter you bought from AliExpress, and then run that into your system?

Yes Don, I cut a spur cable and used only the white & blue wires. That's all.
Enjoy.
Reply
#8
Hello I have joined the forum as I have spent many hours trying to get your signalk bridge to work. 
I have raspberry pi running open plotter with a waveshare USB-CAN-A
I am so grateful and full of admiration for you being able to write such software and to share it.
I can see N2K in signal k dashboard, (signalk reports connected) connections activity appearing to be sending data. Have I understood correctly that I should be able to use the resulting signal k output in opencpn? as I unable to get it to work.
If however I change the connection in open cpn from signalk to socketcan vcan0 I get a gps position. I have teed into an nmea 2000 backbone using a Garmin gps antenna, just at home in an effort to learn before connecting to my 2000 network onboard my ex-commercial fishing boat. (I have retired and use it for pleasure)
My test system has nothing else connected, just the gps, power and the waveshare usb.
Reply
#9
Thank you so much for this guide — it genuinely changed what was possible for my project. Truly wonderful work, and I mean that.

I've been building d3kOS, a marine dashboard system for my boat running on Raspberry Pi. The system needs to read NMEA 2000 data off the boat's CAN bus, and I had a real problem: different Pis in the fleet use different hardware. My lab Pi runs a PiCAN-M HAT, my Pi 5 uses a USB-CAN-A adapter (1a86:7523), and every time I cloned an SD image to a new Pi, the CAN setup was wrong for that machine and had to be fixed by hand.

Your article gave me the foundation I needed to finally solve it properly. I built an automatic detection routine (hardware-probe.sh) that runs at boot and every 15 minutes. It checks for the PiCAN-M HAT via the mcp251x driver and probes USB for the 1a86:7523 device ID. Depending on what it finds, it enables or disables the correct Signal K provider (can0 for PiCAN-M, usbcan bridge for USB-CAN-A) and brings the right interface up — automatically, with no manual intervention after cloning.

Both paths are now verified on real hardware:
- Lab Pi (PiCAN-M): pican_m=present, SK can0 provider ON, can0 UP
- Pi 5 (USB-CAN-A): usbcan=present, SK usbcan provider ON, can0-check timer OFF

It shipped as part of my v0.9.9.5.1 release and went out to three Pis via OTA last week. It just works.

None of that would have happened without thiing your knowledge so clearly — you saved me a tremendous amount of time and taught me so much, eh.
Skipper Don

AtMyBoat.com
skipperdon@atmyboat.com

I watched enough Gilligan’s Island as a kid to explain this
 
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)