Cruisers Forum
 


Reply
 
Thread Tools Search this Thread Rate Thread Display Modes
Old 03-11-2019, 05:17   #1
Registered User

Join Date: Nov 2019
Posts: 20
Converting and sending data to opencpn using a script or program in Unix?

Hi all

I'm recieving data from my weather station (wind, direction, temp etc) using a 433 mHz dongle that I would like to send to OpenCPN. I have been researching quite a bit but haven't been able to find a solution yet. The problem is basically that I recieve the data on the same computer as I'm running OpenCPN on using a script... but how do I take that data, convert it into NMEA and send it to an artificial port?

Has anyone done something similar, and how did you solve it? Is there a way to run scripts in OpenCPN?

Kind Regards,
Peter
peter- is offline   Reply With Quote
Old 03-11-2019, 05:54   #2
Registered User

Join Date: Aug 2009
Location: oriental
Boat: crowther trimaran 33
Posts: 4,414
Re: Converting and sending data to opencpn using a script or program in Unix?

You can connect to opencpn using a socket to send the mwv nmea wind sentence.
seandepagnier is offline   Reply With Quote
Old 03-11-2019, 06:07   #3
Registered User
 
transmitterdan's Avatar

Join Date: Oct 2011
Boat: Valiant 42
Posts: 6,008
Re: Converting and sending data to opencpn using a script or program in Unix?

Yes, you can do it if you convert your data to NMEA 0183 format and send it over the network. See github.com/transmitterdan/VDRplayer for an example of how to send already properly formatted NMEA data from a text file to OpenCPN via a network connection. You can modify that program to convert your weather station data and send it to OpenCPN or any other similar chart plotting device. They almost all accept NMEA data.

UDP is the preferred comm method but TCP also works.
transmitterdan is offline   Reply With Quote
Old 03-11-2019, 06:43   #4
Registered User

Join Date: Nov 2019
Posts: 20
Re: Converting and sending data to opencpn using a script or program in Unix?

Thanks - that could solve my problem but:

1. I dont have a network yet so I would like to do it without hence why I was referring to the artificial serial port as a best guess. Does anything exist like VDRplayer but sending to a serial port rather than a network?

2. Once I get a network installed on my Raspberry Pi Model 3, the Pi will become a hotspot such that I can e.g. connect my tablet with OpenCPN and get all the data there but in a way I guess it won't solve the network problem for the weather data however as all my serial connections goes into my Raspberry Pi which on the same time is my router so I guess I can't really send anything over the network at that point either as I'll just be sending stuff to myself?

Kind Regards,
Peter
peter- is offline   Reply With Quote
Old 03-11-2019, 07:09   #5
Registered User

Join Date: Nov 2019
Posts: 20
Re: Converting and sending data to opencpn using a script or program in Unix?

So I found this:
https://en.wikipedia.org/wiki/Pseudoterminal

I'll try to dig around with that for a while, what I need is a virtual serial port.

Alternatively, I'll try to setup a network in my boat and use the VDRplayer, but that would not only require a router but also an additional Raspberry Pi or computer which is starting to potentially overcomplicate the hardware part along with unnessesary electricity consumption.

Kind Regards,
Peter
peter- is offline   Reply With Quote
Old 03-11-2019, 08:07   #6
Registered User

Join Date: Nov 2012
Location: Orust Sweden
Boat: Najad 34
Posts: 4,119
Re: Converting and sending data to opencpn using a script or program in Unix?

Peter.
If you've everything in the same machine your don't need a external network. Use UDP address LocalHost or 127.0.0.1 and a suitable port. 10110 is common for NMEA0183.
Hakan is offline   Reply With Quote
Old 03-11-2019, 08:08   #7
cruiser

Join Date: Nov 2007
Location: Probably in an anchorage or a boatyard..
Boat: Ebbtide 33' steel cutter
Posts: 5,030
Re: Converting and sending data to opencpn using a script or program in Unix?

Quote:
Originally Posted by peter- View Post
Thanks - that could solve my problem but:

