WiFi.SSID(thisNet)

Hello ,
I have an issue when i use WiFi.SSID(); in an if condition , this condition never happens.
For example if (WiFi.SSID(thisNet) == "NetworkName") { //Do Smthng } because i have more than access point and i need to choose between them.

I don't know , although i am writing network name right , this doesn't come true ever !
or i missed the real type of value returned by WiFi.SSID().

Any solutions ?

Without any further clues such as the sketch itself its hard to make even a guess.

To help its always best to give as much information as possible.

You will see lots of posts get much better responses with more information.
If you are willing to post your sketch then please use the code tags ( </> )

Hi @EngSamy,

You can't use == to compare C strings.

A few options for you to try:

  1. Try strcmp: if(strcmp(WiFi.SSID(thisNet), "NetworkName") == 0)
  2. Convert both values to an Arduino String then use ==: if(String(WiFi.SSID(thisNet)) == String("NetworkName"))

As @Ballscrewbob mentioned it's always better if you can provide a sketch to reproduce the issues.

sandeepmistry:
Hi @EngSamy,

You can't use == to compare C strings.

A few options for you to try:

  1. Try strcmp: if(strcmp(WiFi.SSID(thisNet), "NetworkName") == 0)
  2. Convert both values to an Arduino String then use ==: if(String(WiFi.SSID(thisNet)) == String("NetworkName"))

As @Ballscrewbob mentioned it's always better if you can provide a sketch to reproduce the issues.

I tried strcmp and it worked well
Thank a lot sandeepmistry