Serial monitor small window is present, but actual window is nowhere to be seen

Hello! I am using a simple code for my ESP32 (shown at the end of my question). I have uploaded it succesfully, but the problem is:

When I open my serial monitor, the small window as shown on the image below pops up, indicating that the serial monitor has been opened, but the actual serial monitor window doesn't appear when I click on it, nor is it anywhere to be seen when I search through my opened windows; it's practically not present anywhere. I have restarted my pc, but the problem persists. Can somebody help? Thanks in advance!

The code that I am using:

#include <BLEDevice.h>
#include <BLEServer.h>
#include <BLEUtils.h>
#include <BLE2902.h>

BLECharacteristic *pCharacteristic;
bool deviceConnected = false;
int txValue = 0;

#define SERVICE_UUID            "6E400001-B5A3-F393-E0A9-E50E24DCCA9E"
#define CHARACTERISTIC_UUID_TX  "6E400003-B5A3-F393-E0A9-E50E24DCCA9E"          

class MyServerCallbacks: public BLEServerCallbacks {
  void onConnect(BLEServer* pServer){
    deviceConnected = true;
  };

  void onDisconnect(BLEServer* pServer){
    deviceConnected = false;
  }
};

void setup() {
  Serial.begin(9600);

  // Create the BLE Device
  BLEDevice::init("ESP32");

  // Create the BLE Server
  BLEServer *pServer = BLEDevice::createServer();
  pServer->setCallbacks(new MyServerCallbacks());

  // Create the BLE Service
  BLEService *pService = pServer->createService(SERVICE_UUID);

  // Create a BLE Characteristic
  pCharacteristic = pService->createCharacteristic(
                      CHARACTERISTIC_UUID_TX,
                      BLECharacteristic::PROPERTY_NOTIFY
                      );

  //BLE2902 needed to notify
  pCharacteristic->addDescriptor(new BLE2902());

  // Start the service
  pService->start();

  // Start advertising
  pServer->getAdvertising()->start();
  Serial.println("Waiting for a client connection to notify...");
}

void loop() {
  if (deviceConnected){
    txValue = random(-10,20);

    // Conversion of txValue
    char txString[8];
    dtostrf(txValue, 1, 2, txString);

    // Setting the value to the characteristic
    pCharacteristic->setValue(txString);

    // Notifying the connected client
    pCharacteristic->notify();
    Serial.println("Sent value: " + String(txString));
    delay(500);
    }
}

That rings a very faint bell with me, but I can't recall the exact circumstances. It had to do with using a second screen previously, where I had the monitor open. Then next time it wouldn't open if I didn't have a second screen. I had to attach a second screen again, open the monitor, pull it to the main screen, and after that it was ok when the second screen was plugged out.

Something like that anyway, sorry I can't be more precise.

So, have you recently used a second screen?

1 Like

I indeed have used a second screen before. I will try what you just said :slight_smile:

double check in the Arduino15 directory the preference.txt file

There might be an entry like
last.serial.location=2525,487,1083,1237

I suspect the numbers are the position, width and height of the Serial monitor

editing those could possibly bring the window back into the main screen

1 Like

The last screen on which I opened my serial monitor was a second screen in my office, but I am currently at home and have tried to connect my PC to my TV-screen and haven't found the serial monitor... I think I should connect it to my office screen. Thanks for your help :slight_smile:

If you can find that entry that J-M-L suggested, perhaps you could edit it and cheat it back to the main screen?

1 Like

I have checked the "last.serial.location" and it showed me some position coordinates of my widescreen. Now I have changed the position values and lef the size values: "last.serial.location=0,0,1123,455", but the serial monitor still doesn't show up :confused:

I also have tried "last.serial.location=100,100,1123,455" but no results...

Unfortunately I don't have my widescreen with me at the moment to see if it pops up there.

I haven't checked those numbers in that preferences file, but I did just verify what I said earlier with my second screen.

If you have the monitor open on the second screen, and close the IDE, when you next open the IDE the second screen needs to be there when you open the monitor. Then you can drag it back to the main screen, and after that it works as normal.

I'd call that a bug.

1 Like

Do you think the type of monitor it was last opened on matters? Because, like I said, I opened it on my widescreen the last time. When I now connect my pc to the TV-screen I can't find the serial monitor.

I really have no idea- all I can report is what happened with me, sorry!

Did you use the same connector?- perhaps monitor at work was hdmi and the tv is vga and it sees them as different in some way? Pure speculation....

1 Like

I used HDMI for both.

Ok, no problem, thanks for your time :wink:

With the keyboard shortcut [Windows] + [Shift] + [→] [←] it should be possible to move windows between different screens. ( You must activate the window with [alt][tab] before - or by clicking on the small window ).

Is that even with no physical second screen?

(Issue here is that if the monitor is open on screen 2 then the ide is closed, next time round the ide still expects screen 2 to be there.)

1 Like

may be you could try moving the preference file out of the arduino directory (don't delete it, just move it out of the way) and with a little luck the IDE will recreate a default one.

1 Like

It indeed created another file. When opening the file, the last serial location shows this:

last.serial.location=-2309,218,1123,455

So my modifications (that I mentioned above) went away.

@J-M-L

The important thing to know when working with the preferences.txt file is that the Arduino IDE loads it from disk into memory on startup, then writes the memory contents back to the file on exit.

So this means two things:

  • Changes made to the file while the IDE is open (including deleting or moving it) will be reverted
  • The IDE will only recognize changes after you have restarted it.
1 Like

The practical moral of the story here, to me, is simply to remember to close the monitor if it's open on a second screen, or drag it to the main screen, before closing the IDE. Then next time you run the IDE it will work.

1 Like

That solved my problem! I closed every window, then opened preferences.txt and edited the postition by changing this:

last.serial.location=-2309,218,1123,455

to this:

last.serial.location=100,218,1123,455

Then restarted my pc and the problem was solved :slight_smile:

Thank you!

1 Like

Good to know - great

Have fun

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.