The Godfather talking
You think I am funny guy huh?
Sonsivri
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
December 01, 2021, 05:50:56 17:50


Login with username, password and session length


Pages: [1]
Print
Author Topic: One Wire + DS18B20 STM32 library  (Read 2881 times)
0 Members and 1 Guest are viewing this topic.
burgic
Newbie
*
Offline Offline

Posts: 29

Thank You
-Given: 8
-Receive: 20


WWW
« on: August 27, 2020, 11:37:09 23:37 »

Hello,

I started a new project today and one of the things I need is DS18B20 temperature sensor library.
I remembered that few years ago I made one for STM32F1xx MCU (but it can be easily reused for other (STM32) MCUs).
I hope it can be of use to someone else as well.

Source code is attached.

P.S. The library is incomplete (CRC calculation missing) but all other thing should be there.

Cheers!
Logged
metal
Global Moderator
Hero Member
*****
Online Online

Posts: 2411

Thank You
-Given: 846
-Receive: 667


Top Topic Starter


« Reply #1 on: August 28, 2020, 04:01:15 04:01 »

https://github.com/nimaltd/ds18b20
https://github.com/cybergibbons/DS2482_OneWire
https://embdev.net/attachment/391825/STM32_CunbeMX_DS18B20.pdf
https://controllerstech.com/ds18b20-and-stm32/
Logged
burgic
Newbie
*
Offline Offline

Posts: 29

Thank You
-Given: 8
-Receive: 20


WWW
« Reply #2 on: December 29, 2020, 06:50:02 18:50 »

I updated the code a bit. See attachment.
Logged
burgic
Newbie
*
Offline Offline

Posts: 29

Thank You
-Given: 8
-Receive: 20


WWW
« Reply #3 on: May 13, 2021, 07:54:50 19:54 »

Considering the lack of STM32 MCUs on the market due to the reduced production, I've decided to switch (temporarily) to the MSP430 MCUs as they are still available in large quantities at Mouser.
Given this, I had to start with some demo to learn about the MCU itself. Is there a better way than to integrate/port existing source code from another MCU?

In the attachment, there is a demo application for measuring the temperature from DS81B20 and displaying it on LCD 20x4 display over the LCD2Wire interface.
Feel free to reuse it for your needs.

Cheers!
Logged
bobcat1
Senior Member
****
Offline Offline

Posts: 254

Thank You
-Given: 3370
-Receive: 76


« Reply #4 on: May 16, 2021, 08:12:05 08:12 »

Hi
There are 2 way to use a microcontroller for communicating with the DS18B20 temp sensor
First way and most used is bit banging who is not using interrupt and slowing down the control process,
The 2nd way is to use one of the UART as the interface for the one wire communication protocol this way is using interrupt and not holding back the controller wile reading the sensor
I can also advice you to use the new GD32VF103 RISC-V controller manufactured by GigaDevice it is a very fast chip (108 Mhz)
And very stable from the software point of view and far more stronger then the MSP430
Code library for both method can be found in GITHUB by searching Google. 
Logged
burgic
Newbie
*
Offline Offline

Posts: 29

Thank You
-Given: 8
-Receive: 20


WWW
« Reply #5 on: May 16, 2021, 11:37:01 11:37 »

Hi,

Yes, I am aware of "misusing" UART peripheral for One Wire interface and this is easy to make (especially) on STM32 devices, but honestly I was too lazy to do it Smiley This library was initially made for PIC16F628A, afterwards ported for several MCUs and due to the lack of time (as always) you don't touch the things which are already working Cheesy I will definitely make this upgrade in the future and share the results here.
Regarding the MSP430, I choose it intentionally for a low-power project. Otherwise, I would consider something more powerful for sure.

Cheers!
Logged
Pages: [1]
Print
Jump to:  


DISCLAIMER
WE DONT HOST ANY ILLEGAL FILES ON THE SERVER
USE CONTACT US TO REPORT ILLEGAL FILES
ADMINISTRATORS CANNOT BE HELD RESPONSIBLE FOR USERS POSTS AND LINKS

... Copyright 2003-2999 Sonsivri.to ...
Powered by SMF 1.1.18 | SMF © 2006-2009, Simple Machines LLC | HarzeM Dilber MC