Is it possible to use the 'TX' and 'RX' pins on a D1 Mini for serial communication with, say, a Pro Micro?
The USB data interface would not be used other than for programming the D1 Mini.
I've read this thread: Wemos D1 mini pro and serial but it refers to the Pro version of the D1 and, tbh, no-one there has actually said it's feasible. For example, I know the on-board CH340 is connected to these pins but I don't know whether that precludes them from also being used to communicate with an external module. I also realize that the ESP8266 runs on 3.3v, while the Pro Micro uses 5v. I didn't think this would be a problem per se, since the HIGH level on the D1 Mini would be around 66% of the supply rail on the Pro Micro and I would use a voltage divider on the Pro Micro's Tx output.
Yes, I could just wire it up and try it, but I don't want to destroy anything in the process!
As far as I've got it it's electrically okey, referring to an UNO, to use the USB Tx/Rx connected to D0/D1 if the USB cable is disconnected. If the same applies to Your controller, more knowing helpers have to say.
Good thinking.. And the voltage divider as you describe is what it is all about. You might also consider whether or not the Arduino is redundant. I don't know anything about the D1 but, if you are short of i/o, a port expander can be a better bet than using two micro-controllers.
So the Atmega16u2 on the UNO definitely doesn't interfere with any input you send from an external module to the RX pin on the Atmega 328P? I thought it might hold it high while no serial signal from the USB.
I don't know the details for that, only what is posted in reply #2. And the need for level shifters when combining 3.3 volt logic with 5 volt logic. 3.3 volt signals into a 5 volt device is okey but not the opposite, 5 volt into a 3.3 volt device.
This application needs to be powered from USB on a PC, have a USB interface that looks like a game pad to the PC (easy peasy on a Pro micro) and needs WiFi (e.g. using a D1 mini).
Certainly there will be better solutions (wrt discrete component count) but I was looking for something easy to work and using readily available components. If you know of a ready-made board that combines EASILY programmable WiFi with an EASILY programmable USB interface (e.g. for which there are libraries such as Matthew Heironimus' Joystick for simulating gamepads) I'd appreciate your sharing.
Appreciate your replies, but possible interaction between the USB interface chip and serial exchange with an external board is really what I'm seeking more information on wrt Wemos D1 Mini board's Tx and Rx pins. Someone must have actually proven, one way or another.
Not sure if I get it. That "interaction" puzzles me. What "interaction"? Never mind, that's beyond my territory. Other helpers are needed.
The USB serial circuitry can't be used freely. Serial.print goes out on the standard serial output pins of the central unit. The USB interface circuit has its serial protocol as far as I've got it.
The UNO USB port is a client and can't be used as server(?) If this applies to Your controller, I can't say.
I'm sure there are helpers knowing that! I don't. Get Yourself a cup of coffee, a can..., whatever and wait a little!
Outside of the voltage divider for the 5v logic levels into a 3.3v MCU, there is the consideration of the Micro not having the UART0 pins exposed, which means that you would have to connect to UART1 instead, so if you want direct communication with the Wemos, you should load the SerialPassthorugh onto the Micro.
Forget USB interfaces, or clients and servers. I don't envisage plugging anything into the USB socket on the D1 mini, other than to program the ESP8266. I'd probably power it via a 3V3 regulator etc. coming off the RAW pin on the Pro Micro.
The USB is not relevant to the issue other than, with no serial data coming from it, it means the output (Tx) on the CH340C would probably be continuously held HIGH (or it may be LOW ... not sure of the convention). This output is, of course, directly connected to the ESP8266's Rx pin internally on the D1 mini board. But the idea is to connect this to the Tx1 pin (not Tx - thanks @Deva_Rishi for pointing that out) on the Pro Micro (i.e. a Tx pin connected directly to Rx pin to facilitate TTL-level serial transmission from Pro Micro to D1 mini).
This means I would have two digital outputs (on CH340C and on ATMega328P) connected to the Rx input on the ESP8266. So what happens when one MCU attempts to drive the connection HIGH, while the other tries to drive it LOW? This is the interaction that I was referring to.
Thanks! I will look into that. It's heading for midnight Sunday here, so it won't be tonight.
I may also investigate using just one-way data exchange (D1 mini to Pro micro) as I believe there is another pin on the mini that can be used for Tx only.