DS18B20 not registering with internal pullup resistor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-08-14 9:26 AM - edited ‎2024-08-14 9:54 AM
I am trying to use the DS18B20 temp sensor on a stm32h7 board to display the current temperature using putty, and if the temp is higher than 45 degrees celsius to display a heat warning, but for whatever reason the sensor is not beign registered.
I have connected the vdd cable to the 5v pin and the data cable to the A2 pin, I have configured the A2 pin as Output Open Drain with pull-up and I think that the sensor is not being registered.
I have attached my code so far
"""
Heat Warning! Current Temperature: 1515.38°C
Heat Warning! Current Temperature: 821.12°C
Heat Warning! Current Temperature: 3424.06°C
Heat Warning! Current Temperature: 1877.06°C
Heat Warning! Current Temperature: 2543.00°C
Heat Warning! Current Temperature: 2560.12°C
Heat Warning! Current Temperature: 1713.81°C
"""
I followed a lot with this tutorial: https://controllerstech.com/ds18b20-and-stm32/#google_vignette
So I think I got the delays correct but I am not entirely sure
Any help would be really appreciated
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-08-14 11:12 AM
Welcome @smakivic, to the community!
you should check your main.c again. I've already found a few strange things when quickly looking over it:
- in Set_Pin_Input() you use the parameters *GPIOx and GPIO_Pin, but then call DS18B20_PORT and DS18B20_PIN directly in the function. Why use parameters then for the function call?
- In Set_Pin_Output() you set the GPIO to output push-pull. However, the DS18B20 uses a bidirectional line that should only float (and thus possibly supply the DS18B20 parasitically) or be pulled to GND (logical zero). You would therefore have to use OD = open drain here.
Have you also verified the waveform on the bi-directional pin using a scope?
Which compiler are you using?
Which compiler optimisation have you set?
Regards
/Peter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-08-15 3:04 AM
Tutorials aside, people should read datasheets.
In the sensor's DS, I only see a 4k7 pull-up in each schematic.
Compare that to the STM's pull-up, so no surprise here.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-08-15 4:14 AM
Im pretty sure that the compiler is arm-none-eabi-gcc and the optimisation is None (-O0)
