Arduino UNO + Wireless Proto Shield + RN-XV WiFly + NodeJS

Evening All. I have search the internet far and wide and I am stuck...

My Components:

  • Arduino UNO R3
  • Wireless Proto Shield
  • RNXV Wifly Module

My Test:
I am attempting to connect to my nodejs server and want to send commands from there to my arduino. Now I have tried all the following libraries:

And I can say that none of these libs work.

Also with the Protoshield and the RNXV what do I need to set up on the wireless shield as I have gotten it as far to connect to my wlan using "set wlan ssid xxxxxxxx" and "set wlan prase xxxxxxxx", then save and reboot and then it connects but I can not get my arduino to communicate with it nore can I create a wificlient connection as it tells me that it can not find the wifly or wifi...

the WifiWebClient code at http://arduino.cc/en/Tutorial/WiFiWebClient does not work either as

if (WiFi.status() == WL_NO_SHIELD) {
    Serial.println("WiFi shield not present"); 
    // don't continue:
    while(true);
  }

tells me that there is no sheild present...?

What do I need to do and where am I going wrong

Kindest Regards

Phil

And I can say that none of these libs work.

And, I can say "Bullpoop". All of the libs work. That they don't do EXACTLY what you want is completely irrelevant.

You need to post a sketch and say exactly what it does, and exactly what it does not do. "It doesn't work" will get you NO help around here.

  1. wow...

Maybe I should have started with I have no prior experience with arduino...

That out the way, lets look at the simple code I posted...

if (WiFi.status() == WL_NO_SHIELD) {
    Serial.println("WiFi shield not present"); 
    // don't continue:
    while(true);
  }

Regardless of what I do, this keeps returning that the wifi shield is not present both with the switch in USB and Micro...

Here is the exact code from the arduino examples that I am trying, it wont go further than Serial.println("WiFi shield not present"); with the correct SSID and PASS...

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

char ssid[] = "yourNetwork"; //  your network SSID (name) 
char pass[] = "secretPassword";    // your network password (use for WPA, or use as key for WEP)
int keyIndex = 0;            // your network key Index number (needed only for WEP)

int status = WL_IDLE_STATUS;
// if you don't want to use DNS (and reduce your sketch size)
// use the numeric IP instead of the name for the server:
//IPAddress server(74,125,232,128);  // numeric IP for Google (no DNS)
char server[] = "www.google.com";    // name address for Google (using DNS)

// Initialize the Ethernet client library
// with the IP address and port of the server 
// that you want to connect to (port 80 is default for HTTP):
WiFiClient client;

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:
  if (WiFi.status() == WL_NO_SHIELD) {
    Serial.println("WiFi shield not present"); 
    // don't continue:
    while(true);
  } 
  
  // attempt to connect to Wifi network:
  while (status != WL_CONNECTED) { 
    Serial.print("Attempting to connect to SSID: ");
    Serial.println(ssid);
    // Connect to WPA/WPA2 network. Change this line if using open or WEP network:    
    status = WiFi.begin(ssid, pass);
  
    // wait 10 seconds for connection:
    delay(10000);
  } 
  Serial.println("Connected to wifi");
  printWifiStatus();
  
  Serial.println("\nStarting connection to server...");
  // if you get a connection, report back via serial:
  if (client.connect(server, 80)) {
    Serial.println("connected to server");
    // Make a HTTP request:
    client.println("GET /search?q=arduino HTTP/1.1");
    client.println("Host: www.google.com");
    client.println("Connection: close");
    client.println();
  }
}

void loop() {
  // if there are incoming bytes available 
  // from the server, read them and print them:
  while (client.available()) {
    char c = client.read();
    Serial.write(c);
  }

  // if the server's disconnected, stop the client:
  if (!client.connected()) {
    Serial.println();
    Serial.println("disconnecting from server.");
    client.stop();

    // do nothing forevermore:
    while(true);
  }
}


void printWifiStatus() {
  // print the SSID of the network you're attached to:
  Serial.print("SSID: ");
  Serial.println(WiFi.SSID());

  // print your WiFi shield's IP address:
  IPAddress ip = WiFi.localIP();
  Serial.print("IP Address: ");
  Serial.println(ip);

  // print the received signal strength:
  long rssi = WiFi.RSSI();
  Serial.print("signal strength (RSSI):");
  Serial.print(rssi);
  Serial.println(" dBm");
}

My actual Board:

Its a Wifi Proto Shield with an RNVX attached ... and not a Wireless Shield... "2 completely different boards..."

Not sure what more I can give you..? as I have attempted all those libs, even the basic set-up doesn't work and these are new boards...

Ok, so now I got Johnny-five to work. FINALLY!!!

But that still does not solve my issue... Johnny5 runs on a localhost on port 80... so then what do I do when I deploy this on a cloud server.. how do I then interface with my arduino from the server... what to do... lets move this conversation to github...

My Node.js code that makes the light bling on my arduino...

var express = require("express");
var app = express();

// Set the HTML Rendere Engine for express
app.engine('html', require('ejs').renderFile);

var five = require("johnny-five"),
    board = new five.Board();

board.on("ready", function() {

  (new five.Led(13)).strobe(1000);

});

app.get('/', function(req, res){
  res.render('default.html', {data:"welcome"});
});


var port = Number(process.env.PORT || 8080);
app.listen(port, function() {
  console.log("Listening on " + port);
});

Its a Wifi Proto Shield with an RNVX attached ... and not a Wireless Shield... "2 completely different boards..."

So, why would you expect software that works with one board to work with the other? That will not happen. The library was correct. You do not have the WiFi card it operates with.

