2 ESP32's GPIOs to same header pins isolation - Page 1
Forum section: electronics / projects

author: Stealthrt
author_rank: Regular Contributor
timestamp: March 23, 2023, 02:49:49 am
content: Hey all I am wondering if my idea below would work.What I am wanting to do is connect 2 (really 3 ESP32's and 4 ATmega32u4's) micro controllers (in the example there are just 2 ESP32's for simplicity) and they both connect to the same header pins.I know that this would not work if both ESP32's were powered on but would this work if only 1 of the ESP32 were to be powered while the other has no power?I was unsure if this type of setup would cause an issue with one another? Or if this setup is fine as long as one is turned off?If this would not work what could you suggest I can use in order to isolate the 2 ESP32's from each other? I was thinking a multiplexer but that would just allow 1 GPIO pin to then have 16 more GPIO pins for it.I was also thinking about some type of reply but that would be a lot of relays to since the ESP32 has 25+ GPIO pins that I would connect to the headers.There was another thought of using some type of optocoupler but like the suggestion above, this would also have many of them for the 25+ GPIOs.Suggestions or confirmation would be great! Perhaps a IC that I have not heard of before that would be a good fit for this? Don't want to blow either upDisclaimer: Also posted onelectronics.stackexchange.comelectro-tech-online.comallaboutcircuits.com

author: james_s
author_rank: Super Contributor
timestamp: March 23, 2023, 02:54:47 am
content: Why do you want to connect them in this way?I don't know what the ESP32 IO pins do when the device is not powered, it might work, or you could power them both up and set the pins on the inactive device as inputs and then they won't interfere.

author: Stealthrt
author_rank: Regular Contributor
timestamp: March 23, 2023, 02:59:48 am
content: Quote from: james_s on March 23, 2023, 02:54:47 amJust a project I'm thinking about doing just to see if something like this would work.

author: james_s
author_rank: Super Contributor
timestamp: March 23, 2023, 03:01:04 am
content: Well you can certainly share IO pins, it's done all the time and is called a bus. You just have to make sure that only one thing is driving the bus at a time, everything else on it must be either tristated or inputs.

author: Stealthrt
author_rank: Regular Contributor
timestamp: March 23, 2023, 04:48:31 pm
content: Quote from: james_s on March 23, 2023, 03:01:04 amDo you have any suggestions on what kind of IC to use for that?

author: james_s
author_rank: Super Contributor
timestamp: March 23, 2023, 04:51:17 pm
content: The 74LS245 is a common one, but you can use any IC that has tristate outputs, any modern microcontroller.

author: Stealthrt
author_rank: Regular Contributor
timestamp: March 23, 2023, 04:56:00 pm
content: Quote from: james_s on March 23, 2023, 04:51:17 pmAnd the 74LS245 would work with both Analog and Digital in/out from/to the ESP2?

author: mikerj
author_rank: Super Contributor
timestamp: March 23, 2023, 05:33:36 pm
content: Quote from: Stealthrt on March 23, 2023, 02:49:49 amNo, a high level input to an IO pin on an unpowered device would cause the input diodes on the unpowered device to be forwards biased, dumping current into it's supply rails and seriously loading down your signal. Using something like a bus transceiver with tristate capability to isolate the powered down device will prevent this.

author: ajb
author_rank: Super Contributor
timestamp: March 23, 2023, 07:58:03 pm
content: You don't necessarily need an IC, depending on what you need to do with the IO pins. If you connect each MCU to the bus line through a diode with the cathode towards the bus, then each device can drive the bus high but not low. You might want a pulldown resistor to hold the bus line low when none of the devices are driving it. Flip the diodes around, and swap the pulldown for a pullup, and each device can drive the bus low but not high. Or you could have each node drive the bus high or low with a transistor rather than directly connecting the MCU's IO pin, which could provide improved current handling or possibly better ability to withstand faults on the bus (or at least have a transistor take the hit rather than the MCU directly) if those factors are important to you.Quote from: Stealthrt on March 23, 2023, 04:56:00 pmNo, the '245 is a digital buffer, it will buffer a digital signal in either direction depending on the state of the direction control line. If you need to be able to pass an analog signal you need an analog switch instead.

author: Ian.M
author_rank: Super Contributor
timestamp: March 23, 2023, 08:13:11 pm
content: *MOST* MCUs tristate (hi-Z) *MOST* of their I/O pins if held in reset. Check their specific datasheets for details, and any pins that don't get tristated. If that works for the pins you need, you simply need a reliable method of holding all their Reset pins except one MCU in the Reset active state (IIRC low for both ESP32 and ATmega).

author: Stealthrt
author_rank: Regular Contributor
timestamp: March 23, 2023, 11:26:47 pm
content: Would something like the 74HC157 be a good choice? I’m reading the data sheet on it and it seems to allow 4 gpio + 4 gpio and outputs one of them. But I’m not seeing anywhere about if it can do digital and analog since the gpio would be one or the other. Aside from that I’m also not seeing anywhere where the company makes a larger version that would have do more than 8 inputs.

author: james_s
author_rank: Super Contributor
timestamp: March 24, 2023, 01:10:54 am
content: If you need to switch analog you need an analog switch, not a digital logic IC. I'm still confused as to what the actual goal here is though, are you trying to accomplish anything or just wire stuff up for fun to see if it works?

author: Infraviolet
author_rank: Super Contributor
timestamp: March 24, 2023, 02:36:51 am
content: It will depend on what the header pins are used for, but you can put some series resistors of a few K to 10K between the each microcontroller's pin and the common point where wires from multiple microcontrollers come together. These resistors protect against the over-current hazards which could destroy microcontrollers if one of them is trying to drive high in to another driving low, as with the resistors such a situation just looks to each mcu like it is driving a small load low or high.If the header pin is an input to all the microcontrollers you'd make sure all of them had the relevant pins floating and then read them.If the header pin is an output them you'd use a situation where the pin is pulled up (or down) normally, and when a microcontroller wants to output on it this single one can drive down (or up) strongly by becoming a low impedance output pin in the low (or high) state. The same way multiple devices sare the data line of an I2C bus.In other scenarios you'd have to use other connections between the microcontrollers to negotiate between them for who has control of the shared line right now, and those series resistors would serve as protection (for mcu survival if not signal integrity) if this negotiation is ever messed up.The main thing to ask here though is what the purpose, in your situation, of multiple mcus sharing a header pin is.

author: DavidAlfa
author_rank: Super Contributor
timestamp: March 26, 2023, 02:35:57 am
content: The pin ESD diode will dump the pin voltage into VDD.

author: Stealthrt
author_rank: Regular Contributor
timestamp: March 26, 2023, 10:28:56 pm
content: Thanks for all the replies! I'm going back to my drawing board to figure some things out with the knowledge I now have. Thanks!

author: james_s
author_rank: Super Contributor
timestamp: March 27, 2023, 02:14:40 am
content: Quote from: DavidAlfa on March 26, 2023, 02:35:57 amIf both parts are on the same supply voltage? How is that going to happen?Technical details aside, I'm still struggling to figure out why someone would *want* to connect something in this manner. It frustrates me a little when someone wants help with a project but then won't share details about it.