2

I'm using an Arduino Mega to monitor the current & voltage input to four different sensors. This works fine - the sensors work as expected and I can view the results via the Serial Monitor or Parallax DAQ for Excel.

SETUP

I also have an Arduino wireless SD shield (now retired) with an XBee module (shown in the below image):

  1. Arduino Shield page
  2. XBee module page

enter image description here

I would like to do the following:

  1. Save the current/voltage sensors' output locally to the SD card
  2. Send the data over a wifi connection for plotting using plotly API (see example here)

I've seen a bunch of tutorials on how to get the shield to work but can't seem to figure it out:

  1. Arduino WiFi shield example
  2. Instructables
  3. Can I connect to WiFi with an Arduino, "wireless SD shield" and XBee

Here's my code (removed the current/voltage sensor code for brevity):

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

void setup() {
  // initialize serial and wait for the port to open:  
  Serial.begin(9600);
  while(!Serial) ;


  SPI.begin();

  Serial.println("Checking WiFi status:");
  Serial.print("\tWiFi Status: ");
  Serial.println(WiFi.status());

  if(WiFi.status() == WL_NO_SHIELD){
    Serial.println("\tNo Shield present.\n");
  }else{
    Serial.println("\tShield found.\n");
  }

  Serial.println("Initializing SD card:");
  if (!SD.begin(53)) {
    Serial.println("\tSD card initialization failed.\n");
    return;
  }else{
    Serial.println("\tSD card initialization successful.\n");    
  }


  // attempt to connect using WEP encryption:
  Serial.println("Initializing Wifi:");
  printMacAddress();

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

void loop() {
  delay(5000);
  // 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("\tMAC: ");

  for(int i = 0; i < 5; i++){
    Serial.print(mac[5-i],HEX);
    if(i != 5){
      Serial.print(":");
    }
  }
  Serial.println(" ");
}

void listNetworks() {
  // scan for nearby networks:
  Serial.println("** Scan Networks **");
  byte numSsid = WiFi.scanNetworks();

  // 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: ");
    Serial.println(WiFi.encryptionType(thisNet));
  }
}

OUTPUT

Checking WiFi status:
    WiFi Status: 255
    No Shield present.

Initializing SD card:
    SD card initialization successful.

Initializing Wifi:
    MAC: 0:0:0:0:0: 
Scanning available networks...
** Scan Networks **
number of available networks:0

Not sure what is going on here.

0

1 Answer 1

1

"Arduino Wireless SD shield" is not "Arduino WiFi shield".

The code you have is for the Arduino WiFi shield. But you have Arduino Wireless SD shield for a XBee module. XBee is not WiFi. Zigbee protocol is different protocol than WiFi.

You can save data to SD card with the SD library. Install the library in Library Manager and try the examples.

Arduino WiFi shield: enter image description here Note: the Arduino WiFi library is only for this shield and clones

6
  • Thanks, I am able to write to the SD card without problem. I have the shield and the XBee module, how do I get them to work together and discover/send data over available WiFi networks?
    – Gautam
    Commented Aug 27, 2018 at 18:21
  • XBee can't send data over WiFi
    – Juraj
    Commented Aug 27, 2018 at 19:41
  • So, what is the shield/module for? the Arduino example seems to suggest that the shield by itself is capable to atleast finding the WiFi networks and joining them. Right now, I can't even get the Mac address to be printed.
    – Gautam
    Commented Aug 27, 2018 at 20:14
  • which example? what you have in question is for WIFI shield, not for Wireless shield. Zigbee protocol is different protocol then WiFi
    – Juraj
    Commented Aug 28, 2018 at 4:51
  • I don't think I understand the difference - if you do, can you point out how/where I'm wrong or what I should be looking for? I'm a mechanical engineer without much experience in electronics. I'm clearly lost and don't want to ask a million irrelevant questions to find out that my initial premise was flawed.
    – Gautam
    Commented Aug 28, 2018 at 13:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.