How to get the RSSI of the current connection?

If I understand the Wifi library has a method that makes what I’m asking.

I confundie me to ask my question.

I am using this library:
Adafruit_CC3000_Library -> https://github.com/adafruit/Adafruit_CC3000_Library

And I am q I see wlan_ioctl_get_scan_results used to scan signals.

But I just need the RSSI of my current connection.

What device are you using? The CC3000 is only present on the Core. If you’re using the Photon, you might not want to use that adafruit library.

What’s wrong with the function I linked to in the docs?

The library does not work with the device me I have.
That’s why I say I use Adafruit_CC3000_Library

Hello guys,

If you are using photon, as far as i remember you just have to do something like :

    int rssi = 0;
    
    void setup() {
       Particle.variable("RSSI", &rssi, INT);
    }
    
    void loop() {    
        rssi = WiFi.RSSI();
        Particle.publish("rssi", String(rssi), 60, PRIVATE);
        delay(1000);  // not to offend the rate limit for publish of 1/s
    }

and it will work, and show you on dashboard.particle.io the data ;

Have fun.

Maybe i`m wrong but it works for me and this is new to me as well.

Take care.

2 Likes

Then, which device do you have? The Core or the Photon? Unless you tell us that, there's little we can do but guess.
As far as I'm aware WiFi.RSSI(); is documented for both the photon and the Core, thus should work on either.
Have you given that a try already?

Try the example from @Aurelian, looks like it should work.

I’d just add that the code above will most likely offend the rate limit for publishing of 1/s.

So add a delay(1000) at the end of loop :wink:

And to get RSSI of not connected networks, you might like to have a look here
List Discovered Wifi Networks


I took the liberty to add this to the code above :wink:

2 Likes

Oh yes. you are right , i forgot about that, if cloud not needed than serial can be used. it was just a sample to get the rssi feedback. Good point.

Thanks for the update.

As I say I’m using:

Adafruit_CC3000_Library -> https://github.com/adafruit/Adafruit_CC3000_Library

I see using the method “wlan_ioctl_get_scan_results” -> https://github.com/adafruit/Adafruit_CC3000_Library/blob/master/utility/wlan.cpp

But that is to capture all signals it finds.

What I want is for the signal to which it is connected.

Thank you.

As I say I'm using:

Adafruit_CC3000_Library -> GitHub - adafruit/Adafruit_CC3000_Library: Library code for Adafruit's CC3000 WiFi breakouts &c

I see using the method "wlan_ioctl_get_scan_results" -> https://github.com/adafruit/Adafruit_CC3000_Library/blob/master/utility/wlan.cpp

But that is to capture all signals it finds.

What I want is for the signal to which it is connected.

Thank you.

Hi @jaed1990

I think we are confused by your question–do you have a Particle Core or Photon? In either case you do not need the Adafruit CC3000 Library. It will not be useful and everything in that library and more is already in the system firmware for a Core. In particular, the WiFi.RSSI method.

If you do not have a Particle Photon or Core, then I can tell you that wlan_ioctl_get_scan_results is a library function provided by the TI CC3000 driver that fetches infomation about all the current WiFi networks from the TI part. There is no other WiFi scanning API in the TI driver. In order to find the RSSI of the current network, you first have to get the current network SSID and then look though the data table returned by the TI driver function wlan_ioctl_get_scan_results to find the entry that matches your SSID. There is no other way that I know of to get that information.

1 Like

I am using a card CC3000 wireless shield, so I use that library

If no other way, because either way.

Thank you.

@jaed1990, I believe you are in the wrong community for your questions. You need to go to the Adafruit forum under “Other Arduino products from Adafruit” and search for CC3000 there.

We can’t help you here since this is the Particle (formerly Spark) product support community. The first generation Spark Core used the TI CC3000 but the newer Photon no longer does. :smiley:

3 Likes

I used the following code and it worked, however I get a crazy number returned (536901568). What do I need to do to get it into the correct RSSI range?

I also have this issue of getting an out of range number 536904604. Am I doing a type conversion wrong?

Are you using the same code that @Exit2Studios posted? I tested that code, and it works fine for me (though the Particle.variable syntax should be changed to the current version). Which device are you running your code on?

I fixed my error, apologizes for the false alarm… For some reason:

char rssi[10];
sprintf(rssi, "%i", WiFi.RSSI());
Serial.println(rssi);

Does not work, printing 536904604 to the console, but

Serial.println(String(WiFi.RSSI()));

Works. Is there something I’m missing with the first version?

Note: it seems using itoa instead of sprintf fixes the issue as well… not sure what I’m misunderstanding about sprintf.

I don't see anything wrong with that, in fact, that's the way I would do it. When I test your first version, it works fine for me. Can you post the whole code, so I can see it in its context?

WiFi.RSSI() doesn’t return an int but an object like this

class WiFiSignal : public particle::Signal {
public:
    // In order to be compatible with CellularSignal
    int rssi = 2;
    int qual = 0;

    WiFiSignal() {}
    WiFiSignal(const wlan_connected_info_t& inf);
    virtual ~WiFiSignal() {};

    operator int8_t() const;

    bool fromConnectedInfo(const wlan_connected_info_t& sig);

    virtual hal_net_access_tech_t getAccessTechnology() const;
    virtual float getStrength() const;
    virtual float getStrengthValue() const;
    virtual float getQuality() const;
    virtual float getQualityValue() const;

    // virtual size_t printTo(Print& p) const;

private:
    wlan_connected_info_t inf_ = {0};
};

Since sprintf() does only take pointers to the provided parameter and does the type casting based on the format string the compiler doesn’t help selecting the correct overload, but if you use (int8_t) cast overload you should get what you want.

1 Like

Hmm that's interesting, from the documentation

WiFi.RSSI() returns the signal strength of a Wi-Fi network from -127 (weak) to -1dB (strong) as an int. Positive return values indicate an error with 1 indicating a Wi-Fi chip error and 2 indicating a time-out error.

Doesn't that seem to indicate that WiFi.RSSI() returns an int?

You said it right, it seems so, but what the eye sees isn’t always what’s real :wink:

1 Like