# How to get the RSSI of the current connection?

**URL:** <https://community.particle.io/t/how-to-get-the-rssi-of-the-current-connection/15203>\
**Category:** Cloud\
**Created:** [September 7, 2015, 9:09pm UTC](https://community.particle.io/t/how-to-get-the-rssi-of-the-current-connection/15203 "2015-09-07T21:09:21Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![jaed1990](https://avatars.discourse-cdn.com/v4/letter/j/c77e96/32.png) [@jaed1990](https://community.particle.io/u/jaed1990)\
**Post date:** [September 7, 2015, 9:09pm UTC](https://community.particle.io/t/how-to-get-the-rssi-of-the-current-connection/15203/1 "2015-09-07T21:09:21Z")

</div>

- how to get the RSSI of the current connection ???

---

<div class="post-metadata">

**Author:** ![Moors7](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/moors7/32/588_2.png) [@Moors7](https://community.particle.io/u/Moors7)\
**Post date:** [September 7, 2015, 9:38pm UTC](https://community.particle.io/t/how-to-get-the-rssi-of-the-current-connection/15203/2 "2015-09-07T21:38:49Z")

</div>

If you try a quick forum search for “RSSI”, several topics pop up.  
Also, reading the documentation has never hurt anyone:  
[https://docs.particle.io/reference/firmware/photon/#wifi-rssi-](https://docs.particle.io/reference/firmware/photon/#wifi-rssi-)

---

<div class="post-metadata">

**Author:** ![jaed1990](https://avatars.discourse-cdn.com/v4/letter/j/c77e96/32.png) [@jaed1990](https://community.particle.io/u/jaed1990)\
**Post date:** [September 7, 2015, 10:02pm UTC](https://community.particle.io/t/how-to-get-the-rssi-of-the-current-connection/15203/3 "2015-09-07T22:02:54Z")

</div>

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](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.

---

<div class="post-metadata">

**Author:** ![Moors7](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/moors7/32/588_2.png) [@Moors7](https://community.particle.io/u/Moors7)\
**Post date:** [September 7, 2015, 10:25pm UTC](https://community.particle.io/t/how-to-get-the-rssi-of-the-current-connection/15203/4 "2015-09-07T22:25:35Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![jaed1990](https://avatars.discourse-cdn.com/v4/letter/j/c77e96/32.png) [@jaed1990](https://community.particle.io/u/jaed1990)\
**Post date:** [September 7, 2015, 11:58pm UTC](https://community.particle.io/t/how-to-get-the-rssi-of-the-current-connection/15203/5 "2015-09-07T23:58:31Z")

</div>

The library does not work with the device me I have.  
That’s why I say I use Adafruit\_CC3000\_Library

---

<div class="post-metadata">

**Author:** ![Aurelian](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/aurelian/32/6742_2.png) [@Aurelian](https://community.particle.io/u/Aurelian)\
**Post date:** [September 8, 2015, 5:42am UTC](https://community.particle.io/t/how-to-get-the-rssi-of-the-current-connection/15203/6 "2015-09-08T05:42:23Z")

</div>

Hello guys,

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

```auto
    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](http://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.

---

<div class="post-metadata">

**Author:** ![Moors7](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/moors7/32/588_2.png) [@Moors7](https://community.particle.io/u/Moors7)\
**Post date:** [September 8, 2015, 8:35am UTC](https://community.particle.io/t/how-to-get-the-rssi-of-the-current-connection/15203/7 "2015-09-08T08:35:08Z")

</div>

> [@jaed1990](#):
>
> The library does not work with the device me I have.

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.

---

<div class="post-metadata">

**Author:** ![ScruffR](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/scruffr/32/6952_2.png) [@ScruffR](https://community.particle.io/u/ScruffR)\
**Post date:** [September 8, 2015, 8:46am UTC](https://community.particle.io/t/how-to-get-the-rssi-of-the-current-connection/15203/8 "2015-09-08T08:46:45Z")

</div>

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 😉

And to get RSSI of not connected networks, you might like to have a look here  
[List Discovered Wifi Networks](https://community.particle.io/t/list-discovered-wifi-networks/4051)

* * *

_I took the liberty to add this to the code above_ 😉

---

<div class="post-metadata">

**Author:** ![Aurelian](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/aurelian/32/6742_2.png) [@Aurelian](https://community.particle.io/u/Aurelian)\
**Post date:** [September 8, 2015, 8:50am UTC](https://community.particle.io/t/how-to-get-the-rssi-of-the-current-connection/15203/9 "2015-09-08T08:50:12Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![jaed1990](https://avatars.discourse-cdn.com/v4/letter/j/c77e96/32.png) [@jaed1990](https://community.particle.io/u/jaed1990)\
**Post date:** [September 8, 2015, 6:33pm UTC](https://community.particle.io/t/how-to-get-the-rssi-of-the-current-connection/15203/10 "2015-09-08T18:33:51Z")

</div>

As I say I’m using:

Adafruit\_CC3000\_Library -\> [https://github.com/adafruit/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](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.

---

<div class="post-metadata">

**Author:** ![jaed1990](https://avatars.discourse-cdn.com/v4/letter/j/c77e96/32.png) [@jaed1990](https://community.particle.io/u/jaed1990)\
**Post date:** [September 8, 2015, 6:34pm UTC](https://community.particle.io/t/how-to-get-the-rssi-of-the-current-connection/15203/11 "2015-09-08T18:34:34Z")

</div>

> [@ScruffR](#):
>
> m

As I say I'm using:

Adafruit\_CC3000\_Library -\> [GitHub - adafruit/Adafruit\_CC3000\_Library: Library code for Adafruit's CC3000 WiFi breakouts &c](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](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.

---

<div class="post-metadata">

**Author:** ![bko](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/bko/32/20704_2.png) [@bko](https://community.particle.io/u/bko)\
**Post date:** [September 8, 2015, 7:06pm UTC](https://community.particle.io/t/how-to-get-the-rssi-of-the-current-connection/15203/12 "2015-09-08T19:06:16Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![jaed1990](https://avatars.discourse-cdn.com/v4/letter/j/c77e96/32.png) [@jaed1990](https://community.particle.io/u/jaed1990)\
**Post date:** [September 8, 2015, 7:33pm UTC](https://community.particle.io/t/how-to-get-the-rssi-of-the-current-connection/15203/13 "2015-09-08T19:33:24Z")

</div>

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

If no other way, because either way.

Thank you.

---

<div class="post-metadata">

**Author:** ![peekay123](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/peekay123/32/810_2.png) [@peekay123](https://community.particle.io/u/peekay123)\
**Post date:** [September 8, 2015, 7:40pm UTC](https://community.particle.io/t/how-to-get-the-rssi-of-the-current-connection/15203/14 "2015-09-08T19:40:49Z")

</div>

@jaed1990, I believe you are in the wrong community for your questions. You need to go to the [Adafruit forum](http://forums.adafruit.com/viewforum.php?f=22) 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. 😃

---

<div class="post-metadata">

**Author:** ![Exit2Studios](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/exit2studios/32/17135_2.png) [@Exit2Studios](https://community.particle.io/u/Exit2Studios)\
**Post date:** [May 3, 2018, 7:49pm UTC](https://community.particle.io/t/how-to-get-the-rssi-of-the-current-connection/15203/15 "2018-05-03T19:49:40Z")

</div>

> [@Aurelian](#):
>
> 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
> }
> 
> ```

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?

---

<div class="post-metadata">

**Author:** ![incorvia](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/incorvia/32/10961_2.png) [@incorvia](https://community.particle.io/u/incorvia)\
**Post date:** [May 16, 2018, 3:40pm UTC](https://community.particle.io/t/how-to-get-the-rssi-of-the-current-connection/15203/16 "2018-05-16T15:40:43Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Ric](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/ric/32/514_2.png) [@Ric](https://community.particle.io/u/Ric)\
**Post date:** [May 16, 2018, 3:57pm UTC](https://community.particle.io/t/how-to-get-the-rssi-of-the-current-connection/15203/17 "2018-05-16T15:57:03Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![incorvia](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/incorvia/32/10961_2.png) [@incorvia](https://community.particle.io/u/incorvia)\
**Post date:** [May 16, 2018, 4:01pm UTC](https://community.particle.io/t/how-to-get-the-rssi-of-the-current-connection/15203/18 "2018-05-16T16:01:46Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Ric](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/ric/32/514_2.png) [@Ric](https://community.particle.io/u/Ric)\
**Post date:** [May 16, 2018, 4:16pm UTC](https://community.particle.io/t/how-to-get-the-rssi-of-the-current-connection/15203/19 "2018-05-16T16:16:28Z")

</div>

> [@incorvia](#):
>
> Is there something I’m missing with the first version?

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?

---

<div class="post-metadata">

**Author:** ![ScruffR](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/scruffr/32/6952_2.png) [@ScruffR](https://community.particle.io/u/ScruffR)\
**Post date:** [May 16, 2018, 4:16pm UTC](https://community.particle.io/t/how-to-get-the-rssi-of-the-current-connection/15203/20 "2018-05-16T16:16:44Z")

</div>

[`WiFi.RSSI()`](https://github.com/particle-iot/firmware/blob/develop/wiring/inc/spark_wiring_wifi.h#L128) doesn’t return an `int` but an object like this

```cpp
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.

[Next page](https://community.particle.io/t/how-to-get-the-rssi-of-the-current-connection/15203.md?page=2)
