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
New user, some questions...
#2
Hello again

I made 2 files, MDAair.js and MDAwater.js, placed in /usr/lib/node_modules/signalk-server/node_modules/@signalk/signalk-to-nmea0183/sentences folder

the MDAair.js is sending the environment.outside.temperature and the MDAwater.js is sending the environment.water.temperature

MDAair.js file I made look like this:

Code:
// NMEA0183 Encoder $IIMDA,29.95,I,1.01,B,19.8,C,17.0,C,68.0,,16.7,C,,,,,,,,*3F
const nmea = require('../nmea.js')
module.exports = function (app) {
 return {
   title: 'MDA - Outside Air Temperature - by sebba',
   keys: ['environment.outside.temperature'],
   f: function (temperature) {
     var celcius = (temperature) - 273.15
     return nmea.toSentence([
       '$IIMDA',
       ,
       'I',
       ,
       'B',
       celcius.toFixed(2),
       'C'
     ])
   }
 }
}

and MDAwater.js looks like this:
Code:
// NMEA0183 Encoder $IIMDA,29.95,I,1.01,B,19.8,C,17.0,C,68.0,,16.7,C,,,,,,,,*3F
const nmea = require('../nmea.js')
module.exports = function (app) {
 return {
   title: 'MDA - Water Temperature - by sebba',
   keys: ['environment.water.temperature'],
   f: function (temperature) {
     var celcius = (temperature) - 273.15
     return nmea.toSentence([
       '$IIMDA',
       ,
       'I',
       ,
       'B',
       ,
       'C',
       celcius.toFixed(2),
       'C'
     ])
   }
 }
}

It seems to be working... but I'm not still sure if this is the best way to do it.
I had to have 2 different files because I don't know how to add different temperature sources in the same sentence
I also so similar approach for relative/true wind sentences so I hope is OK.
I'll try to add the barometric data also.

Can I have some feedback, to know if this is the right way to work with this?

Thanks,
Seb
- SV Haimana
Reply


Messages In This Thread
New user, some questions... - by sebba - 2020-01-24, 01:57 PM
RE: New user, some questions... - by sebba - 2020-01-25, 01:12 PM
RE: New user, some questions... - by PaddyB - 2020-01-25, 02:32 PM
RE: New user, some questions... - by sebba - 2020-01-25, 03:41 PM
RE: New user, some questions... - by PaddyB - 2020-01-25, 04:41 PM
RE: New user, some questions... - by Tigress - 2020-08-15, 01:04 AM
RE: New user, some questions... - by PaddyB - 2020-08-15, 12:32 PM
RE: New user, some questions... - by sebba - 2020-01-25, 05:49 PM
RE: New user, some questions... - by PaddyB - 2020-01-25, 06:34 PM
RE: New user, some questions... - by sebba - 2020-01-25, 07:13 PM
RE: New user, some questions... - by PaddyB - 2020-01-25, 07:58 PM
RE: New user, some questions... - by sebba - 2020-01-25, 09:48 PM
RE: New user, some questions... - by PaddyB - 2020-01-26, 12:35 PM
RE: New user, some questions... - by sebba - 2020-01-26, 01:04 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)