• Home
  • pcDuino
  • WiKi
  • Store
  • Distributors
  • Home
  • pcDuino
  • WiKi
  • Store
  • Distributors
HomeArduinoShieldsHow to Compile Sample UDPApp of LinkSprite’s CuHea ...
Previous Next

How to Compile Sample UDPApp of LinkSprite’s CuHead WiFi Shield

Posted by: admin , January 6, 2014

CuHead WiFi shield, both V1 and V2, are cost-effective solutions to add  WiFi connectivity to an Arduino board.

Recently, there seems to be rising confusion on how to use the popular CuHead WiFi shield. Many users thought the built-in Wifi library in Arduino IDE is for Cuhead. That is NOT the case. The built-on directory named “WiFi” under “libraries” is just for Arduino’s Wifi shield, it is NOT meant for LinkSprite CuHead WiFi Shield.

To use CuHead V1 or V2, we can download the library from github. After we download and unzip, we got a directory named “ZG2100BasedWiFiShield-master”. We should rename the directory as “cuhead” and copy it under directory “libraries”. The structure should look like:

 

cuhead_directory

 

We can then launch the arduino IDE by double clicking the arduino app:

 

arduino_IDE

Now, we are going to test the UDPApp sample code. There are built-in samples in the CuHead library. We can open the simple web server by navigating File->Examples->cuhead->UDPApp:

 

UDP

 

CuHead cannot do DHCP. It can only be set to a static IP address.

How to set a static ip?

If your PC is also connecting to the same access point (wifi router) as the CuHead WiFi shield does, we can use “ipconfig” to check the local IP address as following:

 

Capture1

In this case, the PC has a IP address of 192.168.1.8.  Just to be safe, we will set the local_ip of CuHead to be “192.168.1.20″. Please note that although your router is set to be DHCP. It can also entertain a static IP request.

Now we need to figure out the security_type. Again, if your PC is attached to the same WiFi router, we can check the security type of the wifi of your pc:

 

ap

 

ap2

 

By looking at the picture above, we can tell the security type is WPA, and of course we need to passphrase.

Before we can compile the code, we need to make changes to file ‘apps-conf.h’:

//Here we include the header file for the application(s) we use in our project.
//#define APP_WEBSERVER
//#define APP_WEBCLIENT
//#define APP_SOCKAPP
#define APP_UDPAPP
//#define APP_WISERVER

We also need to make the following change to file ‘uip-conf.h’:

/**
 * UDP support on or off
 *
 * \hideinitializer
 */
#define UIP_CONF_UDP             1

 

After this, we compile and load the code, at the same time, we hit the stop watch to check how long it takes for the CuHead to attach to my router:

photo

 

It takes 38 seconds for the connection LED to turn on:

 

photo

 

 

 

 

 

 

Tags: Shields

Share!
Tweet

admin

About the author

Leave a Reply Cancel reply

You must be logged in to post a comment.

Category

  • Home
  • pcDuino
  • WiKi
  • Store
  • Distributors