cancel
Showing results for 
Search instead for 
Did you mean: 

Interfacing DS18B20 temperature sensor with STM32WB55 development board

SChan.8
Associate II

Hi,

I have been working on interfacing a Ds18b20 sensor with STM32wb55 development board using CubeIDE version 1.5.0. I am using the code provided by controller's tech website following their instructions. The link for the code can be found below. 

https://controllerstech.com/ds18b20-and-stm32/

The microsecond delay function did not work with the board. Therefore, I have implemented and checked the below code and is working fine (It was checked with the oscilloscope). 

According to the datasheet, for the initialization of the sensor, the data pin is pulled low from the high state (for at least 480 us) and released by making it a NOPULL input. Therefore the voltage goes high as the data pin is pulled up by a 4.7k resistor. If the conditions are correct, the sensor would sense the rising pulse and must pull the data pin low for reset within 15-60us. 

I have tried several methods to evaluate the sensor response but no luck so far. The problem persists in all the approaches I have tried. 

(For example, instead of reading the data pin after 60us, I put a while loop incrementing time by 1us 60us max time).

while(HAL_GPIO_ReadPin (DS18B20_PORT, DS18B20_PIN)==1){

t=t+1;

if(t>60) return false;

timerdelay(1);

}

But I could only see that the while loop maxed out every time meaning that the pin never pulled down by the sensor.

I would appreciate if anyone could tell me where I am wrong at or what I could try to make the sensor detect the rising pulse.

2 REPLIES 2
Tilen MAJERLE
ST Employee

In order to avoid using delays and to simplyfy development process and code flow, I have developed an OneWire library, that is optimized to work with UART hardware.

If you have any free UART on STM32WB55 and could use it for DS18B20, this is a good opportunity.

https://github.com/MaJerle/lwow

Link to docs of the lib is in the repository. There is also schematics diagram to follow.

Did I understand correctly that your link will work with FreeRTOS and without "IT" and "DMA"?