![]() WiFiUdp.h - Library for Arduino Wifi shield.Ĭopyright (c) 2011-2014 Arduino LLC. You can see the WiFiUdp.write() method documented here: esp8266/Arduino/blob/master/libraries/ESP8266WiFi/src/WiFiUdp.h /* Now, why would the Serial.readString() be the problem since it has worked with my phone in the first place? just asking to understand.Īnother things, I am very new to this, what do you mean by debug statement? Here is the deal: the Udp.write("tosend") works with both receivers (phone and ESP32) however the Udp.write(tosend) works with only my phone. Udp.write(tosend, 20) otherwise it assumes the argument is one byte long. The first thing to check with debug statements is if this actually worked.įurther, the Udp.write(tosend) statement requires a length in bytes e.g. ![]() Incidentally, Serial.readString() times out after 1 second (by default) so there may be a good chance that at the time it executed, no data was available. This line of code has a good chance of working : Udp.write("tosend") Ī) because it is a well formed cstring literal which will automatically have a null terminating character to mark its end.ī) because its value does not have to be fetched from somewhere like your Udp.write(tosend) which attempts to get a value indirectly from Serial.readString() Going back to the problem you mentioned at the beginning: It is not really clear from your various code snippets where they are running and what their target is. You cannot, however, send UDP packets from an ESP32 to your phone ? Have I got this correct: You can successfully send UDP packets from an ESP8266 to your phone. You have now mentioned a phone, an ESP8266 and an ESP32. I want the last code to work with my ESP32. this portion of code works fine to test sending received serial data via UDP to phone void loop() Serial.printf("Now listening at IP %s, UDP port %d\n", WiFi.localIP().toString().c_str(), localUdpPort) Unsigned int localUdpPort = 5300 // local port to listen onĬhar incomingPacket // buffer for incoming packets ![]() This portion of code works fine with the ESP32 (to test UDP) #include Ĭhar replyPacket = "Hi there! Got the message :-)" Now if send the string "tosend" it works very fine. send back a reply, to the IP address and port we got the packet fromįor(int i=0 i<19 i++) packetBuffer = 0 String IncomingValues = Serial.readString() Here is my code of sending from ESP8266 void loop() I was trying to send whatever is received on serial port by udp, but it doesn't work.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |