LabVIEW Interface for Arduino Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

DHT11

I am using a dht11 temperature and humidity sensor for my arduino project. I have downloaded the arduino toolkit for Labview, but I dont know how to incorporate the dht11 or something similar into my vi. I am new to Labview so I might be missing something very basic here, but any help or guidance would be great. Thanks.

0 Kudos
Message 1 of 78
(54,811 Views)

Do you have it working with Arduino code to knwo that it works?  It seems that it is very time sensitive so you would likely want to implement it on Arduino along side the LabVIEW firmware.  This is generally not for beginners who do not already understand how the LabVIEW firmware for Arduino works.

Message 2 of 78
(19,391 Views)

The sensor is working, I was able to communicate with it using the Arduino code for the dht11. Do you mean add on to the LVIFA base code in order to implement the sensor into my VI?

0 Kudos
Message 3 of 78
(19,391 Views)

The LVIFA system is by default built only with a simple control structure that allows specific functions to be performed (i.e. IO manipulation, and standard communication protocols).

As the writer of the DHT11 library for the Arduino I can tell you that the closest you could get with the current LVIFA system would be to create a complex communication algorithm in the visual editor that handles the single wire communication protocol. This would be a cumbersome process, but it may work. My personal recommendation is that we re-write both the LVIFA Arduino Firmware, and the LVIFA software (for NI) to add a modular Serial control interface.

We could specifically add the DHT11, or we can try to figure out a way to make an NI block that lets you set the commands being sent, and the way the returned serial message is interpreted. That would allow future modifications to be made entirely on the Arduino Firmware.

To be perfectly honest my experience with NI is fairly limited, but I would be more than happy to collaborate with anyone who would like to help extend the functionality for more modular use.

~Joseph Dattilo

Message 4 of 78
(19,391 Views)

The quickest method is to simply create a command in LabVIEW (with a corresponding case in the LIFA firmware) that executes object.readHumidity() and object.readTemperature and sends those back via serial to LabVIEW.  This method requires you to initiate the DHT object in the firmware essentially just like you do it normally.

In summary, the only thing that LabVIEW does is asks for the output values and the library for the DHT handles all the messy stuff.

I could try and write it up (both firmware and LabVIEW code) but I won't be able to test at all because I don't have an arduino.

0 Kudos
Message 5 of 78
(19,391 Views)

My knowledge and skill level in these areas are pretty low, but if you were able to write something up I could test it on my board. Or if you could give me some more specific directions on how to possibly execute this that would also be great. If its any help I attached my VI. Thanks.

0 Kudos
Message 6 of 78
(19,391 Views)

Virtuabotix,

I'm a bit confused with the DHT working Arduino code.  I see that you are reading in bits from the sensor into an array of U8's.  Then, you assign a single U8 to a float variable?  Does that mean that 8 bits are formatted as a floating point number from the sensor already?

reillyc,

I am working on this but as you can see I don't quite understand anything.  So, the earlier that he explains how the data works, the sooner I will be able to get this done.

0 Kudos
Message 7 of 78
(19,391 Views)

Ok, so I wrote up the custom firmware and a LabVIEW function for this.  I am not able to test so you will have to do it for me.

You will only need to initiate Arduino (no pin mode VIs) and then use my Read Data.vi to read the data.  However, you have to check for the case that the information fails to transmit successfully (due to timing issues with the sensor I believe), this is indicated by the "Success?" boolean output by the VI.

Let me know if it does or doesn't work and explain exactly what you tried.  Also, if you have trouble just writing a simple VI for it then I will do that later.

0 Kudos
Message 8 of 78
(19,391 Views)

Nathan,

Sorry for the delay in response, but I wanted to make sure I went through the routine in detail so as not to pass you, and the community innacurate information.

