Real-Time Measurement and Control

cancel
Showing results for 
Search instead for 
Did you mean: 

LabView accessing ESP8266 TCP/IP server

Solved!
Go to solution

Hi everybody!

I am doing a Artifical Inteligence System and it need to be monitorated over Wifi. I am using a ESP8266 12 to create a TCP/IP server. To test the server, I have send the data to port 80 and visualize it by google chrome, the string appears correctly. The problem appears when I try to requisite the data via TCP/IP cliente in LabView. I have tryed a large number of ports and the same thing happens: the activity light of ESP turns on when LabView try to begin a comunication and when timeout ocurred. I am a dumb on networking comunication and because of this I am having a lot of trouble in the comunication. Someone have some ideia how to solve this? Thanks.

0 Kudos
Message 1 of 13
(17,019 Views)

Hello,

 

I see that you already tested some code made by your own, for this test I suggest to use as guideline those options:

 

  1. See the TCP connection project in Example Finder going to: LabVIEW>Help>Find Examples> 'Search' Tab>  open the 'Simple TCP';
  2. Basic TCP/IP Communication in LabVIEW - National Instruments
    http://www.ni.com/white-paper/2710/en/

There other remaining information about the ESP8266 specifically that might help you too:

 

  1. How to communicate between Arduino Mega and Labview using ESP8266 Wifi Module? - Discussion Forums - National Instruments
    http://forums.ni.com/t5/LabVIEW/How-to-communicate-between-Arduino-Mega-and-Labview-using/m-p/325672...
  2. LabVIEW MakerHub • View topic - ESP8266 support for Arduino with LABVIEW
    https://www.labviewmakerhub.com/forums/viewtopic.php?f=12&t=1099

 

Gabriel Ferreira

National Instruments Brazil

ni_logo.jpg

0 Kudos
Message 2 of 13
(16,960 Views)
Solution
Accepted by topic author Hawk1705

I have discovered the problem. When you configure ESP8266 to act as a server, it only accept HTTP requests, so, a TCP/IP conection will get nothing. You need the block GET from HTTP Palette, so you can comunicate ESP with LabView.

Message 3 of 13
(16,945 Views)

Wave can send program (vi) to receive data from esp8266 ?

0 Kudos
Message 4 of 13
(15,647 Views)

Hi,

Need help in connecting esp266 to linx with arduino.
How to deploy code into arduino like upload sketch in Arduino IDE??

Thanks

Thanks & Regards,
Bharath Kumar
GCentral
Message 5 of 13
(13,765 Views)

Hi, I'm doing a project that need to do a networking comunication Node MCU/ESP8266 with LabVIEW. Do you can help me with a tutorial or you send your job for I get how a reference to my job. I'm young in jobs with networking comunication. And I don't see many information about this specific subject. 

 

Since now, thank you!

 

You can send a e-mail if you to prefer.

 

e-mail: eniovieiraa@gmail.com

0 Kudos
Message 6 of 13
(12,469 Views)

Hi, Enio.

 

I don’t know much about ESP8266 but I can try to help you with the LabVIEW part.

Take a look at the example Simple UDP.lvproj from LabVIEW (LabVIEW >> Example Finder >> UDP >> Simple UDP.lvproj). I believe that can help you to stablish a communication.

 

Also, what version of LabVIEW are you using? Do you have LINX installed as well?

Could you tell me more about your application so I can help you more?

 

Best Regards,

Lígia T. Ferreira
Technical Support Engineer
National Instruments Brazil

0 Kudos
Message 7 of 13
(12,278 Views)

Oi, vou escrever aqui em português para melhor entendimento, porque vi que você é brasileira também, e o assunto é técnico.

