Go Down

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

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);   
  }
 

Go Up