manual de arduino wifly shield - unamzaz.iimas.unam.mx/~hector/archivos/manual_wifly2.pdfmanual de...
Post on 10-Mar-2018
244 Views
Preview:
TRANSCRIPT
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:
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
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
Paso 3:
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 "$$$"
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"
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:
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
>> 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.
}
}
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;
}
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
Parámetros de la clave de acceso a la red WIFI donde operará el Arduino con su escudo Wifly
password
top related