Display temperature with DS18b20, but the display is always

mikroC, mikroBasic and mikroPascal PRO for Microchip’s 32-bit PIC MCUs
Post Reply
Author
Message
malugu
Posts: 2
Joined: 04 Jul 2019 07:48

Display temperature with DS18b20, but the display is always

#1 Post by malugu » 05 Nov 2019 10:53

I recently used DS18b20 to display the temperature, but the display has always been 00.0. It should be a problem with the timing of the DS18B20 module. Please explain how to write the correct timing.

User avatar
jovana.medakovic
mikroElektronika team
Posts: 986
Joined: 18 Dec 2018 10:36

Re: Display temperature with DS18b20, but the display is alw

#2 Post by jovana.medakovic » 06 Nov 2019 10:12

Hello,

In the folder where your compiler is installed on the path:
\Mikroelektronika\mikroC PRO for PIC32\Examples\Development Systems\EasyPIC Fusion v7\One Wire
you can find the example for the DS18B20 sensor.

Can you tell me which development board and MCU you are using?

Kind regards,
Jovana

zhschip
Posts: 4
Joined: 24 Jan 2024 10:07

Re: Display temperature with DS18b20, but the display is always

#3 Post by zhschip » 24 Jan 2024 10:19

The DS18B20 is a digital temperature sensor that uses the 1-Wire protocol for communication. Timing is crucial when working with the DS18B20, as it follows specific timing requirements for sending commands and receiving data. In order to successfully communicate with the DS18B20 and receive accurate temperature readings, it's important to follow the protocol correctly.

In general, here is an overview of the steps to communicate with the DS18B20 sensor:

Initialization:

The master (usually a microcontroller) sends a reset pulse to the DS18B20 to start communication.
After the reset pulse, the master should release the bus and wait for the presence pulse from the sensor.
Command:

The master sends a command to the sensor, such as a temperature conversion command, read command, or others.
Data Transmission:

The sensor responds to the command by transmitting data back to the master, typically including the temperature information.
To begin the communication process, the timing for the reset pulse, presence pulse, and other elements must be carefully managed. Here are the typical timing requirements for the DS18B20 sensor during the communication and temperature conversion process:

Reset Pulse: This should be held low for at least 480μs and released. The line should be pulled high within 15-60μs after the 480μs.
Presence Pulse: After the reset pulse, the DS18B20 should pull the bus low within 15-60μs to indicate its presence.
Write 1 time slot: The master should pull the data line low for 1μs and then release it to write a 1 to the sensor.
Write 0 time slot: The master should pull the data line low for at least 60μs to write a 0 to the sensor.
Read time slot: To read, the master should pull the data line low for 15μs, then release it and wait for the line to be pulled low by the DS18B20 within 15μs for a 0 response, or held high by the DS18B20 for a 1 response.
When using the DS18B20, it's quite common to use a specialized library or driver provided by the microcontroller manufacturer or a third-party. These typically handle the low-level timing requirements, so you may not have to directly manage the timing of each pulse and signal.

If you are using a library, ensure that the library is correctly initialized and configured according to the timing requirements of the DS18B20. If you're implementing the communication directly, reference the DS18B20 datasheet for precise timing requirements and consider using existing libraries to abstract and handle these intricacies. Always refer to the official documentation and datasheets for accurate information regarding the DS18B20's timing and communication protocols.
Zhonghaisheng provides original electronic components with low prices, fast delivery,excellent after sales service.with huge selection in stock and ready to ship same day with no minimum orders.New electronic components and parts added every day.

Post Reply

Return to “PIC32 PRO Compilers”