2020-01-25, 01:12 PM
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:
and MDAwater.js looks like this:
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
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