1. I dont have a network yet so I would like to do it without hence why I was referring to the artificial serial port as a best guess. Does anything exist like VDRplayer but sending to a serial port rather than a network?
What operating system are you using? If it's linux then installing signalk should make it possible.
Quote:
2. Once I get a network installed on my Raspberry Pi Model 3, the Pi will become a hotspot such that I can e.g. connect my tablet with OpenCPN and get all the data there but in a way I guess it won't solve the network problem for the weather data however as all my serial connections goes into my Raspberry Pi which on the same time is my router so I guess I can't really send anything over the network at that point either as I'll just be sending stuff to myself?
Pi should be fine, might need to do a little code to turn the data into signalk or nmea but someone could write that easy enough if you struggle.
conachair is offline   Reply With Quote
Old 03-11-2019, 08:08   #8
Registered User

Join Date: Feb 2015
Location: Cambridge, UK
Posts: 16
Send a message via Skype™ to povl
Re: Converting and sending data to opencpn using a script or program in Unix?

You could use a program like Kplex (http://www.stripydog.com/kplex/), which can redirect NMEA data between network ports, files, and serial devices.

I sometimes work on a ship that only transmits relative wind data - and I want to view true wind directions and strengths in OpenCPN. I have written a C program that reads the relative wind data, gyro heading and COG/SOG, and computes true (ground) wind. OpenCPN reads all the nav data from the network, and sends these three sentences to Kplex (via TCP), where they are redirected to a FIFO file. My program reads from the file, writes to a different file, which then is read by Kplex and returned to OpenCPN, where the true wind is displayed in the dashboard. Slightly circuitous, but works perfectly once I figured out how to set it up!

Summary of my settings (for anyone interested):
In OpenCPN:
  • an incoming TCP connection to get nav data onto my computer
  • a bidirectional TCP connection to localhost on port 10110, accepts all incoming sentences, transmits only HDT,RMC,MWV
My .kplex.conf file:
Code:
[file]
filename=/path/to/temp_nmea_in
direction=out
persist=yes
ofilter=+**HDT:+**RMC:+**MWV:-all
[file]
filename=/path/to/temp_nmea_out
direction=in
persist=yes
[tcp]
mode=server
port=10110
direction=both
ofilter=+**MWD:+**MWV:-all
The two files temp_nmea_in and temp_nmea_out were created with the unix "mkfifo" command.
povl is offline   Reply With Quote
Old 03-11-2019, 08:17   #9
cruiser

Join Date: Nov 2007
Location: Probably in an anchorage or a boatyard..
Boat: Ebbtide 33' steel cutter
Posts: 5,030
Re: Converting and sending data to opencpn using a script or program in Unix?

Quote:
Originally Posted by povl View Post
You could use a program like Kplex (Kplex: An NMEA-0183 Multiplexer), which can redirect NMEA data between network ports, files, and serial devices.
Not so much use if the data isn't nmea0183 though, as in this case.

Node-red could have it up and running in a few minutes

Peter - do you have a sample of the data coming in from the sensor?
conachair is offline   Reply With Quote
Old 03-11-2019, 08:27   #10
Registered User

Join Date: Feb 2015
Location: Cambridge, UK
Posts: 16
Send a message via Skype™ to povl
Re: Converting and sending data to opencpn using a script or program in Unix?

Quote:
Originally Posted by conachair View Post
Not so much use if the data isn't nmea0183 though, as in this case.
So, write a script that converts the data to a MWV sentence and get this to write to a FIFO; kplex can read those data and send them to OpenCPN via TCP (or UDP, if you prefer). Or you can do it in Node-red. There is more than one way to skin a cat...
povl is offline   Reply With Quote
Old 03-11-2019, 08:34   #11
cruiser

Join Date: Nov 2007
Location: Probably in an anchorage or a boatyard..
Boat: Ebbtide 33' steel cutter
Posts: 5,030
Re: Converting and sending data to opencpn using a script or program in Unix?

Quote:
Originally Posted by povl View Post
There is more than one way to skin a cat...
Simplest prob in signalk, node-red in there already - then do what you want with it, convert to nmea/2k, save to database, send to web, save to a file..
conachair is offline   Reply With Quote
Old 03-11-2019, 09:19   #12
Registered User

Join Date: Nov 2019
Posts: 20
Re: Converting and sending data to opencpn using a script or program in Unix?

My data looks like this:

Code:
Temperature: 6.0 C
Wind string: E
Wind Degrees: 90
Wind ave speed: 11.02
Wind gust: 14.69
I'm running as Raspberry Pi with Raspbian Unix. I was looking at something called pseudoterminals but I'll try as mentioned.

Does anyone have a good list over NMEA sentences so I can send the correct syntax? I prefer to convert myself so I have proper control. Anyone know if you can send both wind average and wind gust info over NMEA? I'm using a weather station because it is a very cheap solution compared to other solutions and it is wireless so I didn't have to pull any cables and don't mind climbing the mast once a year to change batteries...

Kind Regards,
Peter
peter- is offline   Reply With Quote
Old 03-11-2019, 09:32   #13
cruiser

Join Date: Nov 2007
Location: Probably in an anchorage or a boatyard..
Boat: Ebbtide 33' steel cutter
Posts: 5,030
Re: Converting and sending data to opencpn using a script or program in Unix?

Quote:
Originally Posted by peter- View Post
My data looks like this:

Code:
Temperature: 6.0 C
Wind string: E
Wind Degrees: 90
Wind ave speed: 11.02
Wind gust: 14.69
I'm running as Raspberry Pi with Raspbian Unix. I was looking at something called pseudoterminals but I'll try as mentioned.

Does anyone have a good list over NMEA sentences so I can send the correct syntax? Anyone know if you can send both wind average and wind gust info over NMEA?
If you are on a Pi try installing the not quite yet released openplotter V2 -
OpenPlotter 2 roadmap

I did it couple days ago, very easy and looks great so far, just a few bits missing.
That will install node red when installing the wonderful signalk. So you should be able to set up a serial port as a node-red input , then turn the data into nmea.
conachair is offline   Reply With Quote
Old 03-11-2019, 10:50   #14
Registered User
 
transmitterdan's Avatar

Join Date: Oct 2011
Boat: Valiant 42
Posts: 6,008
Converting and sending data to opencpn using a script or program in Unix?

If you are only using one computer then UDP is still the easiest method. It works on all platforms supported by O. You don’t need any serial port. Just send your data messages to localhost or 127.0.0.1. All computers have this capability.
transmitterdan is offline   Reply With Quote
Old 03-11-2019, 10:59   #15
Registered User

Join Date: Nov 2019
Posts: 20
Re: Converting and sending data to opencpn using a script or program in Unix?

So you to make sure that I understand it correctly:

Step 1: Have a script that pulls the data from my weather station 433MHz and saves it to a file.
Step 2: Use node-red to pickup the file and inject it into signalk
Step 3: Convert it to NMEA in Signalk and save to another file
Step 4: Use node-red to inject into OpenCPN.


I think the following would be easier to:
Step 1: Read weather station data, convert into NMEA (such as $GPMWV,318.00,R,14.80,N,A*1D) and save in file.
Step 2: Injection file into OpenCPN using node-red and http:/ / localhost : 1880]

Am I understanding this correctly?


Kind Regards,
Peter
peter- is offline   Reply With Quote
Reply

Tags
enc, opencpn

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Sending Data To Polar Navy awwbaker OpenCPN 3 25-11-2017 03:28
4g Radar not sending data str-alorman OpenCPN 5 09-10-2017 05:35
Problems sending autopilot data to PolarCOM RhythmDoctor OpenCPN 4 22-01-2014 19:22
Sending wind data from B&G Hydra 2000 to Raymarine Autohelm Bucaniere Marine Electronics 2 19-09-2013 08:49
Sending Data from GPS to two Virtual Ports in Ubuntu 12.04 Sail323 OpenCPN 1 19-07-2012 12:59

Advertise Here


All times are GMT -7. The time now is 17:17.


Google+
Powered by vBulletin® Version 3.8.8 Beta 1
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Social Knowledge Networks
Powered by vBulletin® Version 3.8.8 Beta 1
Copyright ©2000 - 2024, vBulletin Solutions, Inc.

ShowCase vBulletin Plugins by Drive Thru Online, Inc.