Post topics, source code that relate to the Arduino Platform

User avatar
By loyaproject
#25177 Hello,
i try to send data with my esp8266 with UDP protocol.
it say send ok but i receive no data on maxmsp on my other computer.
but i can send data with maxmsp and it work fine.
can anyone help please.
here is my code
Code: Select all#include <SoftwareSerial.h>

SoftwareSerial ESP8266(10, 11);

String NomduReseauWifi = "myssid";
String MotDePasse      = "mypassword";

/****************************************************************/
/*                             INIT                             */
/****************************************************************/
void setup()
{
  Serial.begin(9600);
  ESP8266.begin(9600); 
  initESP8266();
  envoiTcp();
}
/****************************************************************/
/*                        BOUCLE INFINIE                        */
/****************************************************************/
void loop()
{
   while(ESP8266.available())
   {   
     Serial.println(ESP8266.readString());
   }   
}
/****************************************************************/
/*                Fonction qui initialise l'ESP8266             */
/****************************************************************/
void initESP8266()

  Serial.println("**********************************************************"); 
  Serial.println("**************** DEBUT DE L'INITIALISATION ***************");
  Serial.println("**********************************************************"); 
  envoieAuESP8266("AT+RST");
  recoitDuESP8266(2000);
  Serial.println("**********************************************************");
  envoieAuESP8266("AT+CWMODE=3");
  recoitDuESP8266(5000);
  Serial.println("**********************************************************");
  envoieAuESP8266("AT+CWJAP=\""+ NomduReseauWifi + "\",\"" + MotDePasse +"\"");
  recoitDuESP8266(10000);
  Serial.println("**********************************************************");
  envoieAuESP8266("AT+CIFSR");
  recoitDuESP8266(1000);
  Serial.println("**********************************************************");
  envoieAuESP8266("AT+CIPMUX=1");   
  recoitDuESP8266(1000);
  Serial.println("**********************************************************");
  envoieAuESP8266("AT+CIPSERVER=1,80");
  recoitDuESP8266(1000);
  Serial.println("**********************************************************");
  Serial.println("***************** INITIALISATION TERMINEE ****************");
  Serial.println("**********************************************************");
  Serial.println(""); 
}
void envoiTcp(){

 envoieAuESP8266("AT+CIPSTART=4,\"UDP\",\"192.168.0.13\",8000");
 recoitDuESP8266(1000);
 envoieAuESP8266("AT+CIPSEND=4,18");
 recoitDuESP8266(1000);
 envoieAuESP8266("GET /THEAP/1.0");
 recoitDuESP8266(1000);
 envoieAuESP8266("");
 recoitDuESP8266(1000);
 
 
 
}

/****************************************************************/
/*        Fonction qui envoie une commande à l'ESP8266          */
/****************************************************************/
void envoieAuESP8266(String commande)

  ESP8266.println(commande);
 
  //Serial.println(commande.length());
}
/****************************************************************/
/*Fonction qui lit et affiche les messages envoyés par l'ESP8266*/
/****************************************************************/
void recoitDuESP8266(const int timeout)
{
  String reponse = "";
  long int time = millis();
  while( (time+timeout) > millis())
  {
    while(ESP8266.available())
    {
      char c = ESP8266.read();
      reponse+=c;
    }
  }
  Serial.print(reponse);   
}



User avatar
By GigAHerZ
#25272
AcmeUK wrote:Hi loyaproject

Is your code correct? You have
"AT+CIPSTART=4,\"UDP\",\"192.168.0.13\",8000"

Whereas Espressif give this example
AT+CIPSTART=4,"UDP","192.168.101.110",8080


He's escaping double-quote. It's correct, so no fault at there at least.
User avatar
By AcmeUK
#25278
He's escaping double-quote.
OK.

So loyaproject, it looks to me that you are using port 8000 for UDP communication. Just a couple of thoughts:-

1, Is your UDP receiver listening on port 8000?
2, Is there another service on your UDP receiver that has 'grabbed' port 8000?

I have UDP send working fine between ESP8266 and a Python script using port 5000, but I am not using AT commands.

I also have a NTP script running which uses UDP, but again not using AT commands.