Hi,
I have manage to make the UDP work properly on the WIFI shield without too much hassle.
The new version of the Arduino environment (1.0.5) already includes the WIFI shield libraries, and among its examples it has one that uses UDP: go to Examples -> WIFI -> WifiUdpNtpClient
First try:
I have just uploaded the sketch to the Arduino (after setting the proper WIFI SSID and password) but it did not work. In fact, watching at the messages on the serial port I saw:
Attempting to connect to SSID: XXXX
Connected to wifi
SSID: LST-D204
IP Address: 192.168.1.132
signal strength (RSSI):-53 dBm
Starting connection to server...
0
0
0
0
0
At some point, where in the Arduino sketch says Serial.println( Udp.parsePacket() ); it was printing me out this 0, meaning that probably the library was not supported by the firmware.
Firmware update:
Be careful about the firmware. It seems that there are two git repositories with the shield's code
this: GitHub - arduino/wifishield: Arduino Wifi Shield
and this: https://github.com/arduino/Arduino/tree/master/hardware/arduino/firmwares/wifishield/binary
I have used the second one, which was more recent and I think is also the one that is more official, so remember, WIFI shield's firmware is here:
https://github.com/arduino/Arduino/tree/master/hardware/arduino/firmwares/wifishield/binary !!!!!
You have to donwload the files wifi_dnld.elf and wifiHD.elf.
Then I have followed the instructions given here:
they are not very good, but all the steps are described at least.
As I work on Windows I had to download the Atmel's tools here http://www.atmel.com/tools/FLIP.aspx
Then I removed the shield from the Arduino, put the jumper in programming mode and connected the mini USB port to the computer.
If the driver for the AT32UC3 is not found you have it available in your computer inside the Flip folder, in my case here: C:\Program Files (x86)\Atmel\Flip 3.4.7\usb
The I have updated BOTH the HDG104 and the AT32UC3 firmwares.
For updating the HDG104 firmware type:
C:\Program Files (x86)\Atmel\Flip 3.4.7\bin>batchisp.exe -device AT32UC3A1256 -hardware usb -operation erase f memory flash blankcheck loadbuffer D:\D
ownloads\Development\Arduino\wifi_dnld.elf program verify start reset 0
(will have to change the path to the wifi_dnld.elf file that you have downloaded from the GIT repository)
you will see:
Running batchisp 1.2.5 on Fri May 31 14:17:14 2013
AT32UC3A1256 - USB - USB/DFU
Device selection....................... PASS
Hardware selection..................... PASS
Opening port........................... PASS
Reading Bootloader version............. PASS 1.0.2
Erasing................................ PASS
Selecting FLASH........................ PASS
Blank checking......................... PASS 0x00000 0x3ffff
Parsing ELF file....................... PASS D:\Downloads\Development\Arduino\wifi_dnld.elf
WARNING: The user program and the bootloader overlap!
Programming memory..................... PASS 0x00000 0x2902b
Verifying memory....................... PASS 0x00000 0x2902b
Starting Application................... PASS RESET 0
Summary: Total 11 Passed 11 Failed 0
Then for updating AT32UC3 firmware you have to type:
C:\Program Files (x86)\Atmel\Flip 3.4.7\bin>batchisp.exe -device AT32UC3A1256 -hardware usb -operation erase f memory flash blankcheck loadbuffer D:\D
ownloads\Development\Arduino\wifiHD.elf program verify start reset 0
In my case, after the previous update, the board got stuck so I got:
Running batchisp 1.2.5 on Fri May 31 14:18:09 2013
AT32UC3A1256 - USB - USB/DFU
Device selection....................... PASS
Hardware selection..................... PASS
Opening port........................... AtLibUsbDfu: 3EB 2FF8 no device present.
FAIL Could not open USB device.
ISP done.
So I just removed the USB cable and put it back again, so once again:
C:\Program Files (x86)\Atmel\Flip 3.4.7\bin>batchisp.exe -device AT32UC3A1256 -hardware usb -operation erase f memory flash blankcheck loadbuffer D:\D
ownloads\Development\Arduino\wifiHD.elf program verify start reset 0
and you'll see:
Running batchisp 1.2.5 on Fri May 31 14:26:28 2013
AT32UC3A1256 - USB - USB/DFU
Device selection....................... PASS
Hardware selection..................... PASS
Opening port........................... PASS
Reading Bootloader version............. PASS 1.0.2
Erasing................................ PASS
Selecting FLASH........................ PASS
Blank checking......................... PASS 0x00000 0x3ffff
Parsing ELF file....................... PASS D:\Downloads\Development\Arduino\wifiHD.elf
WARNING: The user program and the bootloader overlap!
Programming memory..................... PASS 0x00000 0x3fe2b
Verifying memory....................... PASS 0x00000 0x3fe2b
Starting Application................... PASS RESET 0
Summary: Total 11 Passed 11 Failed 0
Good! now connect the Wifi Shield to the Arduino again and run the WifiUdpNtpClient example.
If everything works you should see on your serial port:
Attempting to connect to SSID: XXXX
Connected to wifi
SSID: LST-D204
IP Address: 192.168.1.132
signal strength (RSSI):-53 dBm
Starting connection to server...
48
packet received
Seconds since Jan 1 1900 = 3578992778
Unix time = 1370003978
The UTC time is 12:39:38
which means that everything is working