24/1/2014 Como usar o Wifi Shield com o Arduino
http://www.seucurso.com.br/index.php?option=com_content&view=article&id=317:como-usar-o-wifi-shield-com-o-arduino&catid=901:arduino&Itemid=65 1/6
Tweetar 10 Recomendar
Seg, 18 de Novembro de 2013 00:20
Fernando Bryan Frizzarin
Como usar o Wifi Shield com o Arduino
Avaliação do Usuário: / 4
Pior Melhor AVALIAR
Você precisará de um Arduino ou um clone seguindo o exato projeto para que o shield possa seracoplado sem problemas.
Um Arduino:
O clone, Tatuino:
Precisará também do escudo para rede sem fios (wifi shield). Para este tutorial utilizei o shieldMicrochip que alé de ser baixo custo pode ser encontrado facilmente na Internet com venda pelaTato Equipamentos Eletrônicos.
Acople o shield sobre o Arduino ou o clone:
MENU PRINCIPAL
Principal
Artigos de usuários
Ambiente de Aprendizagem
Tutoriais
Arduino
Banco de Dados
Celulares e Tablets
Diversos
Internet
Mac
Raspberry Pi
Linguagem de Programação
Linux
Window s
Fórum
Links
Contato
Webmail
ENTRAR
Nome de Usuário
Senha
Remember Me
LOGIN
Forgot your password?
Forgot your username?
Create an account
TRANSLATION
0
pesquisar...
Selecione o idioma
Pow ered by Tradutor
24/1/2014 Como usar o Wifi Shield com o Arduino
http://www.seucurso.com.br/index.php?option=com_content&view=article&id=317:como-usar-o-wifi-shield-com-o-arduino&catid=901:arduino&Itemid=65 2/6
Note que sobram dois pinos, do lado dos pinos de alimentação. Minha opção foi não cortá-los,pois não na acoplagem. Mas cuidado! Caso resolva cortá-los não vá cortar pinos errados!
Obviamente também terá que ter uma rede fio composta de um access point ou roteador para queo shield possa ser conectado a ela para nossos testes. Baixe a biblioteca WiShield-master de www.seucurso.com.br/downloads/wifishield.zip. Descompacte o conteúdo do arquivo baixado na pasta libraries do local onde estiver a instalaçãodo Arduino. Minha sugestão de código é usar o exemplo WebServer que é bem simples e auto explicativo.Você pode encontrá-lo no menu File, opção Examples e sub-opção wifishield:
O código é:
01.02.03.04.05.06.07.08.09.
10.
11.
12.
13.14.
15.16.17.
/** Web Server** A simple web server example using the WiShield 1.0*/ #include <WiShield.h> // Wireless configuration parameters ----------------------------------------
unsigned char local_ip[] = {192,168,0,200}; // IP address ofWiShield
unsigned char gateway_ip[] = {192,168,0,1}; // router or gateway IPaddress
unsigned char subnet_mask[] = {255,255,255,0}; // subnet mask for thelocal network
char ssid[] = {"redesemfio"}; // max 32 bytesunsigned char security_type = 3; // 0 - open; 1 - WEP; 2 -WPA; 3 - WPA2 // WPA/WPA2 passphraseconst prog_char security_passphrase[] PROGMEM = {“senhadaredesemfio"}; //
24/1/2014 Como usar o Wifi Shield com o Arduino
http://www.seucurso.com.br/index.php?option=com_content&view=article&id=317:como-usar-o-wifi-shield-com-o-arduino&catid=901:arduino&Itemid=65 3/6
Para que esse código funcione você terá que alterar algumas variáveis para que reflitam aconfiguração de sua rede sem fio. Sendo elas: O número IP a ser designado para seu shield:
O número IP do gateway:
A máscara de sub-rede:
O SSID (identificação) da sua rede:
O tipo de segurança utilizada, sendo 0 para rede aberta (open), 1 para WEP, 2 para WPA e 3para WPA2:
A senha para sua rede sem fio, no caso deste tutorial para WPA2:
Se você ainda usa WEP, primeiro pense em mudar para WPA ou WPA2 que são criptografiasmais seguras, depois se ainda assim quiser usar WEP terá que mudar a variável abaixo com aschaves em valores hexadecimais:
Agora é compilar e enviar para o seu Arduino. Feito isso o shield irá conectar-se em sua redesem fio em alguns segundos e o LED indicativo de WIFI ON deve acender:
18.19.20.21.
22.
23.
24.
25.26.27.
28.29.30.31.32.33.
34.35.36.37.38.39.40.41.42.
43.44.
45.46.47.48.49.50.51.
max 64 characters // WEP 128-bit keysprog_uchar wep_keys[] PROGMEM = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c,0x0d, // Key 0
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00, // Key 1
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00, // Key 2
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00 // Key 3
}; // setup the wireless mode; infrastructure - connect to AP; adhoc -connect to another WiFi device
#define WIRELESS_MODE_INFRA 1#define WIRELESS_MODE_ADHOC 2unsigned char wireless_mode = WIRELESS_MODE_INFRA;unsigned char ssid_len;unsigned char security_passphrase_len;// End of wireless configuration parameters ----------------------------------------
void setup(){WiFi.init();} // This is the webpage that is served up by the webserverconst prog_char webpage[] PROGMEM = {"HTTP/1.1 200 OK\r\nContent-Type:text/html\r\n\r\n
<h1>Hello World!! I am WiShield</h1><form action="\" method="\">Toggle LED:<input name="\" type="\" value="\"/></form>
"};
void loop(){WiFi.run();}
1. unsigned char local_ip[] = {192,168,0,200};
1. unsigned char gateway_ip[] = {192,168,0,1};
1. unsigned char subnet_mask[] = {255,255,255,0};
1. char ssid[] = {“redesemfio"};
1. unsigned char security_type = 3;
1. const prog_char security_passphrase[] PROGMEM = {“senhadaredesemfio”};
1.2.
3.
4.
5.
6.
prog_uchar wep_keys[] PROGMEM = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c,0x0d, // Key 0
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00, // Key 1
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00, // Key 2
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00 // Key 3
};
24/1/2014 Como usar o Wifi Shield com o Arduino
http://www.seucurso.com.br/index.php?option=com_content&view=article&id=317:como-usar-o-wifi-shield-com-o-arduino&catid=901:arduino&Itemid=65 4/6
Para testá-lo entre em seu navegador de Internet preferido e aponte para o IP que designou aoseu shield:
Caso queira usar qualquer outro exemplo deste shield lembre-se de editar o arquivo apps-conf.h ecomentar ou descomentar a aplicação que deseja utilizar. O código desse arquivo para estetutorial ficou como segue. Note que está descomentada a linha #define APP_WEBSERVER, poisé o exemplo que estamos utilizando. As demais continuam comentadas.
001.002.003.004.005.006.007.008.009.010.011.012.013.014.015.016.017.
018.019.
020.021.022.
023.024.025.026.027.028.029.030.031.032.033.034.035.036.037.038.
039.040.041.042.043.
044.
045.
046.047.048.049.050.
/****************************************************************************** Filename: apps-conf.hDescription: Web application configuration file ****************************************************************************** TCP/IP stack and driver for the WiShield 1.0 wireless devices Copyright(c) 2009 Async Labs Inc. All rights reserved. This program is free software; you can redistribute it and/or modify itunder the terms of version 2 of the GNU General Public License aspublished by the Free Software Foundation. This program is distributed in the hope that it will be useful, butWITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY orFITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public Licensefor
more details. You should have received a copy of the GNU General Public License alongwith
this program; if not, write to the Free Software Foundation, Inc., 59Temple Place - Suite 330, Boston, MA 02111-1307, USA. Contact Information: Author Date Comment---------------------------------------------------------------AsyncLabs 05/29/2009 Initial port *****************************************************************************/ #ifndef __APPS_CONF_H__#define __APPS_CONF_H__ // ----------------------------------------------------------------------------
// -- Begin uIP/WiShield stack configuration settings //// Application type defines; uncomment to enable APP_TYPES// APP_UDPAPP is used for UDP only apps as well as DNS and DHCP apps;if your app will use
// DNS and/or DHCP then your APP_TYPE (e.g. APP_WISERVER) ANDAPP_UDPAPP must be defined
// (uncommented). Currently only APP_UDPAPP may be defined at the sametime as any other APP_TYPE
//#define APP_WEBSERVER//#define APP_WEBCLIENT//#define APP_SOCKAPP//#define APP_UDPAPP
24/1/2014 Como usar o Wifi Shield com o Arduino
http://www.seucurso.com.br/index.php?option=com_content&view=article&id=317:como-usar-o-wifi-shield-com-o-arduino&catid=901:arduino&Itemid=65 5/6
0
Citar
0
Citar
+1
Citar
Com um pouco de conhecimento de HTML e TCP/IP agora é só usar a imaginação para resolverseu problema ou criar sua aplicação!
MOSTRAR OUTROS ARTIGOS DESTE AUTOR
COMENTÁRIOS
#3 Problema — Fernando Bryan Frizzarin 23-01-2014 13:19
Matheus, você ajustou o endereço IP, nome da rede e senha corretamente? Por favor, verifiqueisso e qualquer coisa me fale novamente.
#2 problema — Matheus Prado 23-01-2014 09:50
O Wifi Shield conecta à rede pois o led verde ascende, mas a página não abre. O que fazer??
#1 Pinos disponiveis — Mauricio Nascimento 31-12-2013 11:42
Muito boa tarde. Gostaria de saber quais pinos que posso utilizar para receber sinais externosou acionar leds sem interferir na comunicação.
Atualizar lista de comentários
Assine o RSS dos comentários
ADICIONAR COMENTÁRIO
Nome (obrigatório)
E-mail (obrigatório)
Título (obrigatório)
051.052.053.054.055.056.
057.
058.059.060.061.062.063.
064.065.066.067.068.069.
070.071.072.073.074.075.076.077.078.
079.080.081.082.083.084.085.086.087.088.089.090.091.092.093.094.095.096.097.098.099.100.101.102.103.104.105.106.107.108.109.110.111.112.
//#define APP_WISERVER //// Add on features; uncomment to enable additional functionality////#define UIP_DNS // Add DNS capabilities - APP_UDPAPPmust be defined!
//#define UIP_DHCP // Add DHCP capabilities - APP_UDPAPPmust be defined!
//#define UIP_SCAN // Add Access Point scan capabilities //// Commonly accessed WiServer settings//#define WISERVER_GET_STRING_MAX 64 // Length of buffer which holdsURL/GET passed to WiServer// SimpleServer sendMyPage() page serving function //// Commonly accessed uIP stack settings//#define UIP_WEP_KEY_LEN 13 // WEP Key length: 5 bytes (64-bitWEP); 13 bytes (128-bit WEP)
#define UIP_WEP_KEY_DEFAULT 0 // Default WEP key ID: Key 0, 1, 2, 3#define MAX_TCP_CONNS 2 // Max TCP connections desired#define MAX_TCP_LISTENPORTS 2 // Max TCP listening ports#define MAX_UDP_CONNS 1 // Max UDP connections desired// Don't play with UIP_CLOCK_DIV unless you know what you are doing!#define UIP_CLOCK_DIV 2 // Referenced in stack.c; default 2 // -- End uIP/WiShield stack configuration settings// ---------------------------------------------------------------------------- #ifdef APP_WEBSERVER#include "webserver.h"#endif #ifdef APP_WEBCLIENT#include "webclient.h"#endif #ifdef APP_SOCKAPP#include "socketapp.h"#endif #ifdef APP_UDPAPP#include "udpapp.h"#define UIP_UDP_ENABLED 1#else#define UIP_UDP_ENABLED 0#endif #ifdef APP_WISERVER#include "server.h"#endif #ifdef UIP_DHCP#include "uip_dhcp.h"#endif #ifdef UIP_DNS#include "uip_dns.h"#endif #endif /*__APPS_CONF_H__*/
24/1/2014 Como usar o Wifi Shield com o Arduino
http://www.seucurso.com.br/index.php?option=com_content&view=article&id=317:como-usar-o-wifi-shield-com-o-arduino&catid=901:arduino&Itemid=65 6/6
Você ainda pode digitar 1000 caracteres
Enviar
JC omments
Notifique-me de comentários futuros
Atualizar
Top Related