Estou usando o módulo Node MCU ESP 8266 para fazer a leitura analógica de um sinal que possui componentes de até 40 Hz de um sinal de eletroencefalograma para um trabalho de iniciação científica da universidade. O problema que falei acima consegui resolver ele acrescentando um delay no código. Desta forma, o módulo é programado para servir como ponto de acesso onde o meu computador (cliente) acessa usando o protocolo TC/IP. Assim quando um cliente acessa meu módulo, o mesmo passa a enviar as informações que serão recebidas pelo computador. Fiz um programa no Labview para receber essas informações e mostrar os dados brutos num gráfico, mas preciso aplicar alguns filtros digitais neste software e avaliar o espectro de freqüência deste sinal. Vou colocar aqui tanto meu código em linguagem arduino que programei o módulo, quanto o .VI para você entender melhor. Você deu idéia de usar um protocolo UDP mas não conseguir programar meu módulo para usar esse protocolo.

A forma como eu reduzi a taxa de amostragem acho que não é a da mais elegante, mas não consegui achar outra forma que eu pudesse, por exemplo, mudar o prescaler que faz mudar a taxa de amostragem desse módulo. Vou postar uma figura de um sinal senoidal mostrado no gráfico do LabView antes de eu colocar o delay. E com o delay a forma está sem esses cortes na senoide, ou seja, está mostrando uma senoide normal.

Pelo o que pesquisei e conversei com alguns professores, a taxa de amostragem estava muito alta, assim, caso algum pacote de dados não fosse enviado corretamente o módulo não tinha tempo suficiente para reenviar o pacote e receber os novos dados para um novo pacote de dados. Então começava dar erro e cortar o sinal no gráfico.

Agora o problema está em aplicar alguns filtros digitais neste software e avaliar o espectro de freqüência deste sinal. Pelo o que entendi do LabView, para realizar essas tarefas o sinal precisa ter uma taxa de amostragem do sinal fixa. Então fiz uma pequena rotina para ver se pelo menos a taxa de amostragem do sinal pelo módulo era constante e verifiquei que já ali não era. Vi leituras de tempo entre 160 us até 180 us entre uma amostra e outra. Acho que no envio das informações pode ocorrer alguma variação e até no LabView alguma variação nesses valores, tomara que eu esteja enganado.

Para tentar resolver esse problema tentei usar alguns blocos do LabView que pudessem me auxiliar na resolução deste problema e foram basicamente 3: Build Waveform, Align and Resample Express VI, Resample Waveforms (single shot). Minha idéia foi reconstruir minha forma de onda com uma taxa de amostragem pré-determinada por mim. Mas acho que não sei usar essas ferramentas corretamente. Tentei de várias maneiras e infelizmente não obtive êxito.

 

O código do meu programa em liguagem arduino foi:

 

#ifdef ESP8266//Se estiver usando ESP8266, automáticamente irá adicionar as bibliotecas do ESP8266.
#include <ESP8266WiFi.h>
#include <WiFiServer.h>
#elif defined ESP32//Se estiver usando ESP32, fara a mesma operaçao.
#include <WiFi.h>
#endif

 

WiFiServer sv(555);//Cria o objeto servidor na porta 555
WiFiClient cl;//Cria o objeto cliente.
String sendData();
String strin_analog, zzz = "000",zz = "00",z = "0";

int input_pin = A0, B;

void setup()
{
Serial.begin(115200);//Habilita a comm serial.

WiFi.mode(WIFI_AP);//Define o WiFi como Acess_Point.
WiFi.softAP("NodeMCU", "");//Cria a rede de Acess_Point.
sv.begin();//Inicia o servidor TCP na porta declarada no começo.

delay(10);
}

void loop()
{
if (cl.connected())//Detecta se há clientes conectados no servidor.
{
while(cl.connected())
{

/*avalia se a string tem 3, 2, ou 1 charactere,
* em qualquer dos casos abaixo serao acrescentados zeros
* á esquerda para completar 4 characteres*/

strin_analog = String (analogRead(input_pin));

B = strin_analog.length();
switch(B)
{

case 1:
strin_analog = zzz + strin_analog;
break;

case 2:
strin_analog = zz + strin_analog;
break;

case 3:
strin_analog = z + strin_analog;
break;

}

cl.print(strin_analog);
Serial.println(strin_analog);
delay(4);
}
}
else//Se nao houver cliente conectado,
{
cl = sv.available();//Disponabiliza o servidor para o cliente se conectar.
delay(10);
}

}