The one wire read() method in the DHT11 library from the Virtuabotix website communicates using pulsewidth modulation. The loopCnt while statements collect data from a pulse train of information retrieved from the DHT11. In total 5 Bytes are translated: byte[0] is the humidity, byte[2] is the temperature and byte[4] is the sum of the two (a checksum of sorts). I believe the remaining bytes are reserved for overflow of larger numbers for higher range versions.

For celcius the temperature and humidity percentage the data is stored as an integer with no decimal place. Only through built in conversions from one unit to another do the readings gain the decimal values.

I hope the information helps!

Respectfully,

Joseph Dattilo

Virtuabotix LLC

0 Kudos
Message 9 of 78
(19,391 Views)

Nathan,

I tried to upload the sketch for the firmware in arduino and these are the error messages that came up:

LabVIEWInterface.cpp:910:31: error: LabVIEWInterface.h: No such file or directory

LabVIEWInterface:66: error: expected constructor, destructor, or type conversion before '*' token

LabVIEWInterface.cpp: In function 'int checkForCommand()':

LabVIEWInterface:87: error: 'COMMANDLENGTH' was not declared in this scope

LabVIEWInterface:93: error: 'currentCommand' was not declared in this scope

LabVIEWInterface:95: error: 'currentCommand' was not declared in this scope

LabVIEWInterface.cpp: In function 'void processCommand(unsigned char*)':

LabVIEWInterface:309: error: 'servos' was not declared in this scope

LabVIEWInterface:310: error: 'Servo' was not declared in this scope

LabVIEWInterface:310: error: expected primary-expression before ')' token

LabVIEWInterface:310: error: expected `;' before 'malloc'

LabVIEWInterface:453: error: 'acqMode' was not declared in this scope

LabVIEWInterface:454: error: 'contAcqPin' was not declared in this scope

LabVIEWInterface:455: error: 'contAcqSpeed' was not declared in this scope

LabVIEWInterface:456: error: 'acquisitionPeriod' was not declared in this scope

LabVIEWInterface:457: error: 'iterationsFlt' was not declared in this scope

LabVIEWInterface:458: error: 'iterations' was not declared in this scope

LabVIEWInterface:463: error: 'delayTime' was not declared in this scope

LabVIEWInterface:473: error: 'FIRMWARE_MAJOR' was not declared in this scope

LabVIEWInterface:474: error: 'FIRMWARE_MINOR' was not declared in this scope

LabVIEWInterface:526: error: 'DHTLIB_OK' was not declared in this scope

LabVIEWInterface.cpp: In function 'void syncLV()':

LabVIEWInterface:713: error: 'DEFAULTBAUDRATE' was not declared in this scope

LabVIEWInterface.cpp: In function 'unsigned char checksum_Compute(unsigned char*)':

LabVIEWInterface:724: error: 'COMMANDLENGTH' was not declared in this scope

LabVIEWInterface.cpp: In function 'int checksum_Test(unsigned char*)':

LabVIEWInterface:735: error: 'COMMANDLENGTH' was not declared in this scope

LabVIEWInterface.cpp: In function 'void sampleContinously()':

LabVIEWInterface:776: error: 'iterations' was not declared in this scope

LabVIEWInterface:778: error: 'contAcqPin' was not declared in this scope

LabVIEWInterface:779: error: 'contAcqSpeed' was not declared in this scope

LabVIEWInterface:782: error: 'delayTime' was not declared in this scope

LabVIEWInterface:788: error: 'delayTime' was not declared in this scope

LabVIEWInterface.cpp: In function 'void finiteAcquisition(int, float, int)':

LabVIEWInterface:795: error: 'acquisitionPeriod' was not declared in this scope

LabVIEWInterface.cpp: In function 'void loop()':

LVIFA_Base:62: error: 'acqMode' was not declared in this scope

I also tried adding on your modifications of the Interface and Base firmware into the existing LVIFA in place of the existing Interface and Base and got multiple error messages with that as well.

0 Kudos
Message 10 of 78
(19,391 Views)