簡體   English   中英

從Nodmcu發送傳感器數據到labview

[英]Send sensor data from Nodmcu to labview

我想將傳感器數據(如 DHT)從 NODEMCU 發送到 LABVIEW。 有沒有圖書館或草圖可以做到這一點? NODEMCU 以站點模式連接到網絡。 在labview中,我必須使用哪個庫來做到這一點?

已解決: 1. 在 Arduino IDE 中試試這個庫:ESP8266WiFi.h

主機是你的電腦,比如 192.168.1.11

端口:550(例如)

#include <ESP8266WiFi.h>
const char* ssid     = "xxxx";      // SSID
const char* password = "xxxx";      // Password
const char* host = "xxx.xxx.xxx.xxx";  // Server IP
const int   port = 550;            //  Server Port
const int   watchdog = 5000;        // Watchdog frequency

unsigned long previousMillis = millis(); 

void setup() {
  Serial.begin(115200);
  Serial.print("Connecting to ");
  Serial.println(ssid);

  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }

  Serial.println("");
  Serial.println("WiFi connected");  
  Serial.println("IP address: ");
  Serial.println(WiFi.localIP());
}

void loop() {
  unsigned long currentMillis = millis();

  if ( currentMillis - previousMillis > watchdog ) {
    previousMillis = currentMillis;
    WiFiClient client;

    if (!client.connect(host, port)) {
      Serial.println("connection failed");
      return;
    }

    String url = "/watchdog?command=watchdog&uptime=";
    url += String(millis());
    url += "&ip=";
    url += WiFi.localIP().toString();

    // Envoi la requete au serveur - This will send the request to the server
    client.print(String("GET ") + url + " HTTP/1.1\r\n" +
               "Host: " + host + "\r\n" + 
               "Connection: close\r\n\r\n");
    unsigned long timeout = millis();
    while (client.available() == 0) {
      if (millis() - timeout > 5000) {
        Serial.println(">>> Client Timeout !");
        client.stop();
        return;
      }
    }

    // Read all the lines of the reply from server and print them to Serial
    while(client.available()){
      String line = client.readStringUntil('\r');
      Serial.print(line);
    }
  }
}

2. labview :你需要2個塊來做到這一點:

TCP監聽

TCP讀

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM