HAL library 06- DS18B20 for STM32Fxxx

When you have onewire library done, it’s easy to make interface for DS18B20 sensors.

Library

Read more about new HAL libraries

Features

  • Search sensors
  • Read temperature
  • Set resolution for each device from 9 to 12 bits
  • Start temperature conversion on all devices simultaneously
  • Set alarm low and high temperatures
  • Disable alarm temperatures
  • Search devices with alarm flag set

Dependencies

  • HAL
  • TM
    • STM32Fxxx HAL
    • defines.h
    • GPIO
    • DELAY
    • ONEWIRE

Functions and enumerations

Example

 

Project is available on Github, download all libraries below.

Icon
TM STM32 Libraries

STM32 libraries based on STM32Fxxx HAL drivers.

tilz0R

Owner of this site. Also electronic enthusiasts, web developer, 3D printer fan, handball player and more. Big fan of STM32F4 devices. In anticipation of the new Discovery board for STM32F7 lines.

You may also like...

Read before commenting!

Before you make a new comment, make sure you agree with things listed below:

  • - Read post to make sure if it is already posted what you are asking for,
  • - Make sure you have the latest version of libraries used in your project,
  • - Make a clean and grammatically correct written message,
  • - Report as many details as possible, including what have you done so far,
  • - Do NOT post any code here. Use Pastebin,
  • - Do NOT post any error codes here. Use Pastebin,
  • - Specify STM32Fxxx family and used Discovery/EVAL/Nucleo or custom made board,
  • - Make sure your clock is set correct for PLL,
  • - If you are using my HAL drivers, please check this post how to start.
Comment will be deleted on breaking these rules without notification!
  • Pingback: All STM32 HAL libraries - STM32F4 Discovery()

  • Jędrzej Szczepaniak

    Hi, I have some problem with this library. I’m working on STM32F4-DISCO and can’t find any devices on OneWire line. I created project with STMCubeMX. I’m not sure how to set up pin for OneWire there. Any tips?

    • My guess, delay problems.

      • Jędrzej Szczepaniak

        I’m using TM delay lib. Only I do with them is change include file names. Should I do something more?
        I’m starting with STMs and first time using this libs.

        • Try to run rhis example directly from github project for start and check if it works.

          • Jędrzej Szczepaniak

            I’ve run example from git and it’s working, but I wondering why my project don’t.

          • I see here 2 possible reasons. Oje is that pll is not set correct, second is that delay does not work ok. I think first reason has more chances to win.

          • Jędrzej Szczepaniak

            This is how it look like in my project. There are default values, made by STMCube

          • First of all, hclk should be 168MHz, and source for pll on your board is external 8MHz. Second…why you use stmcubemx? This is source of problems.

          • Jędrzej Szczepaniak

            Heard it is good tool. Why it is problem?

          • As you can see, you have plenty of problems why it is not working.

          • Jędrzej Szczepaniak

            Didn’t expected that Cube cause this problems. But any idea why? There only way is to avoid Cube?

          • CubeMX is still not tool for newbies.

          • Jędrzej Szczepaniak

            OK, many thanks for help. I just donate you for big beer. 🙂

  • Mahmud Ibrahim

    Hi Tilen, how r u? I guess u r doing well. I have some problem with this DS18B20 library of yours. I have tired it with STM32F051 Discovery. Unfortunately, discovery board can’t find any device on One Wire line (PD2). I have used start_up stm32f051 instead of start_up stm32f091. May be i made mistake in PLL setting. Will u please point me the error in the given C/C+ define of keil….

    STM32F051x8,USE_HAL_DRIVER,ARM_MATH_CM0,STM32F0XX,STM32F051_DISCOVERY,HSI_VALUE=8000000,RCC_OSCILLATORTYPE=RCC_OSCILLATORTYPE_HSI,RCC_PLLM=8,RCC_PLLN=336,RCC_PLLP=4,RCC_PLLQ=7

    Secondly, I have also face problem in USART program. The same program u have written, i also tired it. But the problem is some garbage value it’s displaying. I knew its because of baudrate setting. i have set the baud rate at 9600. But i think this problem is also related to PLL setting. The same one above. it would be great if you create a keil setting for STM32F051 discovery.

    Thanks