Johnny5 runs on a localhost on port 80

This doesn't make sense. localhost is the name of the server WHEN the server and client are the same machine. There is NOTHING that limits Johnny5 to running on the same machine as the client.

Ok lets start again. Clearly my attempt at explaining myself and what issues I am having as a vague "Remember that dude with the hair...", so if you dont mind I would like to try again. Here goes...

[i]What I want to accomplish is have a website, in this case a Nodejs app loaded onto a cloud server like nodejitsu, then connecting the arduino to it with the items below and then being able to send commands from the website to the arduino and back again, but I can not even get the arduino to connect with the server...[/i]

I have the following components:

Arduino UNO R3 http://upload.wikimedia.org/wikipedia/commons/3/38/Arduino_Uno_-_R3.jpg
roving networks rn-xv Module https://static.hackaday.io/images/5595561403175750003.jpg
Wirles Proto Shield http://arduino.cc/en/uploads/Main/Arduino_WirelessProtoShield_Front_450px.jpg

I am using WiFlyHQ GitHub - harlequin-tech/WiFlyHQ: WiFly RN-XV Arduino Library to set-up a connection to my web server.

The following sketch is loaded onto my arduino: WiFlyHQ/httpclient.ino at master · harlequin-tech/WiFlyHQ · GitHub

#include <WiFlyHQ.h>

#include <SoftwareSerial.h>
SoftwareSerial wifiSerial(8,9);

//#include <AltSoftSerial.h>
//AltSoftSerial wifiSerial(8,9);

WiFly wifly;

/* Change these to match your WiFi network */
const char mySSID[] = "myssid";
const char myPassword[] = "my-wpa-password";

//const char site[] = "arduino.cc";
//const char site[] = "www.google.co.nz";
const char site[] = "hunt.net.nz";

void terminal();

void setup()
{
    char buf[32];

    Serial.begin(115200);
    Serial.println("Starting");
    Serial.print("Free memory: ");
    Serial.println(wifly.getFreeMemory(),DEC);

    wifiSerial.begin(9600);
    if (!wifly.begin(&wifiSerial, &Serial)) {
        Serial.println("Failed to start wifly");
	terminal();
    }

    /* Join wifi network if not already associated */
    if (!wifly.isAssociated()) {
	/* Setup the WiFly to connect to a wifi network */
	Serial.println("Joining network");
	wifly.setSSID(mySSID);
	wifly.setPassphrase(myPassword);
	wifly.enableDHCP();

	if (wifly.join()) {
	    Serial.println("Joined wifi network");
	} else {
	    Serial.println("Failed to join wifi network");
	    terminal();
	}
    } else {
        Serial.println("Already joined network");
    }

    //terminal();

    Serial.print("MAC: ");
    Serial.println(wifly.getMAC(buf, sizeof(buf)));
    Serial.print("IP: ");
    Serial.println(wifly.getIP(buf, sizeof(buf)));
    Serial.print("Netmask: ");
    Serial.println(wifly.getNetmask(buf, sizeof(buf)));
    Serial.print("Gateway: ");
    Serial.println(wifly.getGateway(buf, sizeof(buf)));

    wifly.setDeviceID("Wifly-WebClient");
    Serial.print("DeviceID: ");
    Serial.println(wifly.getDeviceID(buf, sizeof(buf)));

    if (wifly.isConnected()) {
        Serial.println("Old connection active. Closing");
	wifly.close();
    }

    if (wifly.open(site, 80)) {
        Serial.print("Connected to ");
	Serial.println(site);

	/* Send the request */
	wifly.println("GET / HTTP/1.0");
	wifly.println();
    } else {
        Serial.println("Failed to connect");
    }
}

void loop()
{
    if (wifly.available() > 0) {
	char ch = wifly.read();
	Serial.write(ch);
	if (ch == '\n') {
	    /* add a carriage return */ 
	    Serial.write('\r');
	}
    }

    if (Serial.available() > 0) {
	wifly.write(Serial.read());
    }
}

/* Connect the WiFly serial to the serial monitor. */
void terminal()
{
    while (1) {
	if (wifly.available() > 0) {
	    Serial.write(wifly.read());
	}


	if (Serial.available() > 0) {
	    wifly.write(Serial.read());
	}
    }
}

My Wifly Is programed as follows (its set to USB mode as micro gives me a sync error)

  • $$$ to enter command mode in the serial monitor

  • then I set the SSID - set wlan ssid myLanSSID

  • then i set t the phrase - set wlan phrase xxxx-xxxxx

  • then I save and reboot..

This then connects the Wifly to my network: I receive the associated and READY messages, I also succesffuly went through these steps: http://www.tinkerfailure.com/2012/02/setting-up-the-wifly-rn-xv/

So technically with everything set up it should work, however it does not...

When I load my sketch and run it I get the following output in the Serial Monitor:

Starting
Free memory: 1337
setPrompt failed
Failed to enter command mode
Failed to start wifly
Terminal ready

I have no idea where it gets these from... and why I would get these messages.
setPrompt failed
Failed to enter command mode

is there a setup that I am missing. a little help would be nice :slight_smile:

THanx for the responses so far... hopefully the above is more in detail.

I've not used the wireless proto shield BUT the WIFly modules (or at least the one I use) talk to the arduino via serial (and you can use serial no need for softserial or such). So Ditch the libs. connect the wiFly to pins 0 and 1 and just use serial.

You have the option of send control sequences to the WiFly to control the connection. or just sending data.

Look at the WiFly's data sheet and ditch the lib's.

A good tip is never use a lib until you can do without it!!!!.

Mark