ESP32 board test wifi shows 'non-printable' chars in serial monitor

Hello,

I have a question regarding a test I'm running on an 'ESP32 WROOM-32' MCU.
I'm using an "Instructables" for this test https://www.instructables.com/Introduction-to-ESP32/.
In the IDE I have selected the ESP32-WROOM-DA module from the list of boards.
After compiling and upload of the code


String networkSSID = "";
int strengthSignal = -9999;

void setup()
{
   // Initialize Serial to log in Serial Monitor
   Serial.begin(115200);

      // configuring the mode of operation of WiFi as station
      WiFi.mode(WIFI_STA);//WIFI_STA is a constant indicating the station mode

      // disconnect from the access point if it is already connected
      WiFi.disconnect(); 
      delay(100);

//    Serial.println("Setup done");
}

void loop()
{
//    Serial.println("scan start");

  // performs the scanning of available networks

    int n = WiFi.scanNetworks();
    Serial.println("Scan performed");

    //check if you have found any network 
    if (n == 0) {
        Serial.println("No network found");
    } else {
        networkSSID = "";
        strengthSignal= -9999;
        Serial.print(n);
        Serial.println(" networks found\n");
        for (int i = 0; i < n; ++i) {
    	  //print on serial monitor each of the networks found
          Serial.print("SSID: ");
          Serial.println(WiFi.SSID(i)); //network name (ssid)
          Serial.print("SIGNAL: ");
          Serial.print(WiFi.RSSI(i)); //signal strength
          Serial.print("\t\tCHANNEL: ");
          Serial.print((int)WiFi.channel(i));
          Serial.print("\t\tMAC: ");
          Serial.print(WiFi.BSSIDstr(i));
          Serial.println("\n\n");
          
 
          if(abs(WiFi.RSSI(i)) < abs(strengthSignal))
          {
             strengthSignal = WiFi.RSSI(i);
             networkSSID = WiFi.SSID(i);
             Serial.print("NETWORK WITH THE BEST SIGNAL FOUND: ( ");
             Serial.print(networkSSID);
             Serial.print(" ) - SIGNAL : ( ");
             Serial.print(strengthSignal );
             Serial.println(" )");
          }                        
         
          delay(10);
        }
    }
    Serial.println("\n------------------------------------------------------------------------------------\n");

// interval of 5 seconds to perform a new scan
    delay(5000);
}

the serial monitor shows 'non-printable' characters.

When selecting another board from the list in the IDE, it's posting 'can't find ttyUSB0.
What can/must I do to get the proper output to see whether its' identifying the Wi-Fi or not?
Any suggestion is much appreciated.
TIA

PS: the MCU is labeled as ESP32 WROOM-32

Hello,

Did you set the speed of the Serial Monitor to 115200bps?

After some research on the web, found some tips and changed the speed of the serial monitor from 9600 to 115200.
Now the output is readable, however it's not what the sketch is sending to the serial output.

mmh, Am little bit flustered.
Thanks

Yes at the begining the ESP32 displays always some infos about itself
If you wait a bit more, it will print what you have in your code. Try to uncomment the

Change the board to a DOIT

Changed the board as suggested.
However that does not resolved the problem.

It's still printing the block I have posted earlier but not the connect messages.

Also, as Antony_P suggested, I activated the line ....("scan start");
But that does not have an functionality to the sketch.

:confused:

Do you have any objhection to using one of the 'standard' examples to do a network scan?


I use "ESP32 Dev Module"
Did you try the Blink sketch ?
You can try the example, just before the setup you add `#DEFINE LED_BUILTIN 2
Also, do you have anything connected to the board?

I Run the suggested example sketch WiFi Scan and this is my output from serial:

Everything is the same as earlier today.
Can compile, can connect, can upload. But the result is not as expected.

Selected board is DO IT ESP32 DevKit V1
What do I do wrong? :face_with_steam_from_nose:

Blink sketch is working fine.

I think I have to change the subject of this tread. 'non-printable characters' does not apply anymore.
:slight_smile:

Try another board, that is a stock sketch and should work.

Does it mean the board is not working properly?
I could switch to a WEMOS D1R2 (ESP8266).

Sure give it a try.

Try that board

Hi @domify80. When I'm having trouble with serial output, I like to do a quick check with the most simple possible sketch. If this works, then I know the problem has something to do with my real sketch. If it doesn't work, then I know the problem is not related to my sketch code. It seems maybe a little silly, but it allows me to be sure I'm focusing my troubleshooting efforts in the right direction.

Try uploading this sketch to your Arduino board:

  1. Copy and paste this code as a new sketch in Arduino IDE:

    void setup() {
      Serial.begin(115200);
    }
    
    void loop() {
      Serial.println("hello");
      delay(1000);
    }
    
  2. Select Sketch > Upload from the Arduino IDE menus.
    Arduino IDE will start an upload operation.

  3. Wait for the upload to finish successfully.
    :red_exclamation_mark: If it does not finish successfully, add a reply here on the forum topic to inform us of the failure and we'll investigate further.

  4. Select Tools > Serial Monitor from the Arduino IDE menus to open the Serial Monitor view if it is not already open.

  5. Make sure the baud rate menu at the top right corner of the Serial Monitor panel is set to "115200".

Do you now see the word "hello" being printed in the Serial Monitor's output field once a second?

Note that it is normal and expected to see some additional output in Serial Monitor immediately after uploading a sketch, resetting the board, or powering on the board. As explained already by @Anthony_P, the ESP32 microcontroller automatically prints some diagnostic information to the serial port on startup, even when your sketch program doesn't contain any code that would produce such output. But we also expect to see the serial output that is produced by the sketch program in Serial Monitor following the diagnostic information.

I am able to compile, upload and run simple sketch with "Hello World' and with a blink on the on-board LED.
At the moment when I'm uploading a sketch with Wi-Fi functionality I have no success (see earlier posting with the block of information I posted).

I tested also a Wi-Fi connection with an LOLIN (WEMOS) D1R2 and that is working fine.
I think I have to focus either on the library that I'm using for the ESP32 or the code itself.
I will investigate further and will post after some new results.
If you have in the meantime any suggestions, please let me know.

Thanks

There is some ambiguity in this answer. Please answer the question with one of the following answers:

  • Yes, I do see the word "hello" being printed in the Serial Monitor's output field once a second.

  • No, I do not see the word "hello" being printed in the Serial Monitor's output field once a second.

  • I did not understand the instructions you provided.

  • I tried to follow your instructions but encountered a problem that did not allow me to complete them.

1 Like

My interpretation is that the code you gave is working, the Blink example is working, but not the rest.

What I don't understand is more like, why I didn't get any feedback from this post @domify80?

Consider that ^ as a

YES