esphome-panasonic-ac icon indicating copy to clipboard operation
esphome-panasonic-ac copied to clipboard

🎉 Tested and Confirmed: Working on an ESP8266 NodeMCU 🎉

Open Expaso opened this issue 3 years ago • 10 comments

Perhaps not the correct place to share this information, but nice to hear anyway!

I still had some ESP8266 NodeMCU's laying around that I wanted to designate to this task. But.. as you already suggested, these only have 1 full UART (the second one is TX only).

This is fixable in the ESP Config, by moving the Log component to UART-1 (instead of the default UART-0):

# Enable logging
logger:
  hardware_uart: UART1 #Uses D4 (GPIO2) as LOG output!

And so we freed up UART-0 for our purpose:

uart:
  rx_pin: GPIO3
  tx_pin: GPIO1
  id: ac_uart
  baud_rate: 9600
  parity: EVEN

Yes, we loose logging on the default USB port, but hey, who cares! We have logging over WIFI. (and a fallback on Pin GPIO2 if we would ever need it).

No level shifter / Logic Converter

Next, I wanted to skip the level shifter. I don't think it's really needed, and here's why:

  1. The ESP is 5v tolerant on it's IO pins.
  2. Even if it's not (since the internet is 50/50 on this one) we can fix this.

Please note! This trick works because the Panasonic AC has resistors in series with it's TX and RX lines!

  • For TX line on the ESP, we don't have to change anything. We can drive the RX line of the AC directly. This line is pulled-up by a resistor in the AC, and the ESP will simply pull it down hard when sending signals. The ESP's internal clamping diodes will make sure the voltage on this line never reache a too high value (also because of the series resistor on the line at AC side). If you are really worried about your $3 module, add a 3v3 zener-diode to GND for this task.

  • For the RX line on the ESP, we have to solder a 1k resistor between GND and RX on the ESP Side. The TX line of the AC also has a series resistor, but.. there is also a pull-up resistor on the NodeMCU (because this line is also still attached to the usb2serial chip of the NodeMCU module. The combination leads to the situation whereby the voltage won't go low enough when the AC pulls this line low. To counter this effect, adding a 1K resistor to GND will shift this line's voltage more towards ground (like a voltage divider). Now, this line won't go higher then 3.3V. This line won't go to GND completely (because of the series resistor) so to be even more on the safe side around this low-voltage, you can go as low as 500Ohm's for this resistor if your NodeMCU is very picky.

P.S.

For the fanboys who read the ESP's 8266 datasheet: Yes, you can move the hardware UART to pin GPIO13 and 15 instead of GPIO3 and GPIO1. But.. Your ESP won't boot, because

image https://randomnerdtutorials.com/esp8266-pinout-reference-gpios/

So, connecting your AC (with idle-high tx and rx lines) to this pin will prevent booting your ESP. It's a pity, because from an electrical perspective, this would be the better option.

I also tried D4 and D5 pins with a soft-uart, but couldn't get it to work.

Expaso avatar Jun 22 '21 20:06 Expaso

Good to know that it works, logging via USB isn't needed anyway most of the time.

I also tried D4 and D5 pins with a soft-uart, but couldn't get it to work.

I'm surprised that it didn't work since the AC uses a fairly low baudrate of 9600, nothing a ESP8266 should struggle with.

The ESP8266 and ESP32 are both 5V tolerant, but it's out of spec so I still recommend a logic converter since it's not really complicated to connect through it and they are cheap.

DomiStyle avatar Jun 23 '21 09:06 DomiStyle

Agreed, if you have a logic converter, that is the best option. Problem was, I only had 2 left, and I needed to replace 4 wifi units.

I will retry the soft uart option using a scope, see if I can find anything weird.

Could you clarify out of spec? I always learned that TTL 5v and 3v3 were digitally compatible: https://learn.sparkfun.com/tutorials/logic-levels/all

Expaso avatar Jun 24 '21 19:06 Expaso

Out of spec for the ESP8266 data sheet, which lists a working voltage of 2.5V to 3.6V. Doesn't really matter if it works though.

DomiStyle avatar Jun 29 '21 08:06 DomiStyle

Ah you mean that.

For the VSS, the nodemcu has ofcourse its own 3.3v regulator., so you will always stay in-spec there.

For the IO, above measures will make sure you also stay within specs, because of the 1k resistor on the RX line (forming a voltage divider) and the 3.3v zener on the TX line. No 5v will ever reach 3.6v or higher on any pin if you take these measures.

Indeed, working out of specs is asking for trouble, so I value your caution.

Expaso avatar Jun 29 '21 19:06 Expaso

Is it possible to consolidate this info into README.md? Or perhaps better an esp8266.md doc linked from README rather than in the issue tracker? I'm going to look to try this as soon as I can.

foxy82 avatar Aug 12 '21 11:08 foxy82

This worked for me without a logic converter.

I needed a 500 ohm resistor instead of the 1k mentioned (I actually didn't have any 500 ohms to hand so used a 470 ohms which worked as well).

foxy82 avatar Oct 31 '21 08:10 foxy82

I confirm that it works fine as sad and it's possible to leave UART0 to debug logging. I've used GPIO13 for RX and GPIO2 for TX transmission

uart:  
  rx_pin: GPIO13  
  tx_pin: GPIO2  
  baud_rate: 9600  
  parity: EVEN

In this way we don't risk boot failure as well as we can continue to use usb for debugging. I did it this way because I couldn't use UART0 to communicate with the AC conditioner but in the end it's even better.

zioCristia avatar Feb 18 '22 20:02 zioCristia

I confirm that it works fine as sad and it's possible to leave UART0 to debug logging. I've used GPIO13 for RX and GPIO2 for TX transmission

@zioCristia, Do you use logic converter? I use Wemos D1 mini with logic converter and GPO1 for TX and GPIO3 for RX, but it doesnt work (no reply for commands, no status receiving from AC). I've opened an issue here.

Can you help me to fix it?

alex-v-fraser avatar Mar 17 '22 08:03 alex-v-fraser