04-13-2024 01:04 AM
I am currently creating a tcp server vi to receive information data from a circuit with esp8266 and mpu6050 to display all 6 data parameters on one waveform chart. Firstly I programmed the esp8266 using the following code and a connection failed output:
04-13-2024 01:07 AM
I am currently creating a tcp server vi to receive information data from a circuit with esp8266 and mpu6050 to display all 6 data parameters on one waveform chart. Firstly I programmed the esp8266 using the following code and a connection failed output:
#include <ESP8266WiFi.h>
#include <Wire.h>
#include <Adafruit_MPU6050.h>
// Wi-Fi credentials
const char* ssid = "Galaxy A32960C";
const char* password = "sqzl3356";
// LabVIEW TCP server address and port
const char* serverAddress = "192.168.108.37"; // Change to your LabVIEW TCP server IP address
const int serverPort = 61762; // Change to your LabVIEW TCP server port
WiFiClient client;
Adafruit_MPU6050 mpu;
void setup() {
Serial.begin(115200);
delay(100);
// Connect to Wi-Fi
Serial.println();
Serial.println("Connecting to WiFi");
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("\nWiFi connected");
// Initialize MPU6050
if (!mpu.begin()) {
Serial.println("Sensor init failed");
while (1)
yield();
}
Serial.println("Found an MPU-6050 sensor");
}
void loop() {
// Read sensor data
sensors_event_t a, g, temp;
mpu.getEvent(&a, &g, &temp);
// Connect to the LabVIEW TCP server if not connected
if (!client.connected()) {
Serial.print("Connecting to ");
Serial.print(serverAddress);
Serial.print(" on port ");
Serial.println(serverPort);
if (client.connect(serverAddress, serverPort)) {
Serial.println("Connected to server");
} else {
Serial.println("Connection failed");
return;
}
}
// Format the data string
String dataToSend = String("AccelX:") + String(a.acceleration.x, 2) +
", AccelY:" + String(a.acceleration.y, 2) +
", AccelZ:" + String(a.acceleration.z, 2) +
", GyroX:" + String(g.gyro.x, 2) +
", GyroY:" + String(g.gyro.y, 2) +
", GyroZ:" + String(g.gyro.z, 2) +
", Temp:" + String(temp.temperature, 2);
// Send the data to LabVIEW
client.println(dataToSend);
// Debug message to verify data sent over network
Serial.print("Sent data to server: ");
Serial.println(dataToSend);
delay(1000); // Adjust delay as needed
}
04-13-2024 07:59 AM
I am currently creating a tcp server vi to receive data from a circuit with esp8266 and mpu6050 to display all of its 7 gait parameters on one waveform chart but keep getting errors. Please help
04-14-2024 03:27 PM
How to adjust this VI to read several parameters from an esp8266/mpu6050 circuit to display on one waveform chart via TCP.
04-14-2024 03:33 PM
How to modify this VI to display several gait parameters from an esp8266/mpu6050 circuit on one waveform chart via TCP?
04-14-2024 11:43 PM
Regarding multiple plots, this is from the LabVIEW Help:
Displaying Multiple Plots on Waveform Charts
To pass data for multiple plots to a waveform chart, you can bundle the data together into a cluster of scalar numeric values, where each numeric represents a single point for each of the plots.
If you want to pass multiple points per plot in a single update, wire an array of clusters of numeric values to the chart. Each numeric represents a single y value point for each of the plots.
You can use the waveform data type to create multiple plots on a waveform chart. Use the Build Waveform function to plot time on the x-axis of the chart and automatically use the correct interval between markers on the x-scale of the chart. A 1D array of waveforms that each specify t0 and a single-element Y array is useful for plotting data that is not evenly sampled because each data point has its own time stamp.
If you cannot determine the number of plots you want to display until run time, or you want to pass multiple points for multiple plots in a single update, wire a 2D array of numeric values or waveforms to the chart. By default, the waveform chart treats each column in the array as a single plot. Wire a 2D array data type to the chart, right-click the chart, and select Transpose Array from the shortcut menu to treat each row in the array as a single plot.
Refer to the labview\examples\Controls and Indicators\Graphs and Charts\Waveform Graphs and Charts\Waveform Graphs and Charts.lvproj for examples of the waveform chart.
What error do you get for the TCP connection?
You cannot use TCP read with bytes to read <0. That part is also mentioned in the other thread. Use CRLF mode with a sufficient byte count as mentioned before.
The scan from string format string does not match the format you send from arduino.
(You can create a snippet by selecting the relevant block diagram parts and choosing Edit->Create Snipped from Selection)
04-15-2024 01:21 AM - edited 04-15-2024 01:27 AM
Hi John,
@StephenJohn wrote:
How to adjust this VI to read several parameters from an esp8266/mpu6050 circuit to display on one waveform chart via TCP.
Apparently this VI will do just that…
Do you have any specific problems with this VI?
Please stop asking the same question in several threads: stick with your own thread and keep information in one place!
04-15-2024 02:48 PM
I used this VI to display multiplots on the waveform chart of the data but error 85 came up. The data is in this format: 1.2,1.4,1.5,5.7,4.6,6.5,7.8.
04-16-2024 12:09 AM
Can you show what is received by TCP read? Probe the wire or add a string indicator.
05-09-2024 11:59 PM
Good day,
Please note that the data received by the tcp read is in this format: .0,0.0,0.0,0.0,0.0,0.0,36.5. And the error 85 keeps showing up. Please help.