wellenvogel / esp32-nmea2000

nmea2000 gateway with ESP32
GNU General Public License v2.0
65 stars 30 forks source link

XDR Mappings PGN-127506 (DC Detailed Status) #65

Open oxbown opened 10 months ago

oxbown commented 10 months ago

I´m using an esp8266 to send the battery information over TCP to the esp32-nmea2K. Messages are in nmea0183 format with XDR sentences For example: $JCXDR,U,12.0,V,I,2.5,A,C,25.0,C,BAT1*hh

I can read voltage, amperage, and battery temperature on esp32 using XDR mappings with that sentence.

But I have more information about the battery, in particular, 2 more values that are interesting State of Charge (SoC) - The remaining percentage of charge (%) Time Till Zero Charge (TTZ) - Time to discharge the battery (seconds)

These two values can be included in the XDR sentence: $JCXDR,U,12.0,V,I,2.5,A,C,25.0,C,SOC,50.0,,TTZ,3520,,BAT1*hh

The n2k PNG that has that information is 127506. That sentence is not present in the project, but fortunately, the nmea2000 library supports it! https://github.com/ttlappalainen/NMEA2000/blob/5e4fb0a49f4832f134878054da1ce8e4d700ee55/src/N2kMessages.h#L1981

The question is. Can be integrated? is there any challenge?

wellenvogel commented 10 months ago

Most probably it can be integrated. Would require some idea about the XDR unit/type (any standard for that?) and the implementation of the appropriate definitions for the XDR mappings and the implementation in the converter. Do you already use the n2k lib on the esp8266? If yes you could potentially directly send the data in n2k format using the seasmart format via TCP. This would allow you to implement things independently... Only drawback: No value display on the converter.

oxbown commented 10 months ago

I did not find any standard for that XDR, the only thing that I found is XDR can be expanded or adapted by the manufacturer. Format: $--XDR,a,x.x,b,.....,c *hh

-- : is the Talkder id a : is the Transducer Type x.x : is the Value of the measure b : is the Unit of the measure c : is the Name of the transducer hh : is the checksum

There is a list of standard Transducer Types: A - Angular displacement // C - Temperature // D - Depth // F - Frequency // H - Humidity // N - Force // P - Pressure // R - Flow // B - Absolute humidity // G - Generic // I - Current // L - Salinity // S - Switch, valve // T - Tachometer // U - Voltage // V - Volume

And a list of standard Units A - Amperes // B - Bars | Binary // C - Celsius // D - Degrees // H - Hertz // I - liters/second // K - Kelvin or Density, kg/m3 kilogram per cubic meter // M - Meters or Cubic Meters (m3) // N - Newton // P - percent of full range or Pascal // R - RPM // S - Parts per thousand // V - Volts

Transducer types can be customized (like: "MAGX", "SOC", "TTZ") Units can also be custom o directly not units.

I´m using esp8266 with micropython so I can not use the library. The idea is to make sensors or devices with a few lines of code.

wellenvogel commented 10 months ago

Yes I know about the types/units you mentioned. But none of them really fit's. So we would end up with some proprietary mappings. Doable - but not really great. And btw: Transducer types are one character, the names are free...

Basically to support any kind of user defined mapping we would need to extend the mapping definitions to also be able to set the transducer type, the unit and the PGN+field you would like to map to.

oxbown commented 10 months ago

Here is a reference in another project https://github.com/maritime-labs/calypso-anemometer/issues/21#issuecomment-1444396266 for battery level. Uses L for "level" and R for "ratio" unit..

On the other hand, could be G for Generic and ", ," for not specified unit. To adapt the value to the desired PNG unit, the solution could be a scaling factor like Openplotter i2c app. image