Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions components/thermistor/example/main/thermistor_example.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,18 +63,19 @@ extern "C" void app_main(void) {
auto celsius = thermistor.get_celsius();
// use kelvin for calculating error so we don't have to worry about division by zero
auto error = std::abs(kelvin - actual_kelvin);
logger.info("calculated temp: {:.2f} C, actual: {:.2f} C; error: {:.2f} C", celsius,
actual_celsius, error);
logger.info("measured voltage: {:.2f} mV, calculated resistance: {:.2f} Ohm, calculated "
"temp: {:.2f} C, actual: {:.2f} C; error: {:.2f} C",
get_voltage(), thermistor.get_resistance(), celsius, actual_celsius, error);
}
//! [thermistor validation example]
}

//! [thermistor adc example]

// create a continuous ADC which will sample and filter the thermistor
// voltage on ADC1 channel 1
// voltage on ADC1 channel 7
std::vector<espp::AdcConfig> channels{
{.unit = ADC_UNIT_1, .channel = ADC_CHANNEL_0, .attenuation = ADC_ATTEN_DB_11}};
{.unit = ADC_UNIT_1, .channel = ADC_CHANNEL_7, .attenuation = ADC_ATTEN_DB_11}};
// this initailizes the DMA and filter task for the continuous adc
espp::ContinuousAdc adc(
{.sample_rate_hz = 20 * 1000,
Expand All @@ -94,9 +95,14 @@ extern "C" void app_main(void) {
};

// create a thermistor object (based on the datasheet from
// https://product.tdk.com/system/files/dam/doc/product/sensor/ntc/chip-ntc-thermistor/data_sheet/50/db/ntc/ntc_smd_standard_series_0402.pdf
// https://product.tdk.com/system/files/dam/doc/product/sensor/ntc/chip-ntc-thermistor/catalog/tpd_commercial_ntc-thermistor_ntcg_en.pdf
// From the table (page 7):
// clang-format off
// Part Number. | R25(Ω) | Tolerance | B25/50(Κ) | B25/75(Κ) | B25/85(Κ) | B25/100(K) | Current (mA) | Operating Temp Range
// NTCG103JF103FT1 | 10,000 | +/–1% | 3380 | 3422 | 3435 | 3453 +/–1% | 0.31 | –40 to 152
// clang-format on
espp::Thermistor thermistor({.divider_config = espp::Thermistor::ResistorDividerConfig::UPPER,
.beta = 3940, // 25/50C beta since we're not planning on hot temps
.beta = 3380,
.nominal_resistance_ohms = 10000,
.fixed_resistance_ohms = 10000,
.supply_mv = 3300,
Expand Down
23 changes: 17 additions & 6 deletions components/thermistor/include/thermistor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,11 @@ class Thermistor {
}
}

/// @brief Get the temperature in Kelvin
/// @return Temperature in Kelvin
/// @brief Get resistance of the thermistor
/// @return Resistance of the thermistor in ohms
/// @details
/// Reads the voltage from the thermistor and converts it to temperature
/// using the Steinhart-Hart equation.
float get_kelvin() {
/// Reads the voltage from the thermistor and converts it to resistance
float get_resistance() {
if (read_mv_ == nullptr) {
logger_.error("read_mv_ is null");
return 0.0f;
Expand All @@ -88,10 +87,22 @@ class Thermistor {
r1 = r2_ * (1.0f / v_r - 1.0f);
}

logger_.debug("mv: {:.3f}, v_r: {:.3f}, r1: {:.3f}", mv, v_r, r1);
return r1;
}

/// @brief Get the temperature in Kelvin
/// @return Temperature in Kelvin
/// @details
/// Reads the voltage from the thermistor and converts it to temperature
/// using the Steinhart-Hart equation.
float get_kelvin() {
float r1 = get_resistance();

// compute temperature using the Steinhart-Hart equation
float t = 1.0f / (T_25C_INV + fast_ln(r1 / r0_) * b_inv_);

logger_.debug("mv: {:.3f}, v_r: {:.3f}, r1: {:.3f}, t: {:.3f}", mv, v_r, r1, t);
logger_.debug("t: {:.3f}", t);
return t;
}

Expand Down
4 changes: 2 additions & 2 deletions docs/adc/adc_types.html
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@
<li><a href="index.html">ADC APIs</a> &raquo;</li>
<li>ADC Types</li>
<li class="wy-breadcrumbs-aside">
<a href="https://github.com/esp-cpp/espp/blob/f80f4d4/docs/en/adc/adc_types.rst" class="fa fa-github"> Edit on GitHub</a>
<a href="https://github.com/esp-cpp/espp/blob/5a07a6b/docs/en/adc/adc_types.rst" class="fa fa-github"> Edit on GitHub</a>
</li>
</ul>
<hr/>
Expand All @@ -155,7 +155,7 @@ <h2>API Reference<a class="headerlink" href="#api-reference" title="Permalink to
<section id="header-file">
<h3>Header File<a class="headerlink" href="#header-file" title="Permalink to this headline"></a></h3>
<ul class="simple">
<li><p><a class="reference external" href="https://github.com/esp-cpp/espp/blob/dde3d42/components/adc/include/adc_types.hpp">components/adc/include/adc_types.hpp</a></p></li>
<li><p><a class="reference external" href="https://github.com/esp-cpp/espp/blob/661fbc0/components/adc/include/adc_types.hpp">components/adc/include/adc_types.hpp</a></p></li>
</ul>
</section>
</section>
Expand Down
4 changes: 2 additions & 2 deletions docs/adc/ads1x15.html
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@
<li><a href="index.html">ADC APIs</a> &raquo;</li>
<li>ADS1x15 I2C ADC</li>
<li class="wy-breadcrumbs-aside">
<a href="https://github.com/esp-cpp/espp/blob/f80f4d4/docs/en/adc/ads1x15.rst" class="fa fa-github"> Edit on GitHub</a>
<a href="https://github.com/esp-cpp/espp/blob/5a07a6b/docs/en/adc/ads1x15.rst" class="fa fa-github"> Edit on GitHub</a>
</li>
</ul>
<hr/>
Expand All @@ -156,7 +156,7 @@ <h2>API Reference<a class="headerlink" href="#api-reference" title="Permalink to
<section id="header-file">
<h3>Header File<a class="headerlink" href="#header-file" title="Permalink to this headline"></a></h3>
<ul class="simple">
<li><p><a class="reference external" href="https://github.com/esp-cpp/espp/blob/f80f4d4/components/ads1x15/include/ads1x15.hpp">components/ads1x15/include/ads1x15.hpp</a></p></li>
<li><p><a class="reference external" href="https://github.com/esp-cpp/espp/blob/5a07a6b/components/ads1x15/include/ads1x15.hpp">components/ads1x15/include/ads1x15.hpp</a></p></li>
</ul>
</section>
<section id="classes">
Expand Down
4 changes: 2 additions & 2 deletions docs/adc/ads7138.html
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@
<li><a href="index.html">ADC APIs</a> &raquo;</li>
<li>ADS7138 I2C ADC</li>
<li class="wy-breadcrumbs-aside">
<a href="https://github.com/esp-cpp/espp/blob/f80f4d4/docs/en/adc/ads7138.rst" class="fa fa-github"> Edit on GitHub</a>
<a href="https://github.com/esp-cpp/espp/blob/5a07a6b/docs/en/adc/ads7138.rst" class="fa fa-github"> Edit on GitHub</a>
</li>
</ul>
<hr/>
Expand All @@ -161,7 +161,7 @@ <h2>API Reference<a class="headerlink" href="#api-reference" title="Permalink to
<section id="header-file">
<h3>Header File<a class="headerlink" href="#header-file" title="Permalink to this headline"></a></h3>
<ul class="simple">
<li><p><a class="reference external" href="https://github.com/esp-cpp/espp/blob/f80f4d4/components/ads7138/include/ads7138.hpp">components/ads7138/include/ads7138.hpp</a></p></li>
<li><p><a class="reference external" href="https://github.com/esp-cpp/espp/blob/5a07a6b/components/ads7138/include/ads7138.hpp">components/ads7138/include/ads7138.hpp</a></p></li>
</ul>
</section>
<section id="classes">
Expand Down
4 changes: 2 additions & 2 deletions docs/adc/continuous_adc.html
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@
<li><a href="index.html">ADC APIs</a> &raquo;</li>
<li>Continuous ADC</li>
<li class="wy-breadcrumbs-aside">
<a href="https://github.com/esp-cpp/espp/blob/f80f4d4/docs/en/adc/continuous_adc.rst" class="fa fa-github"> Edit on GitHub</a>
<a href="https://github.com/esp-cpp/espp/blob/5a07a6b/docs/en/adc/continuous_adc.rst" class="fa fa-github"> Edit on GitHub</a>
</li>
</ul>
<hr/>
Expand All @@ -161,7 +161,7 @@ <h2>API Reference<a class="headerlink" href="#api-reference" title="Permalink to
<section id="header-file">
<h3>Header File<a class="headerlink" href="#header-file" title="Permalink to this headline"></a></h3>
<ul class="simple">
<li><p><a class="reference external" href="https://github.com/esp-cpp/espp/blob/f80f4d4/components/adc/include/continuous_adc.hpp">components/adc/include/continuous_adc.hpp</a></p></li>
<li><p><a class="reference external" href="https://github.com/esp-cpp/espp/blob/5a07a6b/components/adc/include/continuous_adc.hpp">components/adc/include/continuous_adc.hpp</a></p></li>
</ul>
</section>
<section id="classes">
Expand Down
2 changes: 1 addition & 1 deletion docs/adc/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@
<li><a href="../index.html" class="icon icon-home"></a> &raquo;</li>
<li>ADC APIs</li>
<li class="wy-breadcrumbs-aside">
<a href="https://github.com/esp-cpp/espp/blob/f80f4d4/docs/en/adc/index.rst" class="fa fa-github"> Edit on GitHub</a>
<a href="https://github.com/esp-cpp/espp/blob/5a07a6b/docs/en/adc/index.rst" class="fa fa-github"> Edit on GitHub</a>
</li>
</ul>
<hr/>
Expand Down
4 changes: 2 additions & 2 deletions docs/adc/oneshot_adc.html
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@
<li><a href="index.html">ADC APIs</a> &raquo;</li>
<li>Oneshot ADC</li>
<li class="wy-breadcrumbs-aside">
<a href="https://github.com/esp-cpp/espp/blob/f80f4d4/docs/en/adc/oneshot_adc.rst" class="fa fa-github"> Edit on GitHub</a>
<a href="https://github.com/esp-cpp/espp/blob/5a07a6b/docs/en/adc/oneshot_adc.rst" class="fa fa-github"> Edit on GitHub</a>
</li>
</ul>
<hr/>
Expand All @@ -160,7 +160,7 @@ <h2>API Reference<a class="headerlink" href="#api-reference" title="Permalink to
<section id="header-file">
<h3>Header File<a class="headerlink" href="#header-file" title="Permalink to this headline"></a></h3>
<ul class="simple">
<li><p><a class="reference external" href="https://github.com/esp-cpp/espp/blob/f80f4d4/components/adc/include/oneshot_adc.hpp">components/adc/include/oneshot_adc.hpp</a></p></li>
<li><p><a class="reference external" href="https://github.com/esp-cpp/espp/blob/5a07a6b/components/adc/include/oneshot_adc.hpp">components/adc/include/oneshot_adc.hpp</a></p></li>
</ul>
</section>
<section id="classes">
Expand Down
4 changes: 2 additions & 2 deletions docs/bldc/bldc_driver.html
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@
<li><a href="index.html">BLDC APIs</a> &raquo;</li>
<li>BLDC Driver</li>
<li class="wy-breadcrumbs-aside">
<a href="https://github.com/esp-cpp/espp/blob/f80f4d4/docs/en/bldc/bldc_driver.rst" class="fa fa-github"> Edit on GitHub</a>
<a href="https://github.com/esp-cpp/espp/blob/5a07a6b/docs/en/bldc/bldc_driver.rst" class="fa fa-github"> Edit on GitHub</a>
</li>
</ul>
<hr/>
Expand All @@ -153,7 +153,7 @@ <h2>API Reference<a class="headerlink" href="#api-reference" title="Permalink to
<section id="header-file">
<h3>Header File<a class="headerlink" href="#header-file" title="Permalink to this headline"></a></h3>
<ul class="simple">
<li><p><a class="reference external" href="https://github.com/esp-cpp/espp/blob/f80f4d4/components/bldc_driver/include/bldc_driver.hpp">components/bldc_driver/include/bldc_driver.hpp</a></p></li>
<li><p><a class="reference external" href="https://github.com/esp-cpp/espp/blob/5a07a6b/components/bldc_driver/include/bldc_driver.hpp">components/bldc_driver/include/bldc_driver.hpp</a></p></li>
</ul>
</section>
<section id="classes">
Expand Down
8 changes: 4 additions & 4 deletions docs/bldc/bldc_motor.html
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@
<li><a href="index.html">BLDC APIs</a> &raquo;</li>
<li>BLDC Motor</li>
<li class="wy-breadcrumbs-aside">
<a href="https://github.com/esp-cpp/espp/blob/f80f4d4/docs/en/bldc/bldc_motor.rst" class="fa fa-github"> Edit on GitHub</a>
<a href="https://github.com/esp-cpp/espp/blob/5a07a6b/docs/en/bldc/bldc_motor.rst" class="fa fa-github"> Edit on GitHub</a>
</li>
</ul>
<hr/>
Expand Down Expand Up @@ -169,7 +169,7 @@ <h2>API Reference<a class="headerlink" href="#api-reference" title="Permalink to
<section id="header-file">
<h3>Header File<a class="headerlink" href="#header-file" title="Permalink to this headline"></a></h3>
<ul class="simple">
<li><p><a class="reference external" href="https://github.com/esp-cpp/espp/blob/f80f4d4/components/bldc_motor/include/bldc_motor.hpp">components/bldc_motor/include/bldc_motor.hpp</a></p></li>
<li><p><a class="reference external" href="https://github.com/esp-cpp/espp/blob/5a07a6b/components/bldc_motor/include/bldc_motor.hpp">components/bldc_motor/include/bldc_motor.hpp</a></p></li>
</ul>
</section>
<section id="classes">
Expand Down Expand Up @@ -547,13 +547,13 @@ <h4>Example Usage<a class="headerlink" href="#classespp_1_1_bldc_motor_1bldc_mot
<section id="id1">
<h3>Header File<a class="headerlink" href="#id1" title="Permalink to this headline"></a></h3>
<ul class="simple">
<li><p><a class="reference external" href="https://github.com/esp-cpp/espp/blob/f80f4d4/components/bldc_motor/include/bldc_types.hpp">components/bldc_motor/include/bldc_types.hpp</a></p></li>
<li><p><a class="reference external" href="https://github.com/esp-cpp/espp/blob/5a07a6b/components/bldc_motor/include/bldc_types.hpp">components/bldc_motor/include/bldc_types.hpp</a></p></li>
</ul>
</section>
<section id="id2">
<h3>Header File<a class="headerlink" href="#id2" title="Permalink to this headline"></a></h3>
<ul class="simple">
<li><p><a class="reference external" href="https://github.com/esp-cpp/espp/blob/f80f4d4/components/bldc_motor/include/sensor_direction.hpp">components/bldc_motor/include/sensor_direction.hpp</a></p></li>
<li><p><a class="reference external" href="https://github.com/esp-cpp/espp/blob/5a07a6b/components/bldc_motor/include/sensor_direction.hpp">components/bldc_motor/include/sensor_direction.hpp</a></p></li>
</ul>
</section>
</section>
Expand Down
2 changes: 1 addition & 1 deletion docs/bldc/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@
<li><a href="../index.html" class="icon icon-home"></a> &raquo;</li>
<li>BLDC APIs</li>
<li class="wy-breadcrumbs-aside">
<a href="https://github.com/esp-cpp/espp/blob/f80f4d4/docs/en/bldc/index.rst" class="fa fa-github"> Edit on GitHub</a>
<a href="https://github.com/esp-cpp/espp/blob/5a07a6b/docs/en/bldc/index.rst" class="fa fa-github"> Edit on GitHub</a>
</li>
</ul>
<hr/>
Expand Down
6 changes: 3 additions & 3 deletions docs/cli.html
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@
<li><a href="index.html" class="icon icon-home"></a> &raquo;</li>
<li>Command Line Interface (CLI) APIs</li>
<li class="wy-breadcrumbs-aside">
<a href="https://github.com/esp-cpp/espp/blob/f80f4d4/docs/en/cli.rst" class="fa fa-github"> Edit on GitHub</a>
<a href="https://github.com/esp-cpp/espp/blob/5a07a6b/docs/en/cli.rst" class="fa fa-github"> Edit on GitHub</a>
</li>
</ul>
<hr/>
Expand Down Expand Up @@ -177,7 +177,7 @@ <h2>API Reference<a class="headerlink" href="#api-reference" title="Permalink to
<section id="header-file">
<h3>Header File<a class="headerlink" href="#header-file" title="Permalink to this headline"></a></h3>
<ul class="simple">
<li><p><a class="reference external" href="https://github.com/esp-cpp/espp/blob/f80f4d4/components/cli/include/cli.hpp">components/cli/include/cli.hpp</a></p></li>
<li><p><a class="reference external" href="https://github.com/esp-cpp/espp/blob/5a07a6b/components/cli/include/cli.hpp">components/cli/include/cli.hpp</a></p></li>
</ul>
</section>
<section id="macros">
Expand Down Expand Up @@ -326,7 +326,7 @@ <h4>Oneshot CLI Example<a class="headerlink" href="#classespp_1_1_cli_1cli_ex1"
<section id="id1">
<h3>Header File<a class="headerlink" href="#id1" title="Permalink to this headline"></a></h3>
<ul class="simple">
<li><p><a class="reference external" href="https://github.com/esp-cpp/espp/blob/f80f4d4/components/cli/include/line_input.hpp">components/cli/include/line_input.hpp</a></p></li>
<li><p><a class="reference external" href="https://github.com/esp-cpp/espp/blob/5a07a6b/components/cli/include/line_input.hpp">components/cli/include/line_input.hpp</a></p></li>
</ul>
</section>
<section id="id2">
Expand Down
4 changes: 2 additions & 2 deletions docs/color.html
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@
<li><a href="index.html" class="icon icon-home"></a> &raquo;</li>
<li>Color APIs</li>
<li class="wy-breadcrumbs-aside">
<a href="https://github.com/esp-cpp/espp/blob/f80f4d4/docs/en/color.rst" class="fa fa-github"> Edit on GitHub</a>
<a href="https://github.com/esp-cpp/espp/blob/5a07a6b/docs/en/color.rst" class="fa fa-github"> Edit on GitHub</a>
</li>
</ul>
<hr/>
Expand All @@ -154,7 +154,7 @@ <h2>API Reference<a class="headerlink" href="#api-reference" title="Permalink to
<section id="header-file">
<h3>Header File<a class="headerlink" href="#header-file" title="Permalink to this headline"></a></h3>
<ul class="simple">
<li><p><a class="reference external" href="https://github.com/esp-cpp/espp/blob/f80f4d4/components/color/include/color.hpp">components/color/include/color.hpp</a></p></li>
<li><p><a class="reference external" href="https://github.com/esp-cpp/espp/blob/5a07a6b/components/color/include/color.hpp">components/color/include/color.hpp</a></p></li>
</ul>
</section>
<section id="classes">
Expand Down
4 changes: 2 additions & 2 deletions docs/controller.html
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@
<li><a href="index.html" class="icon icon-home"></a> &raquo;</li>
<li>Controller APIs</li>
<li class="wy-breadcrumbs-aside">
<a href="https://github.com/esp-cpp/espp/blob/f80f4d4/docs/en/controller.rst" class="fa fa-github"> Edit on GitHub</a>
<a href="https://github.com/esp-cpp/espp/blob/5a07a6b/docs/en/controller.rst" class="fa fa-github"> Edit on GitHub</a>
</li>
</ul>
<hr/>
Expand All @@ -152,7 +152,7 @@ <h2>API Reference<a class="headerlink" href="#api-reference" title="Permalink to
<section id="header-file">
<h3>Header File<a class="headerlink" href="#header-file" title="Permalink to this headline"></a></h3>
<ul class="simple">
<li><p><a class="reference external" href="https://github.com/esp-cpp/espp/blob/f80f4d4/components/controller/include/controller.hpp">components/controller/include/controller.hpp</a></p></li>
<li><p><a class="reference external" href="https://github.com/esp-cpp/espp/blob/5a07a6b/components/controller/include/controller.hpp">components/controller/include/controller.hpp</a></p></li>
</ul>
</section>
<section id="classes">
Expand Down
6 changes: 3 additions & 3 deletions docs/csv.html
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@
<li><a href="index.html" class="icon icon-home"></a> &raquo;</li>
<li>CSV APIs</li>
<li class="wy-breadcrumbs-aside">
<a href="https://github.com/esp-cpp/espp/blob/f80f4d4/docs/en/csv.rst" class="fa fa-github"> Edit on GitHub</a>
<a href="https://github.com/esp-cpp/espp/blob/5a07a6b/docs/en/csv.rst" class="fa fa-github"> Edit on GitHub</a>
</li>
</ul>
<hr/>
Expand All @@ -152,14 +152,14 @@ <h2>API Reference<a class="headerlink" href="#api-reference" title="Permalink to
<section id="header-file">
<h3>Header File<a class="headerlink" href="#header-file" title="Permalink to this headline"></a></h3>
<ul class="simple">
<li><p><a class="reference external" href="https://github.com/esp-cpp/espp/blob/f80f4d4/components/csv/include/csv.hpp">components/csv/include/csv.hpp</a></p></li>
<li><p><a class="reference external" href="https://github.com/esp-cpp/espp/blob/5a07a6b/components/csv/include/csv.hpp">components/csv/include/csv.hpp</a></p></li>
</ul>
</section>
<section id="macros">
<h3>Macros<a class="headerlink" href="#macros" title="Permalink to this headline"></a></h3>
<dl class="cpp macro">
<dt class="sig sig-object cpp" id="c.__gnu_linux__">
<span class="target" id="csv_8hpp_1a51b087854dc3c2f76946efb432745639"></span><span class="sig-name descname"><span class="n"><span class="pre">__gnu_linux__</span></span></span><a class="headerlink" href="#c.__gnu_linux__" title="Permalink to this definition"></a><br /></dt>
<span class="target" id="csv_8hpp_1a51b087854dc3c2f76946efb432745639"></span><span class="sig-name descname"><span class="n"><span class="pre">__gnu_linux__</span></span></span><br /></dt>
<dd></dd></dl>

</section>
Expand Down
Loading