Example Code

Reading 1-Wire DS18B20 and DS18S20 Via a Serial or USB Adapter

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Software

  • LabVIEW

Code and Documents

Attachment

 

 

Overview
    This VI package reads the temperature from a DS18B20 and/or DS18S20 1-wire temperature probe via a serial adapter (DS9097U) or USB adapter (DS9490R). The VIs only use the TMEX DLLs.

 

 

Description

    This program uses the TMEX API to start a session, detect measurements, read measurements, and end a session with the DS18B20 or DS18S20 1-wire temperature probes. The probes are connected to the PC via a serial or USB adapter.

 

Requirements

    Software
        LabVIEW 2012 (or compatible)
    Hardware
        1-wire COM port adapter (DS9097U) or USB adapter (DS9490R)

 

Instructions
    1. Extract files
    2. Open and run "Reading several 1-wire probes via a serial or USB adapter.vi"

  

Additional Information or References

Snippet.png

 

 

6 Dec 2006: My previous example didn't work with several temperature sensors on the same net so I updated so that it works. The new example measures all temperature sensors on a net and place the results in an array and indicates how many were found.

7 Dec 2006: Created a cluster to get together the temperature with the sensor ID.

3 Apr 2007: Someone had problem with interfacing a DS18S20 so I got some samples from Maxim (thank you) and I could update the VIs accordingly. The temperature reading is a bit different so I made 2 VIs, one for each.

 

**This document has been updated to meet the current required format for the NI Code Exchange.**

 

 

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Comments
Member
Member
on

Help with Multiple DS1822s

All,

I'm attempting to use Labview 7.1 to display about 16 DS1822's temperature readings and your latest post was quite helpful in getting a readout if there's only 1 device in the system. I've tried modifying the code to be able to read and display from multiple sensors, but with no luck.

I've been able to identify and display the correct serial numbers of multiple devices, using the TMNext function after using the TMFirst device identifier. The problem seems to lie within the Read DS18B20.vi when trying to read more than one device. I think it has to do with the way I'm routing my SessionHandler and StateBuffer signals. Has anyone tried identifying, reading, and displaying multiple DS18B20s or DS1822s at a time? I'm very new to both 1-wire and TMEX API, so any help would be greatly appreciated. Thanks!

Rick Clemons

rclemons@hrl.com

Member
Member
on

Thanks a lot!

This is a very good instrument driver for the DS18B20! Actually to my knowledge this package is the only full featured driver for DS18B20. It would be great to have some documentation in the package about the propre way to set and talk to the DS18B20.

Member
Member
on

I would like to know the legal terms of usage of this package. I am curently graduating from tech. university and i would like to use parts of this package in my own program. My program would be strictly used to measurements purposes at university (no commercial usage). Please provide adequate notice on this page (e.g. comment) as well as email (visible on my profile page).

Thanks in advance for any help.,

Member
Member
on

I had some difficulties to get this 1-wire code to work. I have installed latest Maxin drivers from Maxim's web site. It started to work, when I copied two .exe files from Maxim driver install directory and IBFS32.dll from system32 over files in this zip.

 

Thanks!

Member
Member
on

Hi, I would like to know about the legal terms of usage of this package too, I am about to graduate too. I will make an App to compare the behavior of the different temperature sensors at the Lab of my Faculty; and I would like to use some parts of this package too. My App is not for comercial use neither. Just like with yeltzyn.

I was thinking to make an App to read the temperature from the DS18B20's by programing the comunication protocol in Labview and to use a DAQ USB6009 with an externat circuitry.

Thank you so much for this project, it gives more ideas

Norberto Purtschert B.

norberto2540@hotmail.com / norberto2540@gmail.com

Member
Member
on

Hi. I have tried to use the code with my brewery and antempted to read out the temperatures. I did not succeed with the code as is, so I had to do some modification to make it work as intented.

With the code provided below, the temperatures are being read from three sensors (but more can be added if the number in blue near the stop-button is changed from 2 to any number of sensors minus 1).

1-wire three temperatures.JPG

Member
Member
on

Hi all,

