2026-02-06 2:22 AM
I want to interface STM32G474 MCU with DS18B20 digital temperature probe in my project. The DS18B20 uses one-wire interface. Is one wire interface supported with this MCU?
Kindly provide a detailed explanation. Help please.
Datasheet link for DS1B20: EVVO DS18B20Axx
Regards,
Sreejith
Solved! Go to Solution.
2026-02-09 2:41 AM
@sreejithrnair2026 wrote:do not have any UARTs free and all the UARTs are occupied.
You can take a similar approach to synthesising 1-Wire using SPI ...
See:
Note also that Analog Devices (who are now the manufacturers, since they acquired Maxim) have various bridge chips to connect 1-Wire to more widely supported interfaces; eg, I2C:
https://www.analog.com/en/products/ds2482-100.html
2026-02-06 2:27 AM - edited 2026-02-06 2:32 AM
Hello @sreejithrnair2026 and welcome to the ST community,
The protocol used by this sensor is not supported natively by the MCU. You need to use GPIO and may be a timer to communicate with a such sensor.
2026-02-06 2:30 AM
You can easily implement one-wire with an uart. Uart Feature of G4 like logic inversion, open drain and half duplex mode allows implementation with one pullup.
2026-02-06 2:36 AM
And it seems others already implemented that:
Example: https://github.com/nimaltd/ds18b20/tree/master
2026-02-09 12:56 AM
Thanks for sharing the implemented code. In my case, I do not have any UARTs free and all the UARTs are occupied. So, I can only use the option of bit banging for 1 wire interface.
2026-02-09 2:25 AM
Try to use the timer so you have constant timing. GPIO bitbanging will easily be disturbed by other interrupts...
2026-02-09 2:31 AM - edited 2026-02-09 3:14 AM
Hello @sreejithrnair2026 ,
Look at the link I have shared it uses GPIO + timer to read and write data:
The link to the one wire library:
https://github.com/nimaltd/ow/tree/main
Used by a higher level library: ds18b20: https://github.com/nimaltd/ds18b20/tree/master
2026-02-09 2:41 AM
@sreejithrnair2026 wrote:do not have any UARTs free and all the UARTs are occupied.
You can take a similar approach to synthesising 1-Wire using SPI ...
See:
Note also that Analog Devices (who are now the manufacturers, since they acquired Maxim) have various bridge chips to connect 1-Wire to more widely supported interfaces; eg, I2C:
https://www.analog.com/en/products/ds2482-100.html
2026-02-09 5:51 AM
Thank you Andrew. Really appreciate your support.
Regards
2026-02-09 6:35 AM
If your question has been answered, please accept as solution the post that has answered it.