Download All
0 Kudos
Message 8 of 13
(12,008 Views)

I'm using a module NodeMCU ESP8266 to do a analog read of a signal that have components from to 40 Hz of a signal of electroencephalogram to a job of scientific research of university. Was with a problem of cut of signal that I got to resolve adding a delay in the code. Thus, the module is programmed to serve as access point, where my computer (client) access using a TC/IP protocol. Thus, when a client access my module, the same send the data that will receive for my computer. I do a program on LabView to receive the data and show the same on graph, but I need to apply some digital filters in this software and to evaluate the frequency spectrum of this signal. I will put here both my code in arduino and the .VI to you understand best. I can use a UDP protocol, but I could not to program my module to use this protocol.

 

The way I managed to reduce the sampling rate isn't the best, but I could not find it other way that I could, for example, change the prescaler that change the sampling rate of this module. I will post a figure of a signal showing the LabView graph before I put the delay in arduino code. With the delay the waveform is without this cut in sine, that is, show a normal sine waveform.

 

For what I researched with some teachers, the sampling rate was very tall, thus, if any data package wasn't  send correctly the module wasn't have enough time to resend the package and receive the new data to a new data package. Thus began give to some mistakes and cut the graph signal.

 

Now, the problem is to apply some digital signals in this software and evaluate spectrum frequency of this signal. For what I understand of LabView software, to do this tasks the signal need to have a sampling rate fixed. Thus, I got a little routine to I see if at least the sampling rate of module waveform was constant and I see that already there wasn't.  I saw readings of time in between 160 us and 180 us between a sample and other without the delay of 4 ms that already in the code. I think in sending of data may occur some variation, and even in LabView some variation in this values, I hope I'm mistaken.

 

To try to resolve this problem I tried to use some LabView blocks that could help me in the resolution of this problem and was three: Build Waveform, Align and Resample Express VI, Resample Waveforms (single shot). My idea was to rebuild my waveform with a sampling rate pre-fixed for me. But I think that still do not know to use this tools correctly. I tried of many forms and unfortunately I didn't sucess.

 

The  link to download my program .VI and arduino program is:

 

https://drive.google.com/drive/folders/1_FItfUE8IW52u7Ec4WdggadKnMH7QR5O?usp=sharing

 

Can anyone help me solve this problem?

0 Kudos
Message 9 of 13
(11,996 Views)

Boa tarde, Enio.

 

Se eu entendi corretamente o seu desafio nesse momento é na utilização dos filtros no LabVIEW. Correto?

 

Vou sugerir que você dê uma olhada em um exemplo nativo do LabVIEW chamado Extract the Sine Wave. Você pode encontrá-lo em Find Examples >> Analysis, Signal Processing and Mathematics >> Filtering and Conditioning >> Extract the Sine Wave.vi

Esse exemplo utiliza uma função da Filters Palette chamada Butterworth Filter. O mais interessante para você nesse caso é que a informação pode ser passada como um número de ponto flutuante (dado double) e esse filtro é aplicado ponto a ponto. Ainda, mesmo que exista alguma alteração, o Sample Rate colocado aqui pode ser o esperado para a sua placa.

 

Existem outros exemplos para utilização de funções dessa paleta que você pode encontrar pelo Example Finder dentro da pasta Filtering and Conditioning. Mas acredito que esse seja um bom ponto para começar.

 

Me avise se funcionar.

Lígia T. Ferreira
Technical Support Engineer
National Instruments Brazil

0 Kudos
Message 10 of 13
(11,949 Views)