jmed87
November 7, 2018, 2:59pm
1
Hi,
I'm pretty new to coding c++ and am not really sure where to go from this problem I am having. I'm trying to display my string data into arrays and graphs but it isn't work quite right in LabVIEW. My string is reading but not into the array. I went to the LabVIEW forums and someone suggested;
"to read all of the sensor data and put it in variables. Then use a single Serial.println() command to format and write the data. I would separate your readings with a tab. Then it is simple enough to use the Spreadsheet String To Array on your read line to get all of your values."
I'm not really sure what to do here. I'll post my original code. Any help would be appreciated.
Best,
Josh
temp sensor code.txt (2.31 KB)
Post you Arduino code for a start, using code tags when you do
jmed87
November 7, 2018, 3:14pm
3
I attached it but here you go...
// This Arduino sketch reads DS18B20 "1-Wire" digital
// temperature sensors.
// Tutorial:
// http://www.hacktronics.com/Tutorials/arduino-1-wire-tutorial.html
#include <OneWire.h>
#include <DallasTemperature.h>
// Data wire is plugged into pin 3 on the Arduino
#define ONE_WIRE_BUS 6
// Setup a oneWire instance to communicate with any OneWire devices
OneWire oneWire(ONE_WIRE_BUS);
// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);
// Assign the addresses of your 1-Wire temp sensors.
// See the tutorial on how to obtain these addresses:
// http://www.hacktronics.com/Tutorials/arduino-1-wire-address-finder.html
DeviceAddress Sensor01 = { 0x28, 0xDE, 0x7B, 0x50, 0x2F, 0x14, 0x01, 0x4E };
DeviceAddress Sensor02 = { 0x28, 0x29, 0x29, 0x4B, 0x2F, 0x14, 0x01, 0x03 };
DeviceAddress Sensor03 = { 0x28, 0xED, 0x56, 0x69, 0x2F, 0x14, 0x01, 0x35 };
DeviceAddress Sensor04 = { 0x28, 0x6E, 0x4C, 0x68, 0x2F, 0x14, 0x01, 0xC8 };
DeviceAddress Sensor05 = { 0x28, 0x4B, 0xA6, 0x5E, 0x2F, 0x14, 0x01, 0xB3 };
void setup(void)
{
// start serial port
Serial.begin(9600);
// Start up the library
sensors.begin();
// set the resolution to 10 bit (good enough?)
sensors.setResolution(Sensor01, 10);
sensors.setResolution(Sensor02, 10);
sensors.setResolution(Sensor03, 10);
sensors.setResolution(Sensor04, 10);
sensors.setResolution(Sensor05, 10);
}
void printTemperature(DeviceAddress deviceAddress)
{
float tempC = sensors.getTempC(deviceAddress);
if (tempC == -127.00) {
Serial.print("Error getting temperature");
} else {
Serial.print("C: ");
Serial.print(tempC);
Serial.print(" F: ");
Serial.print(DallasTemperature::toFahrenheit(tempC));
}
}
void loop(void)
{
delay(2000);
Serial.print("Getting temperatures...\n\r");
sensors.requestTemperatures();
Serial.print("Sensor01 is: ");
printTemperature(Sensor01);
Serial.print("\n\r");
Serial.print("Sensor02 is: ");
printTemperature(Sensor02);
Serial.print("\n\r");
Serial.print("Sensor03 is: ");
printTemperature(Sensor03);
Serial.print("\n\r");
Serial.print("Sensor04 is: ");
printTemperature(Sensor04);
Serial.print("\n\r");
Serial.print("Sensor05 is: ");
printTemperature(Sensor05);
Serial.print("\n\r");
}
What do you see in the Serial monitor when you run the program ?
jmed87
November 7, 2018, 4:17pm
5
Attaching the file below.
It reads fine but it won't translate to an array or a graph.
Is that screenshot from Labview or Arduino ?
jmed87
November 7, 2018, 5:43pm
7
Labview; it is essentially the same in the serial monitor for Arduino.
Attaching a snip.
So the data gets yo Labview but is not stored in an array in Labview.
What format of data is Labview expecting ?
You are certailny not doing as was suggested and separating the data with tabs. To output a tab in Arduino use
Serial.print("\t");
jmed87
November 7, 2018, 6:01pm
9
Thanks for telling me how to separate it by tabs.
I think the data is 1D?
I think the data is 1D?
Sorry, but I don't understand
Do you mean one dimension ?
jmed87
November 7, 2018, 7:18pm
11
I'm not sure if you are familiar with LabVIEW but this is what the code is. I've changed the semicolon (delimeter).