From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

I2C communication SHT85 and USB-8451

Solved!
Go to solution

Hi, 

 

I am trying to connect SHT85 via I2C using USB-8541 and LabVIEW. 

Is there a sample program to get raw data from the SHT85 sensor?

 

Thanks,

Nilesh

 

0 Kudos
Message 1 of 8
(2,245 Views)

I don't know of one, but some of the built in examples that come with the USB-8451 driver might get you pretty close.

For more information, you might review these:

Understanding the I2C Two Wire Bus Interface with NI LabVIEW - NI

Using I2C with LabVIEW and the USB-8451 - National Instruments (This one mentions the USB-8451 driver examples)

 

Also, I found this:

Adapting code from U3/U6 to T7 | LabJack

I haven't reviewed it thoroughly, but in the replies at the end, it links to examples by LabJack that mention using the SHT85 with I2C.

 

However, I do not have experience using I2C with LabVIEW, so if someone more experienced with I2C, the SHT85, or the USB-8451 reads this, I hope they will respond. 😅

 

-joeorbob

0 Kudos
Message 2 of 8
(2,224 Views)

Here's something to get you started.  I already spent more time on this than I should have.  Code in LabVIEW 2019.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Download All
Message 3 of 8
(2,142 Views)

Thank you both of you.

 

It helped me a lot.

Also, I did something similar. See the attached file. The output is raw data. 

 

nilux_0-1597064603414.png

 

Thanks,

Nilesh

 

0 Kudos
Message 4 of 8
(2,132 Views)
Solution
Accepted by topic author nilux

@nilux wrote:

Thank you both of you.

 

It helped me a lot.

Also, I did something similar. See the attached file. The output is raw data. 

 

nilux_0-1597064603414.png

 

Thanks,

Nilesh


1. No need to do anything with the DIO Active Port.  a) There is only 1 port.  b) You are not using it for this application.  The voltage level may need to be set depending on your supply voltage for the device.

2. You need to set the pull-up to be active unless you are supplying your own pull-up.

3. You do not need to use the I2C Write to write the address.  That is taken take of by the driver.  I forgot this part in my quick example using the property node like you did.

4. Speaking of the address, I don't think you are setting it to the proper value.  a) You have a coercion dot there, meaning you are using the wrong representation.  It should be a U16 to make the driver happy (it can handle larger address ranges, but defaults to using the 7-bit).  b)  Right-click on the constant and enable Visible Items->Radix.  You will see a little letter show up in the constant.  This shows in what format the value is shown in.  If it is a 'd', that means you are inputting decimal values.  But everything in the manual is in hex.  So you need to click on that icon and choose "hex".  Retype the "44".  NOTE: If you are ever using a format other than decimal, you really should have the radix visible so you can immediately tell.  I have seen way too many errors from mixing hex and decimal formats.

5. Depending on your repeatability, the device may take between 2.5 - 15.5ms.  This is an EXTREMELY long time.  So you do not want to use the Write-Read function.  You will want to do your write, wait for a set amount of time, and then do the I2C Read for 6 bytes.

6. Since you are doing the "one-shot", you do not need to send the "Fetch Data".  So just use I2C Read.

 

Here is an update to my example adding the address.

 


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 5 of 8
(2,124 Views)

Thank you for your suggestions.

 

Yes, your suggestions works and I don't need to write fetch command. 

One write and read can get me raw data. 

 

1. DIO port: I am going to use it for future work. I am going to use the I2C multiplexer to connect multiple SHT85. 

2. I am using external pullups resistors. 

3. Repeatability is going to be in minutes. 

4.  "Fetch Data".  Let's say I want to read data every 10 min, Do I need to use fetch data or just loopback?

 

 

Thanks,

Nilesh

 

0 Kudos
Message 6 of 8
(2,117 Views)

@nilux wrote:

3. Repeatability is going to be in minutes. 

4.  "Fetch Data".  Let's say I want to read data every 10 min, Do I need to use fetch data or just loopback?


I was stating "repeatability" as stated in the data sheet.  The repeatability can be "Low", "Medium", or "High" and they increase in measurement time.  So you should definitely use the one-stop measurement command, wait, and then read the measurement.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 7 of 8
(2,112 Views)

 Yes, Correct. 

0 Kudos
Message 8 of 8
(2,108 Views)