This code will calculate thermo voltages from a given temperature for a defined thermocouple type or calculates a temperatures from a given voltage.
The code based on the coefficients of the NIST database
Supported thermocouple types are:
This example can be found under source/main.cpp
#include "TypeConversion.h"
#include <fmt/format.h>
int main()
{
using namespace UnitLiterals;
constexpr auto MILLI_VOLT = 4.096_mV; // 100 °C by TypeK
fmt::print("Input voltage: {0:.3f} mV\n", MILLI_VOLT());
// only one type given
constexpr auto TEMP = Thermocouple::calculate<TypeK>(MILLI_VOLT);
constexpr Temperature temp{TEMP};
fmt::print("Temperature: {0:.2f} °C\nVoltage: {1:.2f} mV\n", TEMP, Thermocouple::calculate<TypeK>(temp));
constexpr auto TEMPERATURES = Thermocouple::calculate<TypeK, TypeT, TypeB, TypeE, TypeJ, TypeN, TypeR, TypeS>(MILLI_VOLT);
std::apply([](const auto&... val) { ((fmt::print("{1} Temperature: {0:.2f} °C\n", val.getValue(), val.getName())), ...); }, TEMPERATURES);
return 0;
}