I am designing an ESP8266 based module that will provide control of a certain make of air condition utilizing an existing serial connection on the A/C.
The Tx,RX pins on the A/C side operate at 5-6V DC hence the need for level shifters to interface with 3V3 of the ESP module. I am of couse aware of the classic level shifter design like this :
A particular aspect of this system however is that the high voltage supply (5V) is not available locally.
I have drafted the following design which works fine for the Tx side (Q1) but for some reason the Rx (Q2) line dosnt work. ie the ESP can send data but it cannot receive any
The gate of Q2 may need to be pulled up. You may get away with pulling it up to 3V3.
ok... will try that.
You could make it available by creating 5V on the ESP side.
Right now I am creating 3V3 from the available 20V (shown as DC on pin 4 of the J2 header) using a switching converter.
Yes I know I could also create 5V but that would be a major change and the PCB has already been made. I d rather avoid it..
So you're patching things anyway; this means that anything that's physically possible, is in principle fair game. Of course, I'd try to get there with just 3V3 at this point as well.
As you found out, it's a good idea to make physical modules also functionally autonomous insofar as possible, or at least to think through the interfaces very well.
That's correct. I will probably have to have another iteration on this PCB anyway.
I just want to make sure that everything will be fine this time... and in that sense I want to find out exactly why is not working.
Yeah, good approach. And that's how it goes with PCB's much of the time anyway; you think you've got everything covered and then you still end up with a patch or two. To be honest, I usually just leave them patched instead of making a new version, unless I need to make several more identical ones. But many of my projects are one-offs, so I'm OK with some wires and additional components sticking out.
That always keeps me from doing it, too. For the most part I want my PCB to be in my hand by the next day or so, so I usually end up sacrificing an hour or two to DIY it.
True. However on the "5V' logic side, the HI voltage might be higher than 5V, so a simple voltage divider would be risky. I am also considering an opto-coupler if was to redo the design.
So are you bit banging it? Or does the ESP8266's serial peripheral let you specify the polarity? It's not just the data bits that would need to be inverted, but also the idle state and the start and stop bits. Well, it just seems strange, but if as you say the Tx side works ok, then maybe Rx does too. But if you're getting the signal at the ESP's Rx pin, then I agree with @jim-p that there must be a software problem.
You could un-invert it by changing the connections to the mosfet. Connect the source to the incoming line from the AC, and the gate to the 3.3V supply.
Edit: No you can't. High voltage would flow through the body diode.
Backing up a bit: The classic shifter you posted originally, that you rejected, is a bi-directional shifter. But Rx and Tx are not bi-directional, so only need to work in one direction each.
If your mosfet-based inverting Tx line, with no pullup on the 5V side, works now, then the classic non-inverting shifter would also work with no pullup on the 5V side.
The classic non-inverting shifter should also work on the Rx side with no pullup on the 5V side. At the ESP, the Rx pin will be 3.3V unless the AC brings it low. It doesn't matter what the AC brings it to when high.
So it appears you don't need access to the 5V rail to use the classic non-inverting shifter. But I assume the AC has a pullup to 5V or 6V on its Rx pin, in which case the idle voltage on that pin will be 5V or 6V, which would explain why your Tx works now with no pullup.