Go Down

Topic: Wifly arduino shield RSSI Vout (signal strength) (Read 3529 times) previous topic - next topic

00lewisd

Hi,

I have bought a Wifly shield for Arduino (http://www.sparkfun.com/products/9954). I want to read the strength of any Wifi signal in the area to control some LEDs, I noticed that the module incorporates a function called "show RSSI" as it says in the data sheet: http://www.sparkfun.com/datasheets/Wireless/WiFi/WiFlyGSX-um2.pdf.

I can't figure out how to successfully read a value for RSSI (signal strength). Would somebody be able to help me get started with this code?

Most recent library for Wifly: http://forum.sparkfun.com/viewtopic.php?f=32&t=25216.

This library includes three example codes.


Please help!!

Thanks, Darren.

johnwasser

Do you have a serial port connected to the WiFly UART port?

You switch to command mode by sending "$$$".  I think you have to send nothing else within one seconds before and one second after.
Code: [Select]

delay(1000);
WiFly.write("$$$");
delay(1000);

If the first thing you get back is not "CMD" then something is wrong.
Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

dxw00d

I voted for the second option, although I'm still not sure if I was right.

Hope that helps.

PaulS

I voted for the first option, just to be contrary.

Hope that helps.

johnwasser

I was going to vote for the underdog but they are tied at 1 and 1 so I'm going to boycott this poll instead.
Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

00lewisd

Thank you for that.

Using: WiFly.write("$$$"); came up with an error: 'class WiFlyDevice' has no member named write. I replaced it with Serial.write("$$$");.

It returns: <2.23>

My code is attached to this post.


Darren

00lewisd

Actually the code wasn't attached. Here it is:


#include "WiFly.h"
#include "Credentials.h"


void setup()
{
  Serial.begin(9600);      //initialise serial comms

  WiFly.begin();          //initialise WiFly comms

  delay(1000);
  Serial.write("$$$");        //initialise command mode
  delay(1000);
}


void loop(){

  delay(100);

  Serial.write("show rssi");      //request RSSI value

    while(SpiSerial.available()) {
    Serial.print(SpiSerial.read(), BYTE);

    /* if (WiFly.join(ssid, passphrase)) {
     int ch = WiFly.read();
     Serial.println(ch);
     
     }
     */
    if(Serial.available()) { // Outgoing data
      SpiSerial.println(Serial.read(), BYTE);
    }
  }
}

PaulS

Code: [Select]
Serial.write("show rssi");      //request RSSI value
Serial.write() is for binary data. Serial.print() is for strings and for converting numeric types to strings. Why are you using Serial.write() this way?

Quote
Using: WiFly.write("$$$"); came up with an error: 'class WiFlyDevice' has no member named write. I replaced it with Serial.write("$$$");.

What is connected to the Serial port?  Why didn't you try LCD.write()?

00lewisd

I was using Serial.wite() because I saw someone using it in another post. I'm now using SpiSerial.print() and the comms works with that.

This is a page about troubleshooting using the WiFly shield:

http://forum.sparkfun.com/viewtopic.php?f=32&t=25129

00lewisd

My code is able now to write a series of commands to the WiFly shield in the following order:
- $$$ (with no carrige return)(this command enters command mode)
- set wlan ssid BTHub3-Q9Z8
- set wlan phrase df2387da92
- join BTHub3-Q9Z8
- show rssi

It seams to bring back a number for the signal strength (RSSI) but it isn't very consistent and its very slow to respond when I move the shield relative to my wifi router. My code:


#include "WiFly.h" // We use this for the preinstantiated SpiSerial object.
//#include "WiFlySerial.h"


int pos = 0;
int crap = 0;
int rssi_read = 0;
int rssi_val = 0;
long i = 0;


void setup() {

  Serial.begin(9600);
  Serial.println("SPI UART on WiFly Shield terminal tool");
  Serial.println("--------------------------------------"); 
  Serial.println();
  Serial.println("This is a tool to help you troubleshoot problems with the WiFly shield.");
  Serial.println("For consistent results unplug & replug power to your Arduino and WiFly shield.");
  Serial.println("(Ensure the serial monitor is not open when you remove power.)"); 
  Serial.println();

  Serial.println("Attempting to connect to SPI UART...");
  SpiSerial.begin();
  Serial.println("Connected to SPI UART.");
  Serial.println();

  Serial.println(" * Use $$$ (with no line ending) to enter WiFly command mode. (\"CMD\")");
  Serial.println(" * Then send each command followed by a carriage return.");
  Serial.println();

  Serial.println("Waiting for input.");
  Serial.println();
}


void loop(){
  Serial.println("loop");

 

//void command(){
  delay (1000);
  SpiSerial.print("$$$");      //enters WiFly's command mode, should return CMD
  delay (1000);
  Serial.print(SpiSerial.read(), BYTE);
 
 
  SpiSerial.println("set wlan ssid BTHub3-Q9Z8");
  //delay (2000);
  Serial.print(SpiSerial.read(), BYTE);
 
  SpiSerial.println("set wlan phrase df2387da92");
  //delay (200);
  Serial.print(SpiSerial.read(), BYTE);
 

  SpiSerial.println("join BTHub3-Q9Z8");
  delay(2000);
  Serial.print(SpiSerial.read(), BYTE);
  delay(2000);
  Serial.print(SpiSerial.read(), BYTE);
  delay(2000);


  SpiSerial.println("show rssi");
  Serial.print(SpiSerial.read(), BYTE);
 

  for(;;){
  SpiSerial.println("show rssi");
  Serial.print(SpiSerial.read(), BYTE);   
  }
 

00lewisd

I based my code on the sample code:  SpiUartTerminal.pde

This code gives me a good predictable RSSI reading that dynamically updates when I move the shield relative to my router.

This code can be found here: http://forum.sparkfun.com/viewtopic.php?f=32&t=25129

And here:



/*

  SpiUartTerminal - tool to help troubleshoot problems with WiFly shield

  This code will initialize and test the SC16IS750 UART-SPI bridge then enable you
  to send commands to the WiFly module.

  Copyright (c) 2010 SparkFun Electronics. http://sparkfun.com LGPL 3.0

*/

#include "WiFly.h" // We use this for the preinstantiated SpiSerial object.


void setup() {

  Serial.begin(9600);
  Serial.println("SPI UART on WiFly Shield terminal tool");
  Serial.println("--------------------------------------"); 
  Serial.println();
  Serial.println("This is a tool to help you troubleshoot problems with the WiFly shield.");
  Serial.println("For consistent results unplug & replug power to your Arduino and WiFly shield.");
  Serial.println("(Ensure the serial monitor is not open when you remove power.)"); 
  Serial.println();
 
  Serial.println("Attempting to connect to SPI UART...");
  SpiSerial.begin();
  Serial.println("Connected to SPI UART.");
  Serial.println();
 
  Serial.println(" * Use $$$ (with no line ending) to enter WiFly command mode. (\"CMD\")");
  Serial.println(" * Then send each command followed by a carriage return.");
  Serial.println();
 
  Serial.println("Waiting for input.");
  Serial.println();   
 
}


void loop() {
  // Terminal routine

  // Always display a response uninterrupted by typing
  // but note that this makes the terminal unresponsive
  // while a response is being received.
  while(SpiSerial.available() > 0) {
    Serial.print(SpiSerial.read(), BYTE);
  }
 
  if(Serial.available()) { // Outgoing data
    SpiSerial.print(Serial.read(), BYTE);
  }
}

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy