Code Monkey home page Code Monkey logo

thermistorntc's Introduction

ThermistorNTC

STM32 LL(Low-Layer) C library. Thermistor is short form of thermal resistor, whose resistance changes with change in temperature.

Features

  • Interrupt based implementation
  • Auto ADC resolution detection
  • Temperature to int value rounding
  • No HAL dependencies

image

Add as CPM project dependency

How to add CPM to the project, check the link

CPMAddPackage(
        NAME ThermistorNTC
        GITHUB_REPOSITORY ximtech/ThermistorNTC
        GIT_TAG origin/main)

Project configuration

  1. Start project with STM32CubeMX:
  2. Select: Project Manager -> Advanced Settings -> ADC -> LL
  3. Generate Code
  4. Add sources to project:
add_subdirectory(${STM32_CORE_SOURCE_DIR}/ADC/IT)  # add ADC to project

include_directories(${THERMISTOR_NTC_DIRECTORY})   # source directories
file(GLOB_RECURSE SOURCES ${THERMISTOR_NTC_SOURCES})    # source files
  1. Then Build -> Clean -> Rebuild Project

Wiring

  • image

Usage

Provide interrupt handler in stm32f4xx_it.c

/**
  * @brief This function handles ADC1 global interrupt.
  */
void ADC_IRQHandler(void) {
   conventionCompleteCallbackADC(ADC1, ADC_REGULAR_CHANNEL);
}

Define values at main.h or use defaults(see ThermistorNTC.h)

#define NTC_SUPPLY_VOLTAGE 3.275
#define NTC_B_COEFFICIENT 3950
#define NTC_RESISTANCE 9840

Then predefined NTC instance can be created

#include "ThermistorNTC.h"

int main() {

   ThermistorNTC thermistor = initPredefinedThermistor(ADC1, TIM3, LL_ADC_CHANNEL_0);
      if (thermistor == NULL) {
         Error_Handler();
      }
      
      while(true) {
          
        int32_t temperature = readThermistorCelsiusAsInt(thermistor);
        printf("Temperature: %d\n", temperature);
      }
}

Or create instance passing parameters

ThermistorNTC thermistor = initThermistor(ADC1, TIM3, LL_ADC_CHANNEL_0, NTC_RESISTANCE, NTC_SUPPLY_VOLTAGE, NTC_B_COEFFICIENT);

thermistorntc's People

Contributors

ximtech avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.