I would like to use a Wemos D1 mini pro to read a serial port of another device. Can I use the TX and RX pins at the same time i’m using the onboard USB connection to program? I may be wrong but i believe i read somewhere that the TX and RX pin are shared with the onboard USB, is that correct? Or are these totally separated?
Hardware serial (as opened with
Serial.begin(115200) for example) on Wemos D1 mini pro uses UART0 of ESP8266, which is mapped to pins TX (GPIO1) and RX (GPIO3).
Serial1 (opened with
Serial1.begin(115200)) uses UART1 which is a transmit-only UART. UART1 TX pin is D4 (GPIO2, LED).
You can also use pins D7 and D8 (= GPIO 13 / RXD2 or GPIO 15 / TXD2) instead. All you have to do is insert the instruction
Serial.begin() in the setup.
The downside of this technique is that you then cannot use serial monitor to help with monitoring and debugging your code. You can still upload new code in the normal way, because that involves resetting the Wemos, which reverts the hardware serial back to the original pins. But after the .swap(), serial monitor stops working.
Indeed fair point
Are these D7 and D8 pins using another UART? Or is this just a convenient way to make sure you still can use the USB to upload code so that the connected serial device does not interfere with the USB TX/RX for uploading? (otherwise you would need to connect/disconnect the serial device & USB all the time)
It’s just pins te-assignment
I found these WiFi kit 8 for development work, they are the same as a D1 Mini but with an added display. You can use serial as others have suggested and use the display for debugging information. Once you have finished you can out your code on a D1 Mini unchanged and it will work, you just won’t have the display.
I don’t seem to get that swap working on my Wemos D1 mini pro. I had hoped that i could switch during reading of the device and then swap back for debugging. But the suggestion to attach an OLED to it for debugging is a nice idea.
How do you know when to switch? How do you know the device on the serial port is sending data? It seems to me like making things more painful than they need to be trying to do it like that.
Good point, didn’t thought about that… thx