LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Data acquisition of NTC 10K, Humidity sensor(DHT 11) and pressure sensor(BMP 180) in LabVIEW

Good Evening,

I am using 4 temperature sensor(NTC 10K, Picture attached). 1 humidity sensor(DHT 11, Picture attached) and Pressure sensor (BMP 180, Picture attached).  I am accessing the data in Labview through Arduino nano. I have code and labview file for this. but i am not getting accurate value.

 

Note- for temperature sensor i have used NTC 100K also, but didnt get proper values. and arduino code in in text file.

 

 

 

Thank you in advance

Download All
0 Kudos
Message 1 of 8
(944 Views)

#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BMP085.h>
#include <DHT.h>

// NTC sensor pins
const int ntcPin1 = A0;
const int ntcPin2 = A1;
const int ntcPin3 = A2;
const int ntcPin4 = A3;

// BMP180 sensor
Adafruit_BMP085 bmp;

// DHT11 sensor
#define DHTPIN 4
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);

void setup() {
Serial.begin(9600);

if (!bmp.begin()) {
Serial.println("Could not find a valid BMP180 sensor, check wiring!");
while (1);
}

dht.begin();
}

void loop() {
// Read temperatures from NTC sensors
float temperature1 = readTemperature(ntcPin1);
float temperature2 = readTemperature(ntcPin2);
float temperature3 = readTemperature(ntcPin3);
float temperature4 = readTemperature(ntcPin4);

// Read pressure from BMP180 sensor
float pressure = bmp.readPressure() / 100.0; // Convert Pa to hPa

// Read humidity from DHT11 sensor
float humidity = dht.readHumidity();

// Print sensor values to serial monitor
Serial.print("Pressure:");
Serial.print(pressure);
Serial.println("hPa");

Serial.print("Humidity:");
Serial.print(humidity);
Serial.println("%");

Serial.print("Temperature 1:");
Serial.print(temperature1);
Serial.println("°C");

Serial.print("Temperature 2:");
Serial.print(temperature2);
Serial.println("°C");

Serial.print("Temperature 3:");
Serial.print(temperature3);
Serial.println("°C");

Serial.print("Temperature 4:");
Serial.print(temperature4);
Serial.println("°C");

 

//delay(1000); // Adjust delay as needed
}

float readTemperature(int ntcPin) {
// Implement the logic for reading temperature from the NTC sensor
// Replace this with your specific code or function
// You can use the same convertToTemperature function from the previous example

// For example, using the function from the previous example:
int adcValue = analogRead(ntcPin);
return convertToTemperature(adcValue);
}

float convertToTemperature(int adcValue) {
// Replace the parameters below with the characteristics of your NTC sensor
float referenceResistance = 10000.0; // Resistance of the NTC at the reference temperature (in ohms)
float referenceTemperature = 25.0; // Reference temperature (in degrees Celsius)
float betaValue = 3950.0; // Beta value of the NTC

// Calculate the resistance of the NTC based on the measured ADC value
float resistance = referenceResistance * (1023.0 / adcValue - 1.0);

// Calculate the temperature using the Steinhart-Hart equation
float temperature = 1.0 / (1.0 / (referenceTemperature + 273.15) + (1.0 / betaValue) * log(resistance / referenceResistance));
temperature -= 273.15; // Convert temperature to degrees Celsius

return temperature;
}

0 Kudos
Message 2 of 8
(938 Views)

Hi Alien,

 


@AlienVi6789 wrote:

but i am not getting accurate value.


What do you get and what do you expect?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 3 of 8
(909 Views)

I want temperature value from 0 to 100 celcius but I am getting temperature from 21 to 100 celcius.

And one more thing, can I do everything from LabVIEW, if I don't want to code from LabVIEW for all sensors.

0 Kudos
Message 4 of 8
(901 Views)

Hi Alien,

 


@AlienVi6789 wrote:

I want temperature value from 0 to 100 celcius but I am getting temperature from 21 to 100 celcius.


Debug your Arduino code as in there the data is measured and scaled!

 


@AlienVi6789 wrote:

can I do everything from LabVIEW, if I don't want to code from LabVIEW for all sensors.


As LabVIEW is a programming language you can do (almost) anything "from" LabVIEW!

What do you mean by "don't want to code from LabVIEW for all sensors"???

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 5 of 8
(891 Views)

I am saying if I don't want to code from Arduino ide and do everything from LabVIEW only. Can I do that?

Please help me on that.

0 Kudos
Message 6 of 8
(863 Views)

Hi Alien,

 

using the Arduino IDE gives you much more options than using LabVIEW+Hobbyists toolkit...

 

When the Hobbyist toolkit supports ALL of your requirements then you can try to use that and create your program only with LabVIEW.

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 7 of 8
(842 Views)

There are VI's in the Hobbyist Toolkit (LINX) that directly support reading a 10K thermistor and there are VI's for reading devices on the I2C bus.

 

So you could do this entire project in LabVIEW

 

In general there are three ways of using LabVIEW with an Arduino

 

  1. Program the Arduino in the native Arduino language.
    1. LabVIEW can communicate with an Arduino using VISA just like any other instrument on a serial port.
    2. IMHO: this is the best way as you have full control over the communications protocol and access to all of the of Arduino libraries and LabVIEW toolkits that are already out there.
    3. I highly recommend watching this video on serial communications: VIWeek 2020/Proper way to communicate over serial
  2. Use LINX (Now called the Hobbyist Toolkit) 
    1. Full LabVIEW integration, but limited amount of Arduino libraries and peripherals directly supported
    2. The Arduino basically becomes a tethered DAQ device that needs to be connected to a computer/LabVIEW to work
  3. TSXperts Arduino compiler for LabVIEW
    1. Actually turns LabVIEW into compiled Arduino code. (A real feat on its own)
      1. Limited subset of LabVIEW vi's and primitives
      2. Very limited support for Arduino libraries 
      3. Development seems to have stopped, so those annoying bugs are here to stay

 

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 8 of 8
(814 Views)