Manual de Arduino Wifly Shield - UNAMzaz.iimas.unam.mx/~hector/archivos/Manual_wifly2.pdfManual de...

13
Manual de Arduino Wifly Shield Material necesario: Arduino UNO. Wifly shield Software requerido en la PC: Arduino IDE v.1.0.1 Librería Wifly Alpha2 Preparando el hardware:

Transcript of Manual de Arduino Wifly Shield - UNAMzaz.iimas.unam.mx/~hector/archivos/Manual_wifly2.pdfManual de...

Page 1: Manual de Arduino Wifly Shield - UNAMzaz.iimas.unam.mx/~hector/archivos/Manual_wifly2.pdfManual de Arduino Wifly Shield Material necesario: Arduino UNO. Wifly shield Software requerido

Manual de Arduino Wifly Shield Material necesario:

Arduino UNO. Wifly shield

Software requerido en la PC: Arduino IDE v.1.0.1 Librería Wifly Alpha2

Preparando el hardware:

Page 2: Manual de Arduino Wifly Shield - UNAMzaz.iimas.unam.mx/~hector/archivos/Manual_wifly2.pdfManual de Arduino Wifly Shield Material necesario: Arduino UNO. Wifly shield Software requerido

Como se puede ver 4 LEDs parpadean La parte de acondicionamiento del Hardware está completa

AHORA resta la programación:

Paso 1 : Descarga de internet la librería Wifly Alpha2 del siguiente vínculo

http://sparkfun.com/Code/wifly/WiFly-20101217-alpha-2.zip

Descomprime y extrae la librería en el folder libraries de Arduino

Page 3: Manual de Arduino Wifly Shield - UNAMzaz.iimas.unam.mx/~hector/archivos/Manual_wifly2.pdfManual de Arduino Wifly Shield Material necesario: Arduino UNO. Wifly shield Software requerido

Cuando ya esté disponible la librería wifly dentro del IDE de Arduino, se verá como así:

Paso 2: Carga en tu Arduino el sketch SpiUartTerminal

Page 4: Manual de Arduino Wifly Shield - UNAMzaz.iimas.unam.mx/~hector/archivos/Manual_wifly2.pdfManual de Arduino Wifly Shield Material necesario: Arduino UNO. Wifly shield Software requerido

Paso 3:

Page 5: Manual de Arduino Wifly Shield - UNAMzaz.iimas.unam.mx/~hector/archivos/Manual_wifly2.pdfManual de Arduino Wifly Shield Material necesario: Arduino UNO. Wifly shield Software requerido

Abre el monitor del puerto Serial: Una vez que está abierto el monitor del puerto serial, debe aparecerlo siguiente:

Selecciona entonces la opción de "NO LINE ENDING " y manda a través del monitor del puerto "$$$"

Page 6: Manual de Arduino Wifly Shield - UNAMzaz.iimas.unam.mx/~hector/archivos/Manual_wifly2.pdfManual de Arduino Wifly Shield Material necesario: Arduino UNO. Wifly shield Software requerido

Paso 4

Posterior a enviar el comando "$$$" si la comunicación fue correcta debe aparecer por respuesta CMD

Ahora debes cambiar en el monitor de Puerto serie hacia la opción "CARRIAGE RETURN"

Page 7: Manual de Arduino Wifly Shield - UNAMzaz.iimas.unam.mx/~hector/archivos/Manual_wifly2.pdfManual de Arduino Wifly Shield Material necesario: Arduino UNO. Wifly shield Software requerido

Paso 5 Con el fin de obtener los parámetros que tiene cargados el escudo wifly manda la instrucción: get everything. El monitor de puerto serie debe responder con una pantalla como esta:

Page 8: Manual de Arduino Wifly Shield - UNAMzaz.iimas.unam.mx/~hector/archivos/Manual_wifly2.pdfManual de Arduino Wifly Shield Material necesario: Arduino UNO. Wifly shield Software requerido

Configurando los parámetros de la antena del escudo Wifly

