Measuring boat engine temperature wih NMEA 2000

This is a continuation of my previous project, this is just ising NMEA2000 to show the measurements on our chart plotter, instead of displaying it via webpage on Wi-Fi.
It started when i saw that Arduino had made a CAN bus shield, for the Arduino MKR serie.
The Arduino MRK 1010 Wi-Fi, sounds perfekt with the Can bus Shield for this purpose, and even a few other project for the boat with NMEA2000 connectivity, but more on this in a later blog.




I have used a Arduino MKR Wi-Fi 1010 and the MKR CAN shield on a NMEA2000 network, using ttlappalainen's NMEA2000 library and a Raymarine Axiom 7 as MFD.







I have 3 ds18b20 (one-wire Temperatur sensor) connected on a one-wire bus, then senses temperatures on my old VP 2003t engine.




I can highly recommend ttlappalainen's excellent document "Connecting_hardware_to_NMEA2000.pdf", specially the troubleshooting section, it saved me for a lot of frustrations, and hours ;)




For testting purpose, the en alarm is set to 26 C, in case you wondered..;)







Code: Blogger is not really good at presenting code, so I have just included the fist part to get anyone started, but i am happy to share my code i you write to me.

---
// Send DIY temp readings to NMEA 2000 bus.
// Based on the shoulders of my heros, Including but not limited to:
// DallasTemperature: Miles Burton https://github.com/milesburton
// NMEA2000: Timo Lappalainen https://github.com/ttlappalainen
// OneWire: Paul Stoffregen https://github.com/PaulStoffregen

#include <Arduino.h>
#define USE_N2K_CAN 1
#define N2k_SPI_CS_PIN 3
#define N2k_CAN_INT_PIN 7
#define USE_MCP_CAN_CLOCK_SET 16
#include <NMEA2000_CAN.h>  
#include <N2kMessages.h>
#include <OneWire.h>
#include <DallasTemperature.h>
---




The alarm is generated by: (note the true/false as the last argument. Not pretty, but it get the job done)
---
       if (coolingtemp > OilAlarmTemp || coolingtemp > CoolingAlarmTemp ) {
      SetN2kEngineDynamicParam(N2kMsg, 0, N2kDoubleNA, ReadoilTemp(), ReadEngineTemp(), N2kDoubleNA, N2kDoubleNA, N2kDoubleNA, N2kInt8NA,N2kInt8NA, N2kInt8NA, N2kInt8NA, false, true);
   } else {
      SetN2kEngineDynamicParam(N2kMsg, 0, N2kDoubleNA, ReadoilTemp(), ReadEngineTemp(), N2kDoubleNA, N2kDoubleNA, N2kDoubleNA, N2kInt8NA,N2kInt8NA, N2kInt8NA, N2kInt8NA, false, false);
   }
---


Comments