Arduino WiFi Shield UDP Support

srrichie:
Is the initialization of your class correct? Is it right I'm initializing it like this:

Udp.begin(receiverPort);

...using receiverPort as argument?

Is the composition of the UDP message correct?

Well yes and no.
If you look at the header file of WifiUDP ( Arduino/WiFiUdp.h at wifishield-bugfix · mlafauci/Arduino · GitHub ), you'll see that the method is commented like this:

  virtual uint8_t begin(uint16_t);	// initialize, start listening on specified port. Returns 1 if successful, 0 if there are no sockets available to use

so it's expecting you to pass the port the Arduino should listen on, not the one to send to. But since you are not listening on the Arduino and the local and remote port can be the same, this shouldn't be a problem.

The construction of your UDP message

Udp.beginPacket(receiverIP, receiverPort); //start udp packet
  Udp.write(valueInBytes, 8); //write sensor data to udp packet
  Udp.endPacket(); // end packet

looks right to me.
It's difficult to debug these kind of things from a distance. What I would do in such a case is try with the simplest setup that works and then change the code until it breaks. Step by step, compiling and testing with every change. At a certain point it will stop working.
So I would suggest you start with my example, start changing things and see how far you can get.
I would start by checking these:

  • do you really want delay(10000); // 10sec delay?
  • is the receiving computer really at IP 192.168.1.212 ? and is it listening at port 9100 ?
  • more really obvious mistakes that are easy to overlook :slight_smile: