I migrated from Arduino IDE to VS Code with PlatformIO, and have problem with Serial Monitor. Serial Monitor always prints ‘NUL’. Can someone help me ?
On reset, the ESP8266 will print bootloader messages at 74880 baud. Since you have set the monitor to 115200 baud, the USB-UART adapter cannot correctly the UART TX signal and prints the wrong data. What is being output at minotor_speed = 74880? I suspect your ESP just can’t boot.
I see that you’re using a Mac by that /dev/cu.usbserial* device name. Serial drivers for like CH340 chips are known to be very buggy / needing the exact right kernel driver. See Troubleshooting CH340G issues on macOS. If no sensible output is shown on any baud rate, a driver issue may be fault.
upload_speed = 460800 - didn’t help. Also, I didn’t found chip CH340 on my adapter
if I upload code via Arduino IDE everything works fine. I use ESP Link v1.0 adapter
I thing when I upload code via VS Code, it’s also working because led on my esp01 blinking
correctly I mean every 500milisec (I tried other value for milisec). Something wron with Serial
Yeah that one has a good CP2104 usb-serial chip on it with which I haven’t seen any problems reports with MacOS so far. With the CH340 though… a lot.
You can try and follow the above links to make sure you have the correct drivers installed for your Mac. The solution also depends on what Mac os you are running, as I remember that the vendor-drivers needed to be used for older Mac OS versions, but the built-in ones for higher Mac OS versions.
The cause of the problem is quite unexpected: it’s a conflict between the LED and the Serial output. The LED is on pin 2, so is the serial’s TX.
In PlatformIO, the LED_BUILTIN is correctly defined as 2. So your code outputs 1 Hz square wave instead of a TX signal. The LED will have worked.
In the Arduino IDE, you probably have something else selected as the LED pin or the selected board has a different selection. So the serial output was working, but probably the LED wasn’t.