cancel
Showing results for 
Search instead for 
Did you mean: 

One wire interface fr STM32G474MBT6

sreejithrnair2026
Associate II

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

1 ACCEPTED SOLUTION

Accepted Solutions

@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:

https://community.st.com/t5/stm32-mcus-embedded-software/ds2431-read-rom-returns-0x00-on-stm32f446re/m-p/845399/highlight/true#M68752

 

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

 

 

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.

View solution in original post

9 REPLIES 9
mƎALLEm
ST Employee

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.

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.
Uwe Bonnes
Chief

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.

mƎALLEm
ST Employee

And it seems others already implemented that:

Example: https://github.com/nimaltd/ds18b20/tree/master

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.
sreejithrnair2026
Associate II

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.

Try to use the timer so you have constant timing. GPIO bitbanging will easily be disturbed by other interrupts...

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

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.

@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:

https://community.st.com/t5/stm32-mcus-embedded-software/ds2431-read-rom-returns-0x00-on-stm32f446re/m-p/845399/highlight/true#M68752

 

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

 

 

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.

Thank you Andrew. Really appreciate your support.

 

Regards

mƎALLEm
ST Employee

@sreejithrnair2026 ,

If your question has been answered, please accept as solution the post that has answered it.

 

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.