How to read the temperature value from the DS18B20 temperature sensor through the host computer?

Thread Starter

Young2

Joined Dec 7, 2020
94
I currently have only the following three conditions.
1, a DS18B20 temperature sensor (four-wire, 485 transmission method)
2, a USB to 485 converter
3, a networked laptop

I have achieved the following results.
Connect the three elements and use the serial debugging assistant to debug, send the temperature sensor to get the temperature message, have been able to get the message containing the temperature value: for example, send 00 03 00 00 00 00 02 C5 DA
The return message 00 03 04 01 08 01 81 AB 3D, the decimal value of the two bytes 01 08 in the return message is 264, so the temperature value is 26.4°C

What I expect to achieve, Instead of using this serial debugging assistant, how can I send a request and get the temperature value directly through a program in the upper computer?
 
What OS and what serial debugging are you using? Luckily being a serial port / converter the actual programming is pretty easy. Open port, write data, read data, close port. All OSs work the same more or less in terms of serial port programming. Google "serial port programming in c" for some ideas.
 

Janis59

Joined Aug 21, 2017
1,355
Little bit other but very similar sensor I used many occassions and only problem I met was that before reading it MUST be nullified all the time. You cannot read "over" the already read figures.
 

ag-123

Joined Apr 28, 2017
61
An easier way is to use a microcontroller e.g. Arduino boards, stm32 etc to interface the sensor.
Then on the pc it is just a serial (VCP) com port connection, and you can control the comms in your sketch/firmware.
 

MrChips

Joined Oct 2, 2009
24,457
DS18B20 uses 1-Wire bus. How did you get it interfaced to 4-wire RS-485?
If you already have it interfaced to a PC via USB you should be able to read it into MATLAB.
 
Top