Open Cosmicbase opened 1 year ago
The values here depend on the wiring you create for the esp32. If you connect the wires to tjose pins then the file should remain untouched otherwise you should modify it acording to the schematic you implement.
Can you write an example yaml that works? I would then like to adjust it. I will use the standard pins which are also provided as an example.
The one I am using is in the example folder https://github.com/Bunicutz/ESP32_Midea_RS485/blob/main/example/esp32_midea_RS485_HA_sample/aer-conditionat.yaml
esphome: name: salon-ac friendly_name: Salon AC
esp32: board: esp32dev framework: type: arduino
logger:
api: encryption: key: "B2gKcvD3IL+n68y20EPk9QrsZDrIWsUbVTOe0lRHc5o="
ota: password: "e6b73dd2b92010079064f8630df6197e"
wifi: ssid: !secret wifi_ssid password: !secret wifi_password
ap: ssid: "Salon-Ac Fallback Hotspot" password: "GIUWS1FzMcMA"
includes:
bunicutz_AC.h
libraries:
sensor:
platform: custom id: my_AC lambda: |- auto my_ACSensors = new BunicutzACSensor(id(my_ac_mode),id(my_ac_fan_mode),id(ac_set_temp),id(ac_aux_heat),id(ac_echo_sleep),id(ac_vent),id(ac_swing),id(ac_lock)); App.register_component(my_ACSensors); return {my_ACSensors->ACT1Temp, my_ACSensors->ACT2ATemp, my_ACSensors->ACT2BTemp, my_ACSensors->ACT3Temp, my_ACSensors->ACNotResponding }; sensors:
name: "AC In Air Temp"
unit_of_measurement: "°C"
accuracy_decimals: 0
name: "AC Coil A Temp"
unit_of_measurement: "°C"
accuracy_decimals: 0
name: "AC Coil B Temp"
unit_of_measurement: "°C"
accuracy_decimals: 0
name: "AC Outdoor Temp"
unit_of_measurement: "°C"
accuracy_decimals: 0
name: "AC Com State"
unit_of_measurement: "bool"
accuracy_decimals: 0
select:
platform: template name: "AC Mode" optimistic: true id: my_ac_mode options:
platform: template name: "AC Fan Mode" optimistic: true id: my_ac_fan_mode options:
number:
switch:
platform: template name: "Auxiliary Heat" id: ac_aux_heat optimistic: true
platform: template name: "Echo/Sleep" id: ac_echo_sleep optimistic: true
platform: template name: "Swing" id: ac_swing optimistic: true
platform: template name: "Vent" id: ac_vent optimistic: true
platform: template name: "Lock" id: ac_lock optimistic: true
INFO Reading configuration /config/esphome/salon-ac.yaml... Failed config
wifi: [source /config/esphome/salon-ac.yaml:22] ssid: !secret wifi_ssid password: !secret wifi_password ap: ssid: Salon-Ac Fallback Hotspot password: GIUWS1FzMcMA
[includes] is an invalid option for [wifi]. Please check the indentation. includes:
bunicutz_AC.h
[libraries] is an invalid option for [wifi]. Please check the indentation. libraries:
I can`t install.
When i take your yaml. The following error ist coming.
INFO Reading configuration /config/esphome/salon-ac.yaml... ERROR Error while reading config: Invalid YAML syntax:
expected '
Do you have esp home installed in the HA? If yes in the copy ghe first chunk of code in the esphome: section and the rest after mqtt: section in the template generated by esphome for the device. The sections are delimited by #........... in the example yaml file.
Hi @Cosmicbase , I guess I understand where you are coming from and why you are asking those question. I feel to be in a similiar position. It is actually my first ESPhome and ESP project at all and the learning curve is quite steep jumping directly into this project here.
Let's start with some basics, which I think I understood so far:
I was able to to do the hardware wiring and the deployment of the firmware to an ESP32.
However, I am still missing something which I don't get due to lack of understanding. I have an Olimex ESP32-POE-ISO (which is probably at bit overkill) I connected three available GPIO ports to the MAX485 and defined those GPIO ports in the bunicutz_AC.h.
What else Do i need to adjust from these parameters
begin:
hwSerial - ESP32 HW serial unit connected to the bus
ro_pin - RI pin
di_pin - RO pin
re_de_pin - RE/DE pin
master_id - id of the master
slave_id - id of the slave
command_time - time in ms needed for command: ~40ms (you can play with it untill no message is lost anymore)
response_timeout - time after which the response is read: ~100ms
It is a bit trial and error at the moment for me. What role does hwSerial play? What is the correct setting for master and slave ids?
It would be really great if @Bunicutz could shade some light here. Thanks a lot.
Hi guys @Cosmicbase @Flachzange Sorry but I did not get any feedback on the thread so I just forgot about it.
I am not an expert in ESP home nor in AC units :) and I will try to layout my understanding on it and how it works:
SW side:
HW side:
I tried to give out in the examples the values that worked for me. You can start from those and then joggle with them until it works.
@Flachzange @Cosmicbase I hope this helps you guys.
Thanks @Bunicutz . That helped a lot to confirm my understanding. My issue: I can conly see the messages being sent by the ESP but I am not getting a response. I played a little with the timings but that's a bit frustrating trial & error. Can I see whether there are com errors without having an oscilloscope? Some kind of debug output on the ESP itself?
I had a look at the terminal board for the indoor unit and it indeed it seems I can set an ID here, but it is not documented somehwere.
Available documentation: https://shop.systemair.com/upload/assets/IOM_TERMINAL_BARD_GB_210621.PDF?d17ebad7
Just to be explicit. My output is the following:
[09:52:50][D][custom:209]: SentData: aa c0 0 0 80 0 0 0 0 0 0 0 0 3f 81 55
[09:52:50][D][custom:250]: ReceivedData: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
[09:52:50][D][select:015]: 'AC Mode': Sending state Off (index 0)
[09:52:50][D][select:015]: 'AC Fan Mode': Sending state Auto (index 0)
[09:52:50][D][number:012]: 'AC Set Temp': Sending state 18.000000
[09:52:50][D][sensor:094]: 'AC In Air Temp': Sending state 0.00000 °C with 0 decimals of accuracy
[09:52:50][D][sensor:094]: 'AC Coil A Temp': Sending state 0.00000 °C with 0 decimals of accuracy
[09:52:50][D][sensor:094]: 'AC Coil B Temp': Sending state 0.00000 °C with 0 decimals of accuracy
[09:52:50][D][sensor:094]: 'AC Outdoor Temp': Sending state 0.00000 °C with 0 decimals of accuracy
[09:52:50][D][sensor:094]: 'AC Com State': Sending state 0.00000 bool with 0 decimals of accuracy
Hi @Flachzange it seems that the AC is not responding. How long is the wire you are using? Can you also send a picture with the ESP wiring? Please try to identify what does the jumper from the documentation. Other debug method would be to buy a usb to rs485 converter and try to sniff the bus with that( connect it in paralal to the bus) using a serial terminal pc application. This will show if the AC is responding at all or not and if the esp is sending something on the bus.
Really appreciate your support. The length of the cable is ~1,20m. I quickly draw a schema of the wiring:
A little bit unexpected, I also found a documentation of the switch:
Therefore, everything is correctly set at the indoor unit. ID is 0
@Flachzange I sue the same cable length. I think I may have a clue about the issue: please use other pin than GPIO 0 and 2 it is used for bootloader for reflashing and might do something unexpected during boot also if I am not mistaken they might have some pullups/downs connected. Please revert timing values to default an try it out like that. Sorry but it is time for trial an error again... :)
@Flachzange also try to disable usage of UART by the ESP Home code by setting the debug level to NONE or try to set the baud rate for the logger to 4800 : https://esphome.io/components/logger.html
https://esphome.io/components/uart.html
If this still does not work the I would suggest to get a simpler ESP32 dev board with serial 2 available just to have exclusivity with the AC on the bus. I am not sure how the AC reacts to higher baud rates on the bus and it might enter some weird state.
Thanks @Bunicutz. I am completely puzzled.
please use other pin than GPIO 0 and 2 it is used for bootloader for reflashing and might do something unexpected during boot also if I am not mistaken they might have some pullups/downs connected.
I tried various other ports. Without success.
also try to disable usage of UART by the ESP Home code by setting the debug level to NONE or try to set the baud rate for the logger to 4800 : https://esphome.io/components/logger.html
I cannot see any console output once disabled ;) But I moved the logger to UART2. Without success.
If this still does not work the I would suggest to get a simpler ESP32 dev board with serial 2 available just to have exclusivity with the AC on the bu
I already ordered a standard ESP32 dev kit yesterday which I could try today. I used the following pins:
#define DI_PIN 16
#define RO_PIN 17
#define DE_PIN 5
#define RE_PIN 5
#define SERIAL_COM_BUS &Serial2
#define SERIAL_COM_CONTROL_PIN DE_PIN
#define SERIAL_COM_MASTER_ID 0
#define SERIAL_COM_SLAVE_ID 0
#define SERIAL_COM_MASTER_SEND_TIME 40
#define SERIAL_COM_SLAVE_TIMEOUT_TIME 100
This makes use of the dedicated serial 2.
Let me know if you have any idea left and sorry for bothering!
Hi @Flachzange no worries. That devkit is exactly the one I have so it should work directly with the example. If that does also not work perhaps the port on the AC is not enabled somehow... but that is leaving my competence area... :) I would look for jumpers or missing(unpopulated) components on the board... but out of my league... sorry...
It seems I am doing something fundamentally wrong. Due the lack of an oscilloscope and a ready-to-use RS485-USB-Converter, I tried to use the second ESP as a sniffer on the bus. Similar to https://jheyman.github.io/blog/pages/RS485Sniffer/
Obviously, I removed the termination resistor on the MAX485 and configured then the UART in debug mode with 4800 baud:
uart:
tx_pin: 1
rx_pin: 3
baud_rate: 4800
data_bits: 8
parity: NONE
stop_bits: 1
debug:
But in the end I do not see anything on the bus...
Sorry but this leaves me puzzled. Could you try with a small led in the data lines between ESP and MAX and see if there is some activity there. Other ideas I don't have.... sorry.
Why do it simple when you can do it super complicated :) I have an "official" KNX bus coupler for the midea ACs with XYE. So I created the most simple KNX setup and the good thing is: I can receive the values. The bad thing is, I still don't know why the other solution is not working. I will do a small summer break now, but I will keep you posted on my efforts.
Edit: And with the sniffer I can see the traffic from the KNX device
Again, thanks for the help
Hello Bunicutz,
If I want to change the mentioned send time and slave timeout values, is it enough if I change them in the bunicutz_AC.h file?
Thank you in advance!
Hi golya87, Yes.
Sadly no luck, from 20 to 60. How can I check if the ESP really uses the 16-17 ports for the MAX485 module? I've connected a led to the X and E ports but haven't seen any blinking.
I would highly recommend either a rs485 to usb converter or an osciloscope. There are some low price solutions on the market.
Hi @golya87, you may want to contact me via discord (Flachzange31). Maybe we can figure this out together and come back here with the results.
@Flachzange @golya87 just had an issue with my device after a thunderstorm and some lightning on the powe grid. The P4 was damaged in the process. Without it on high (3.3V) there is no transmission happening. Perhaps this info can help in identifying your issue.
Hi @Bunicutz , just to be sure: you are talking about
define DE_PIN 4 define RE_PIN 4
Correct?
Hello @Flachzange, yes.
omg...as expected...something trivial: switchting DI and RO did the trick
My understanding was: The pin connecting DI is defined as DI_PIN. That understanding was wrong. The oscilloscope showed me the sending signal on the pin defined as RO_PIN. Looking at your code it then became obvious:
ESP32_Midea_RS485Class::ESP32_Midea_RS485Class(HardwareSerial *hwSerial, uint8_t ro_pin, uint8_t di_pin, uint8_t re_de_pin, uint8_t master_id, uint8_t slave_id, uint8_t command_time, uint8_t response_timeout): ComControlPin(re_de_pin), SerialBus(hwSerial), datain_pin(di_pin), dataout_pin(ro_pin),
The wires need to be crossed: RO_PIN needs to go to the DI input of the MAX485 and DI_PIN to RO.
Now I receive an answer from the AC and can control it.
P.S. There was no need for me to feed the 3.3V to DE_PIN/RE_PIN
I had the same problem. After swapping the tx and rx cables the controlling worked.
Please tell me what is wrong, why I can not compile this project?
do I need to remove the "#" in the file bunicutz_AC.h ?
Hi @klugev303 , a new issue ticket would have probably been the better choice.
The "#" must not be removed. But something else seems to be wrong based on the path and the compilation output. I suggest: create a new issue and post your yaml and bunicutz_AC.h.
Thanks
Do I have to adjust the data here? Unlike what is normal in yaml, here are the parameters in the bunicutz_AC.h.
midea_AC.h#include "esphome.h"
include
define DI_PIN 16 define RO_PIN 17 define DE_PIN 4 define RE_PIN 4
define SERIAL_COM_BUS &Serial2
define SERIAL_COM_CONTROL_PIN DE_PIN
define SERIAL_COM_MASTER_ID 0
define SERIAL_COM_SLAVE_ID 0
define SERIAL_COM_MASTER_SEND_TIME 40 define SERIAL_COM_SLAVE_TIMEOUT_TIME 100