Configuración modo Adhoc: I will show you an example of setting up and adhoc connection and make the wifly act as an webserver and access point: to configure the wifly to act as an adhoc access point: you have to configure an IP address put the name of the SSID choose the Channel turn DHCP off how it is done ? lets start the coding part >>> before we start sending the commends i recommend you to check out the reference guide RN-131C it contain most of the configration and commands you need to setup for the wifly...you can download it from here : http://www.sparkfun.com/datasheets/Wireless/WiFi/WiFlyGSX-um2.pdf so lets begin: follow the above steps to enter the command mode ( sending $$$ to enter CMD ) i will show you how i found the commands to setup the adhoc connection: in page 45 of the reference guide of the wifly you will find a page explaining the adhoc configuration : send the following commands... >> set wlan join 4 //adhoc mode >> set wlan ssid my_adhoc_network //name of SSID >> set wlan chan 1 // channel of the SSID >> set ip address 192.168.1.1 //ip of the wifly >> set ip netmask 255.255.255.0 //netmask of the wifly >> set ip dhcp OFF // this sets the dhcp off

Page 9: Manual de Arduino Wifly Shield - UNAMzaz.iimas.unam.mx/~hector/archivos/Manual_wifly2.pdfManual de Arduino Wifly Shield Material necesario: Arduino UNO. Wifly shield Software requerido

>> save //save the configuration >> reboot //reboot the device that's the part of the configuration of the wifly you are done ;) ahora programaremos el código que correrá sobre Arduino.....

Código que se debe cargar en Arduino: /*

* Web Server

*

* (Based on Ethernet's WebServer Example)

*

* A simple web server that shows the value of the analog input pins.

*/

#include "WiFly.h"

#include "Credentials.h"

Server server(80);

void setup() {

WiFly.begin();

if (!WiFly.join(ssid, passphrase)) {

while (1) {

// Hang on failure.

}

}

Page 10: Manual de Arduino Wifly Shield - UNAMzaz.iimas.unam.mx/~hector/archivos/Manual_wifly2.pdfManual de Arduino Wifly Shield Material necesario: Arduino UNO. Wifly shield Software requerido

Serial.begin(9600);

Serial.print("192.168.7.11:80");

Serial.println(WiFly.ip());

server.begin();

}

void loop() {

Client client = server.available();

if (client) {

// an http request ends with a blank line

boolean current_line_is_blank = true;

while (client.connected()) {

if (client.available()) {

char c = client.read();

// if we've gotten to the end of the line (received a newline

// character) and the line is blank, the http request has ended,

// so we can send a reply

if (c == '\n' && current_line_is_blank) {

// send a standard http response header

client.println("HTTP/1.1 200 OK");

client.println("Content-Type: text/html");

client.println();

// output the value of each analog input pin

for (int i = 0; i < 6; i++) {

client.print("analog input ");

client.print(i);

client.print(" is ");

client.print(analogRead(i));

client.println("<br />");

}

break;

Page 11: Manual de Arduino Wifly Shield - UNAMzaz.iimas.unam.mx/~hector/archivos/Manual_wifly2.pdfManual de Arduino Wifly Shield Material necesario: Arduino UNO. Wifly shield Software requerido

}

if (c == '\n') {

// we're starting a new line

current_line_is_blank = true;

} else if (c != '\r') {

// we've gotten a character on the current line

current_line_is_blank = false;

}

}

}

// give the web browser time to receive the data

delay(100);

client.stop();

}

}

#ifndef __CREDENTIALS_H__

#define __CREDENTIALS_H__

// Wifi parameters

char passphrase[] = "password";

char ssid[] = "AVERNO";

#endif

Page 12: Manual de Arduino Wifly Shield - UNAMzaz.iimas.unam.mx/~hector/archivos/Manual_wifly2.pdfManual de Arduino Wifly Shield Material necesario: Arduino UNO. Wifly shield Software requerido

Parámetros de la clave de acceso a la red WIFI donde operará el Arduino con su escudo Wifly

password

Page 13: Manual de Arduino Wifly Shield - UNAMzaz.iimas.unam.mx/~hector/archivos/Manual_wifly2.pdfManual de Arduino Wifly Shield Material necesario: Arduino UNO. Wifly shield Software requerido