0

I am starting in ESP32 and OTA. I am using the ArduinoOTA library.

The serial monitor output by connecting the ESP32 via USB works correctly.

I have already managed to upload my program to the ESP32 via Wifi. Works correctly.

But I am not able to see the traces of my program. It's a simple Loop with Serial.println("Test");

My platformio.ini configuration is this:

[env:ESP32_SCAFFOLDING]
platform = espressif32
board = esp32dev
framework = arduino
monitor_speed = 9600 ;Serial monitor speed (9600 or 
115200)

;CONFIG LOCAL
; upload_port = /dev/cu.usbserial-0001
; monitor_port = /dev/cu.usbserial-0001

;CONFIGURATION OTA
upload_protocol = espota
upload_port = 192.168.0.253
monitor_port = /dev/cu.Bluetooth-Incoming-Port

My Setup method:

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

  delay(5000); // delay five seconds.

  Serial.println("");
  Serial.println("UPLOAD BY WIFI");
}

And my Loop:

voud loop()
{
    Serial.println("WIFI LOOP!!");
}

I am working on a Mac Book Pro computer, with Monterey operating system

Javier
  • 395
  • 3
  • 18

2 Answers2

0

You set the monitor port to be a Bluetooth serial port.

monitor_port = /dev/cu.Bluetooth-Incoming-Port

You’re not using Bluetooth so there’s no way that’s going to work. Comment out that line to let PlatformIO automatically choose the port.

; monitor_port = /dev/cu.Bluetooth-Incoming-Port

This will only work when you're connected via USB.

It sounds like you're expecting that because you updated the ESP32's firmware over wifi you should also be able to see the serial output over wifi. That's not the case. There is no remote monitoring of serial output over Wifi. OTA is only for updating the firmware running on the ESP32. You will only see the serial output when you're physically connected to the device's serial port as you would be via USB.

romkey
  • 6,218
  • 3
  • 16
  • 12
  • Indeed, that line where you set the monitor_port to the Bluetooth port, was a "hopeless" test. So, having my ESP32 connected to Wifi, how can I see traces and do debugger traces? If I have a simple Serial.println (not connected by USB, only connected by WiFi) how can I see that trace and others? Thank you. – Javier Feb 21 '23 at 15:03
  • You don't over WIFi, as I said in my answer, that's not a thing. For one thing, there's no way to get boot loader or crash messages into the network stack. For another, when you're debugging you're likely to be halting the network stack, which remote debugging would depend on. You do debugging via a hardwired connection over serial, USB or JTAG. You can have your code log messages to your choice of server but that'll be separate from using `Serial` and you'll need to use a library like `Syslog` or write it yourself. – romkey Feb 21 '23 at 17:02
0

If you want to see logging info over the wifi connection then use the TLog library

https://www.arduino.cc/reference/en/libraries/tlog/

and then, for example:

#include <Log.h> 
TelnetSerialStream telnetSerialStream = TelnetSerialStream();

void setup() {
Serial.begin(115200); 
Serial.println("Started (this will only show up on serial)");

... start wifi network ...

Log.addPrintStream(std::make_shared<TelnetSerialStream>(telnetSerialStream)); 
Log.begin();

Log.println("Hello World");

Then telnet into the IP of the ESP32 to view the logging information.

Fuzzy
  • 847
  • 9
  • 23