简体   繁体   English

带有WIFI的Arduino以太网板R3

[英]Arduino Ethernet Board R3 with WIFI

i have been playing around with an arduino for 2 days now, so i am new to this, but i have a problem: the wifi shield wont work with the arduino ethernet R3. 我已经和arduino玩了2天了,所以我对此很陌生,但是我有一个问题:wifi防护罩无法与arduino以太网R3配合使用。 I got them from sparkfun: 我从sparkfun获得了它们:

https://www.sparkfun.com/products/11361 https://www.sparkfun.com/products/11287 https://www.sparkfun.com/products/11361 https://www.sparkfun.com/products/11287

and every time i try to run this code: 每次我尝试运行此代码:

/*

 This example  prints the Wifi shield's MAC address, and
 scans for available Wifi networks using the Wifi shield.
 Every ten seconds, it scans again. It doesn't actually
 connect to any network, so no encryption scheme is specified.

 Circuit:
 * WiFi shield attached

 created 13 July 2010
 by dlf (Metodo2 srl)
 modified 21 Junn 2012
 by Tom Igoe and Jaymes Dec
*/


#include <SPI.h>
#include <WiFi.h>

void setup() {
  //Initialize serial and wait for port to open:
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }

  // check for the presence of the shield:
  unsigned long start=millis();
  while (WiFi.status() == WL_NO_SHIELD) 
  {
    if ((millis()-start)>30000)
    {
      Serial.println("WiFi shield not present"); 
      // don't continue:
      while(true);
    }
    delay(500);
  }

  // Print WiFi MAC address:
  printMacAddress();

  // scan for existing networks:
  Serial.println("Scanning available networks...");
  listNetworks();
}

void loop() {
  delay(10000);
  // scan for existing networks:
  Serial.println("Scanning available networks...");
  listNetworks();
}

void printMacAddress() {
  // the MAC address of your Wifi shield
  byte mac[6];                     

  // print your MAC address:
  WiFi.macAddress(mac);
  Serial.print("MAC: ");
  Serial.print(mac[5],HEX);
  Serial.print(":");
  Serial.print(mac[4],HEX);
  Serial.print(":");
  Serial.print(mac[3],HEX);
  Serial.print(":");
  Serial.print(mac[2],HEX);
  Serial.print(":");
  Serial.print(mac[1],HEX);
  Serial.print(":");
  Serial.println(mac[0],HEX);
}

void listNetworks() {
  // scan for nearby networks:
  Serial.println("** Scan Networks **");
  int numSsid = WiFi.scanNetworks();
  if (numSsid == -1)
  {
    Serial.println("Couldn't get a wifi connection");
    while(true);
  }

  // print the list of networks seen:
  Serial.print("number of available networks:");
  Serial.println(numSsid);

  // print the network number and name for each network found:
  for (int thisNet = 0; thisNet<numSsid; thisNet++) {
    Serial.print(thisNet);
    Serial.print(") ");
    Serial.print(WiFi.SSID(thisNet));
    Serial.print("\tSignal: ");
    Serial.print(WiFi.RSSI(thisNet));
    Serial.print(" dBm");
    Serial.print("\tEncryption: ");
    printEncryptionType(WiFi.encryptionType(thisNet));
  }
}

void printEncryptionType(int thisType) {
  // read the encryption type and print out the name:
  switch (thisType) {
  case ENC_TYPE_WEP:
    Serial.println("WEP");
    break;
  case ENC_TYPE_TKIP:
    Serial.println("WPA");
    break;
  case ENC_TYPE_CCMP:
    Serial.println("WPA2");
    break;
  case ENC_TYPE_NONE:
    Serial.println("None");
    break;
  case ENC_TYPE_AUTO:
    Serial.println("Auto");
    break;
  }
}

i get a WiFi shield not present. 我没有WiFi屏蔽。 any ideas on how to properly connect it? 关于如何正确连接的任何想法?

Thank You! 谢谢!

The products that you listed seem to be redundant. 您列出的产品似乎是多余的。 Specifically, ~/11361 is an all-in-one arduino dev. 具体来说,〜/ 11361是一个多合一的arduino开发人员。 board + Ethernet but no wireless (ie ethernet connection is via a cable), while ~/11287 is a WiFi shield that is used on a generic Arduino board and connects to the internet. 板+以太网,但没有无线连接(即通过电缆通过以太网连接),而〜/ 11287是WiFi屏蔽板,用于通用Arduino板上并连接到互联网。

The problem might be that using 11287 as a shield on 11361 leads to conflicts? 问题可能是使用11287作为11361的屏蔽会导致冲突? I don't know, but the link http://arduino.cc/en/Reference/WiFi has the following comment: 我不知道,但是链接http://arduino.cc/en/Reference/WiFi有以下评论:

The WiFi library is very similar to the Ethernet library, and many of the function calls are the same. WiFi库与以太网库非常相似,并且许多函数调用是相同的。

which makes me a little suspect. 这让我有点怀疑。

Try the shield (11287) on a standard Arduino board. 在标准Arduino板上尝试屏蔽(11287)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM