1

enter image description here

The code works successfully but nothing happens in the serial monitor, what do I do as I've tried almost everything.

1
  • Your serial monitor's baud rate isn't set to 115200
    – Bra1n
    Commented Jul 31, 2022 at 6:43

3 Answers 3

4

No longer an issue.

Any fully released version of the 2.X IDE including the original 2.0.0 release should work. If you're having a problem these days it is probably because you've selected the wrong board causing problems as explained below.

At the time the original answer was given the 2.0-rc9.1 release candidate was current. IDE version 2.0-rc9.3 bundled arduino-cli version 0.27.0-rc.1 which contains code to make the relevant settings work. So every version form the official 2.0.0 release to current (version 2.1.1 as of this update).

Original Answer

In short, use the 1.X series IDE instead of the 2.X series IDE. As of writing, this would be IDE version 1.8.19.


In version 1.8.4 support for a board properties called .serial.disableDTR and .serial.disableRTS were added.

Certain boards, like the ESP32-CAM combined with the ESP32-CAM-MB require this feature in order for the Serial Monitor to see traffic (actually it's worse than that, which I'll explain below). The current 2.X series IDE (2.0-rc9.1 as of writing), which has a completely different code base, appears not to have re-implemented this feature. Presumably they will eventually.

When you install the 1.X series IDE, make sure you test the Serial Monitor with the ESP32-CAM selected. It may be counterintuitive that testing an Arduino UNO as your selected board wouldn't just work, given that you're only using the Serial Monitor and not actually compiling or uploading. But it will, no kidding, fail to work as this board's definition does not specify these .serial.disableDTR and .serial.disableRTS properties that the ESP32-CAM board description does.

In case you're wondering, ESP32 upload tool controls DTR and RTS itself irrespective of these board definition properties that affect the Serial Monitor and Serial Plotter. That's why your uploading works but your Serial Monitor fails under the current IDE 2.0 release candidate.

Without going into detail on what DTR and RTS are supposed to do, and what they can be made to do, etc, typical operating configurations for a serial port are such that when the port is open these signals are going to go active. The ESP32-CAM-MB board design is such that having both active DTR and RTS both active is effectively pushing down both the GPIO0 and rather crucially the EN/RESET buttons. In other words, without this additional fiddling that the 1.X series IDEs (with correct board selected) and esptool do, opening the serial port has the effect of holding your ESP32-CAM in reset (or NOT-enabling it if you like). So not only are you not getting any serial traffic, the board is simply not executing any code at all.


You have other options also, but each kind of requires an explanation in its own right. But, I can give you hints as to what they are:

It is possible to continue using the 2.0 IDE to do your development and upload but use something else instead of the 2.0 IDE's Serial Monitor. But it will introduce complexity, confusion, and annoyance into your setup. Whatever that "something else" is must allow for the disabling for DTR and RTS. Note that disabling DTR and RTS is not merely turning off flow control; that will not manipulate them and it will ignore their counterpart signals, but it will also leave them in the wrong state. One candidate is IDE 1.x's Serial Monitor. Another is RealTerm, which will allow you to clear DTR and RTS (in that order) to then work as a serial monitor. In any case you will need to close the serial connection yourself prior to each upload as the 2.0 IDE will be unable to do that on your behalf as it would normally do its own internal monitor.

You can also interrupt the DTR an RTS signals in hardware before the get to the ESP32-CAM board. Having done that, it no longer matters whether any software controls DTR and RTS, but you then need to manually operate GPIO0 and EN/RESET yourself to enter the bootloader. To accomplish that you'll either need to use a mess of jumpers and the ESP32-CAM-MB (or any other 3.3V serial transceiver) not mounted to the ESP32-CAM and construct push button circuits for GPIO0 and EN/RESET. Alternately you can physically modify the ESP32-CAM-MB in a way that interrupts DTR and RTS from the transceiver but keeps operational buttons. This can be done by desoldering a pair of diodes or cutting the traces on the way to the buttons and headers.

It may also only take a few well placed lines in one of the 2.0 IDE's javascript/typescript to crudely hack in a disabling of DTR and RTS, if you don't care what else it breaks. If I get bored maybe I'll look into that. Doing it properly in response to the correct board properties is a more involved project though.

3

If you use the command line, you can use this command to open a serial console to the esp32:

arduino-cli monitor -p /dev/ttyUSB0 --discovery-timeout 60s --config 'rts=off' --config 'dtr=off' --config 'baudrate=115200'

If you use the IDE, see the answer of timemage.

3
  • My answer was out of date so I've added that this should be a non-issue in non-release candidate 2.X version IDEs. With respect to ardunio-cli, if you're using 0.27.0-rc.1 onward, you should be able to specify esp32:esp32:esp32cam : whatever in --fqbn and that would make it so you didn't need the --config 'rts=off' --config 'dtr=off' options. But what you have should be good for dealing with old arduino-cli versions in any case.
    – timemage
    Commented Jul 11, 2023 at 22:42
  • I needed these parameters with the arduino-cli version 0.33. I have not tested 0.33.1 yet.
    – Alai
    Commented Jul 12, 2023 at 23:09
  • Odd. I've just tested with the 0.27.1 out of the 2.0.0 IDE package and it behaves in line with how I'd thought: arduino-cli monitor --port /dev/ttyUSB0 pulls RTS/RST low. Adding --fqbn esp32:esp32:esp32cam causes it not to do that per disableRTS. As does the --config options you've suggested without the --fqbn specified. -cli version 0.32.3 out of the latest IDE 2.1.1 behaves the same way. I don't have your exact version. I'll keep it in mind though. Maybe I've missed something.
    – timemage
    Commented Jul 13, 2023 at 2:05
2

I'm using platformIO and had the same issue. Disabling the RTS and DTR solved my problem too!

monitor_dtr = 0
monitor_rts = 0
1
  • 1
    I've barely touched PlatformIO. I'm just guessing these go a project config file. It would be better if this were filled out a bit so that someone running across it had that guidance.
    – timemage
    Commented Feb 10 at 22:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.