Jump to content
  • 0

need advice


mustafasei

Question

Hi

 I'm new user for Labview and arduino and recently start to use the arduino with labview via Linx firmware and labview 2013 and doing some small projects or experiments but i have some difficulties with some sensors of arduino which i have it now the 37 kit like the 18B20 and DHT11 and so.

I have no idea about the arduino programming language C++ which is I'm totally far away from it.

i need your support for how to define some of the arduino sensors to be known in labview menu  like (makerhub-linx-sensors-temp-tmp3x)

i have searched in makerhub forums and got answer that i have to use the custom command which is something i cannot use due to my poor ability in C++.

 

please advise

Link to comment
Share on other sites

19 answers to this question

Recommended Posts

Once you have the "Arduino_Uno_Serial" example opened go to Sketch-> Include Library->Manage libraries. In the library manager search "DHT sensor library", once it comes up click on it and then select the install button that pops up. After it is installed restart Arduino IDE and then reopen "Arduino_Uno_Serial"

Now click File-> save as and then save it with a name like "DHT". This way you don't make any changes to the template. 

Once your new file is opened add the DHT library by putting 

#include <DHT.h> 

Screen Shot 2016-10-05 at 12.57.22 PM.png

Then add 

int dht();

Screen Shot 2016-10-05 at 12.57.42 PM.png

Next add the following code to the setup() function to attach the custom command to the LINX listener (in this case called LinxSerial connection)

 LinxSerialConnection.AttachCustomCommand(2, dht);

Screen Shot 2016-10-05 at 12.58.25 PM.png

Finally at the bottom of the firmware, after the void loop, add your custom function. The custom function that will work with "LINX interactions DHT11.vi" example in Labview is pasted below. 

int dht(unsigned char numInputBytes, unsigned char* input, unsigned char* numResponseBytes, unsigned char* response)
{
  if (numInputBytes != 1)
  {
    return 1;
  }

  DHT dht(input[0], DHT11);

  dht.begin();
  delay(1000);

  unsigned char h = dht.readHumidity();
  // Read temperature as Celsius (the default)
  unsigned char t = dht.readTemperature();
  // Read temperature as Fahrenheit (isFahrenheit = true)
  unsigned char f = dht.readTemperature(true);

  // Check if any reads failed and exit early (to try again).
  if (isnan(h) || isnan(t) || isnan(f)) {
    return 1;
  }

  unsigned char hif = dht.computeHeatIndex(f, h);
  // Compute heat index in Celsius (isFahreheit = false)
  unsigned char hic = dht.computeHeatIndex(t, h, false);

  response[0] = h;
  response[1] = t;
  response[2] = f;
  response[3] = hic;
  response[4] = hif;

  *numResponseBytes = 5;

  return 0;
}

Screen Shot 2016-10-05 at 12.59.29 PM.png

I have attached my code as well so you can copy and paste from there or use it if you would like. Once you are finished, upload the code to your board and then you will be able to use the LINX DHT11 example. 

DHT_example.ino

 

Link to comment
Share on other sites

Ok so I am going to walk you through the process of writing a custom command for the DHT11.

Before we start 

1) Generated the LINX firmware libraries in the appropriate location for Arduino IDE

  • do this by opening LabVIEW and under the Tools tab go to MakerHub –> LINX –> Generate Firmware Libraries

 

2) Then restart arduino IDE and then in the arduino IDE open the LINX example for the Arduino uno

  • This will open us a template for making a custom command

Once you have done that I will tell you how you can modify it to use it with the DHT11

 

Link to comment
Share on other sites

Have you gotten the Interactions DHT to work yet?

If not here are a few things you should do

  • Make sure you are using the right COM port 
  • Make sure you have the correct DHT data pin selected
    • Maybe try a few different pins 
  • Use LINX firmware wizard to reload LINX firmware onto your board

Try these things and let me know what happens, you shouldn't need to paste your code anywhere to make this VI work. 

 

Link to comment
Share on other sites

 

 

13 hours ago, AustinStanton said:

Actually, the DHT11 already has a Sub Vi. Open LabVIEW and go to Help>Find Examples and search DHT11, "LINX- Interactions DHT11.vi" will pop up. That is an example showing you how to read the DHT11 sensor. From the block diagram of a VI you can find the Read block for the DTH11 by right clicking to open the functions palette and then selecting Makerhub>LINX>Sensors>Digilent>Interactions>DHT11 Read. 

 Which other sensors do you need help with? 

 

13 hours ago, AustinStanton said:

I found the DHT11.vi  in the examples and run it but i got the error message as attached ,and regarding the function palette I didnt found the Digilent>interaction>DHT11 Read 

any advice  

13 hours ago, AustinStanton said:

Actually, the DHT11 already has a Sub Vi. Open LabVIEW and go to Help>Find Examples and search DHT11, "LINX- Interactions DHT11.vi" will pop up. That is an example showing you how to read the DHT11 sensor. From the block diagram of a VI you can find the Read block for the DTH11 by right clicking to open the functions palette and then selecting Makerhub>LINX>Sensors>Digilent>Interactions>DHT11 Read. 

 Which other sensors do you need help with? 

Hi

 Thank you for your replay, I'm still struggle for building a custom command due to my very poor experience in C++.

I have seen the makerhub which you send to me many times but I have no idea how to copy and paste my codes of arduino sensors which i have in my 37 sensor kit

so let us say in this way :

if i have the below code for the DHT11:

(

#include <dht.h>
 

 
#define dht_apin A0 // Analog Pin sensor is connected to
 
dht DHT;

 

void setup(){
 
  Serial.begin(9600);
 
  delay(500);//Delay to let system boot
 
  Serial.println("DHT11 Humidity & temperature Sensor\n\n");
 
  delay(1000);//Wait before accessing Sensor
 
}//end "setup()"

 

 
void loop(){
 
  //Start of Program
 
  DHT.read11(dht_apin);

 

 
    Serial.print("Current humidity = ");
 
    Serial.print(DHT.humidity);
 
    Serial.print("%  ");
 
    Serial.print("temperature = ");
 
    Serial.print(DHT.temperature);
 
    Serial.println("C  ");
 
  delay(5000);//Wait 5 seconds before accessing sensor again.
 
  //Fastest should be once every two seconds.
 
}// end loop()


)

where shall i past the above code on what has explained in makerhub website for how to create the custom command

thanx

 

Erro 1.png

Link to comment
Share on other sites

First make sure to generate the LINX firmware libraries in the appropriate location for your device's IDE by opening LabVIEW and under the Tools tab go to MakerHub –> LINX –> Generate Firmware Libraries. Then restart arduino IDE and then in the arduino IDE open the LINX example for the device and interface you're using. (ex. File»Examples»LINX»Arduino_Uno_Serial). This will open up a template for making a custom command. The Makerhub link I sent you goes over the basics of where things go but I have attached an example of a custom DHT11 command, this command was written for the WF32 so the beginning will be different because it calls different libraries but it will help you understand where the custom code goes. 

Let me know if you have any more questions

 

DHT.ino

Link to comment
Share on other sites

Hi

 Thank you for your replay, I'm still struggle for building a custom command due to my very poor experience in C++.

I have seen the makerhub which you send to me many times but I have no idea how to copy and paste my codes of arduino sensors which i have in my 37 sensor kit

so let us say in this way :

if i have the below code for the DHT11:

(

#include <dht.h>
 

 
#define dht_apin A0 // Analog Pin sensor is connected to
 
dht DHT;

 

void setup(){
 
  Serial.begin(9600);
 
  delay(500);//Delay to let system boot
 
  Serial.println("DHT11 Humidity & temperature Sensor\n\n");
 
  delay(1000);//Wait before accessing Sensor
 
}//end "setup()"

 

 
void loop(){
 
  //Start of Program
 
  DHT.read11(dht_apin);

 

 
    Serial.print("Current humidity = ");
 
    Serial.print(DHT.humidity);
 
    Serial.print("%  ");
 
    Serial.print("temperature = ");
 
    Serial.print(DHT.temperature);
 
    Serial.println("C  ");
 
  delay(5000);//Wait 5 seconds before accessing sensor again.
 
  //Fastest should be once every two seconds.
 
}// end loop()


)

where shall i past the above code on what has explained in makerhub website for how to create the custom command

thanx

 

Link to comment
Share on other sites

Actually, the DHT11 already has a Sub Vi. Open LabVIEW and go to Help>Find Examples and search DHT11, "LINX- Interactions DHT11.vi" will pop up. That is an example showing you how to read the DHT11 sensor. From the block diagram of a VI you can find the Read block for the DTH11 by right clicking to open the functions palette and then selecting Makerhub>LINX>Sensors>Digilent>Interactions>DHT11 Read. 

 Which other sensors do you need help with? 

Link to comment
Share on other sites

https://www.labviewmakerhub.com/doku.php?id=learn:tutorials:libraries:linx:misc:adding_custom_command

That is a walkthrough showing how to add a custom command 

http://playground.arduino.cc/Main/DHT11Lib

That link will take you to a bunch of example code for the DHT11Lib 

https://blog.digilentinc.com/how-to-use-linx-custom-commands/

Finally this link is a blog post called "How to use LINX Custom Commands" 

Let me know if you have any problems figuring things out

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...