[vc_row][vc_column width=”1/1″][vc_tour][vc_tab title=”Description” tab_id=”1395882074-1-73″][vc_column_text]What is CuHead Pro WiFi/Ethernet Shield with AirPlay/DLNA Audino for Arduino? It is a WiFi Shield, it is an Ethernet Shield, it accepts audio pushed from iphone, iPad, Android phone or pad Wirelessly.
[/vc_column_text][/vc_tab][vc_tab title=”Interface” tab_id=”1395882074-2-26″][vc_column_text]Lets explain the interfaces:
- USB host is reserved. It is for firmware updated in the future so that USB webcam can be used.
- Ethernet RJ45 port. It is used for Ethernet communication where there is no WiFi signal, or where the WiFi Signal is bad.
- Audio jack. It accepts any three segments audio jack.
- J7 is the header used to choose which pins of Arduino are used to communicate with CuHead Pro. CuHead Pro can communicate with Arduino transparently through the UART interface. Please don’t use D0 and D1. This is because that the hardware UART on Arduino TX/RD are pulled low during power up, and unfortunately CuHead pro will check its UART too during power up. If its pulled low, it will not start. So we can only use software serial port of Arduino to communicate with CuHead Pro.
[/vc_column_text][/vc_tab][vc_tab title=”Audio Push” tab_id=”1395882256402-2-0″][vc_column_text]First, lets look at interesting application. We are going to push music from iPhone to CuHead pro.
Lets make sure that J7 is configured so that pins 6 and pins 7 are installed as following:
Install CuHead Pro on Arduino, and Arduino is connected to PC through USB connection. Yes. PC’s USB can supply current for CuHead Pro.
When powered up, we can see four green LEDs of WiFi module turned on.
After several seconds, there are only two LEDs still on, and they are steady on.
Wait for another minute or two, the two LEDs will start to blink. This indicates that WiFi module is ready for use. We use iPhone to scan for WiFi network, and can see that there is a new AP, which is made by CuHead Pro. CuHead Pro works in AP client mode. It is a AP itself, so that it can provide AP service for other WiFi client. It can also connect to a router in home for Internet connection. From this point of view, it works more like a WiFI repeater.
We connect to the AP made by Cuhead Pro:
Open the music application, we can see that there is an AirPlay icon in the lower right. Click the little triangle:
Click AirPlay, we can select the device that will be used to play the audio:
After couple of seconds, the music will show up in the audio jack. Is it amazing?
What about cloud music? We can configure CuHead Pro to connect to the router in office or home.
Launch a browser, and enter 10.10.10.254. Note that iPhone need to connect to CuHead Pro AP.
Click the icon named WiFi, and we can see many APs:
Select the router that we intend to connect, and input password:
Now CuHead Pro is on the Internet, and we connect iPhone to the same router and we can stream audio from Internet.
[/vc_column_text][/vc_tab][vc_tab title=”TCP to UART Communication” tab_id=”1395882257633-3-8″][vc_column_text]The following work will be done on a PC.
First, we need to configure PC to connect to the AP of CuHead Pro. Please make sure that CuHead Pro is powered up and starts up properly.
Open a web browser, and enter 10.10.10.254:
Click System, and we can check the version of firmware loaded on the WiFi module:
If the version is lower than 1.2.1491, we need to upgrade our firmware before continue. Version 1491 can be downloadedhere. Click Status->Firmware update to upgrade.
There are three IPs we need to make sure we can distinguish them:
- When CuHead Pro works as an AP. It will assign an IP to itself. This IP address is always 10.l0.10.254. This IP address is only valid if PC is connected to CuHead Pro AP.
- Wireless IP: This IP address is assigned to CuHead Pro when it connects to the office router. If our PC is also connected to the same router, we can access CuHead Pro using this IP address.
- Ethernet IP: This IP address is assigned to CuHead Pro by the router when CuHead Pro is connected to router by Ethernet cable. If our PC is also connected to the same router wireless or by cable, we need to use this IP address to access CuHead Pro.
In the UART tab, we can configure the baud rate of the WiFi module:
300,600,1200, 1800, 2400, 4800, 9600, 19200, 38400, and default to 9600.
[/vc_column_text][/vc_tab][vc_tab title=”Test Code” tab_id=”1395882259507-4-5″][vc_column_text]Now, let’s look at Arduino code:
/* Software serial multple serial test Receives from the hardware serial, sends to software serial. Receives from software serial, sends to hardware serial. The circuit: * RX is digital pin 10 (connect to TX of other device) * TX is digital pin 11 (connect to RX of other device) Note: Not all pins on the Mega and Mega 2560 support change interrupts, so only the following can be used for RX: 10, 11, 12, 13, 50, 51, 52, 53, 62, 63, 64, 65, 66, 67, 68, 69 Not all pins on the Leonardo support change interrupts, so only the following can be used for RX: 8, 9, 10, 11, 14 (MISO), 15 (SCK), 16 (MOSI). created back in the mists of time modified 25 May 2012 by Tom Igoe based on Mikal Hart's example This example code is in the public domain. */ #include <SoftwareSerial.h> SoftwareSerial mySerial(6, 7); // RX, TX void setup() { // Open serial communications and wait for port to open: Serial.begin(9600); while (!Serial) { ; // wait for serial port to connect. Needed for Leonardo only } Serial.println("Goodnight moon!"); // set the data rate for the SoftwareSerial port mySerial.begin(9600); mySerial.println("Hello, world?"); } void loop() // run over and over { if (mySerial.available()) Serial.write(mySerial.read()); if (Serial.available()) mySerial.write(Serial.read()); }
The code works by copying data back and forth between the software serial port where CuHead Pro is using and the hardware serial port of Arduino.
On the PC, we can use a TCP/IP debug program.
The following is the screen shot showing the bidirectional communication between TCP and UART:
Leave a Reply
You must be logged in to post a comment.