If you'd like something that works for any number of devices, many types, and comes with accessory vis, examples, and a full-featured data logger (and many more features), you might give this a try: http://interfaceinnovations.org/onewireproducts.html

It will save you loads of time over programming it all yourself (trust me). Download a demo, and if you have any questions, contact me directly at support@interfaceinnovations.org.

Best regards,

Colin

PhD ChemE, CLD, Alliance Partner : www.interfaceinnovations.org
Member
Member
on

By the way, Siske, I've used these all over my personal 15G all-grain brewery and love them. I built the OneWire control app included with the package specifically for this purpose. I sit on my couch and watch the temperature of my mash on a big monitor! It's great for brewday, especially during college football season!

Cheers,

Colin

PhD ChemE, CLD, Alliance Partner : www.interfaceinnovations.org
Member
Member
on

Hello,

i know this VI is quite old, but I finally got to work it.

Only if I run it in a loop, to update my temperature reading I dont recieve any more values. If I close LabView and open it again it works again one time.

It seems as if some variable is not properly cleaned or reseted, but I can't figure out which one.

Sometimes the whole programm crashes due to some memory violation error. (seems random to me at this point)

I`m using LV 2013 and the ibfs32.dll.

Any suggestions and help would be appreciated

Thank you very much.

Member
Member
on

i dont understand how i use the VI ,there is no read_me file in there ,can any one help me pls?

Member
Member
on

Hi,

 

thanks for sharing this code. I'm planning to reuse the code for reading out contents from an EEPROM DS2430/2431 via DS9490R USB-RJ11 connector. I'm observing a 'Memory Full" error as shown. I realize this error may be because of lots of open handlers, but this is the first time I'm executing this VI. So there shouldn't be any open handlers.Memory Full ErrorMemory Full Error

 The VI shows the handle number as 4294967095 which is obviously beyond the range. I tried to End session with this value, but the VI can't reach that value, it is limited to 2147483647: End session range cannot cover the open handlerEnd session range cannot cover the open handler

 Can someone let me know how to accommodate the Start Session vi to eliminate this error and also advise to extract the ROM contents from the EEPROM chip with a family code 14h. Search for 14h family code (EEPROM)Search for 14h family code (EEPROM)

 

 

 

 

 

 

 

Active Participant
Active Participant
on

There is a much better driver available now:

https://lavag.org/files/file/302-1-wirezip/

Member
Member
on

I'm trying to communicate with max17312 Maxim IC using one wire adapter.

At first I was using DS9481 - 3C7 one wire adapter and it communicates with the Maxim IC( Max17312) using One Wire Evaluation program. And then, when I was trying to communicate with it through Labview I got struck and I dont find any library for it.

At last I came across your post about one wire adapter and I was trying to use the OneWireLinkLayer.dll file which is responsible for the One wire Evaluation Program but no hope I cannot see the Function names in it.

 

So I tried to get another adapter DS9490R (USB) iButtonlink which uses ibfs32.dll file. and I'm here in this phase struck too.

Can you please help me out?

 

And also can you do me favor, I'm using LV2012 and the VI found in the following link are in LV2017.

https://lavag.org/files/file/302-1-wirezip/

Can you save the file in lower version LV2012??

 

 

Thanks 

Nhizanth

Member
Member
on

Hi

 

I use the "Reading several 1-wire probes via a Serial or USB adapter-LV2012.zip" to communicate with a USB to 1-wire converter DS9097U.

I made some little modifications to the VIs to work with my environment. 

So I got it to work if I start it from the "Reading several 1-wire probes via a serial or USB adapter 2012 NIVerified.vi" as top level VI.

But if I call this VI (as a SubVI) from another VI the HW couldn't be detected:

I have to unplug and re-plug the USB to 1-wire converter and then it works. 

But this is not really usefull, because I want to use the whole thing in a testprogram among much other tests.

 

Has anybody an idea why the VI works as long as I use it as a top level VI, but doesn't if it is used as a SubVI?

 

Thank you very much!

 

1-wire_Reading several 1-wire probes modified ls.JPG1-wire_Reading several 1-wire probes modified ls_StartSession.JPG