4.37. Temperature Sensor API
foxBMS 2 supports various temperature sensors from different manufacturers as shown in Supported Temperature Sensors. This is achieved by drivers that implement the Temperature Sensor Interface (TSI).
This document describes how the TSI works.
An example how to implement a new TSI compatible driver is shown in How to Implement a New Temperature Sensor Driver.
4.37.1. Configuration
The TSI is configured through the bms.json
described in
Section 1.2. As of now it is only possible to configure one
temperature sensor implementation. The configuration is specified as in
Listing 4.20.
1 {
2 "slave-unit": {
3 "temperature-sensor": {
4 "manufacturer": "epcos",
5 "model": "b57251v5103j060",
6 "method": "polynomial"
7 }
8 }
9 }
The key manufacturer describes the manufacturer of the temperature sensor. The key model describes the exact part number of the temperature sensor. The key method describes the implementation that is used in order to calculate the temperature of the sensor. While this is dependent of the implementation typical values of this key are lookup-table and polynomial.
4.37.2. Usage
The TSI exposes the function TSI_GetTemperature
on its public API that
allows to calculate a temperature from a voltage measurement value.
Through the configuration file this function uses internally the specified
temperature sensor implementation.
4.37.3. Internal implementation
Internally this variable implementation is done by conditionally compiling and
linking the library that is specified through the configuration file.
The values of the specified keys are used to resolve the path to the
implementation. The TSI implementations are sorted in a directory structure
like manufacturer/model/manufacturer_model_method.c
.