Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ESP32 - D1 Mini Pro #43

Open
sanderlv opened this issue Oct 27, 2022 · 25 comments
Open

ESP32 - D1 Mini Pro #43

sanderlv opened this issue Oct 27, 2022 · 25 comments

Comments

@sanderlv
Copy link

sanderlv commented Oct 27, 2022

Hi, I have tried to use a D1 Mini Pro ESP32 instead of an ESP8266. But to no avail, it just wont boot.

I want to use the advantage of also using the new bluetooth proxy component in the ESP32.

Is there any hard coding towards ESP8266?

Is it possible to use an ESP32?

board type: wemos_d1_mini32

@sanderlv
Copy link
Author

Some more info:

The ESP8266 (working):
image

The ESP32 (not working):
image

20221027_210715
20221027_210726

@arpiecodes
Copy link
Contributor

First thing that comes to mind is that you should check the pins. The pin layout is different, and you may need to change some around in the core library's h and/or c files. Also, I think you can remove the CPU frequency option as it may be invalid for ESP32.

@sanderlv
Copy link
Author

sanderlv commented Oct 28, 2022

I think, that the pin layout is pretty equal. The other tip I will try somewhere next weeks.

And about the other, I hope someone can confirm/deny that some programmatic changes are needed (not yaml, but the others: core library's h and/or c files).

@arpiecodes
Copy link
Contributor

If you can't even get it to boot/join your WiFi, something is probably trying to do something that is not possible or causes an error on the ESP32. You might be able to hook-up the ESP32 to the serial monitor built-into the Arduino desktop app to debug a bit what error is triggered.

@arpiecodes
Copy link
Contributor

arpiecodes commented Oct 28, 2022

PS: Pins are definitely different. Please see https://github.com/ginkage/MHI-AC-Ctrl-ESPHome/blob/master/MHI-AC-Ctrl-core.h#L33. They determine which pins to use for SPI communication. The ESP32 does not have specific purpose default pins (like the 8266 has) for SPI, you will have to tell it what to do on each pin.

If we look at the pinout for the one you have there, the edits should be something like this inside MHI-AC-Ctrl-core.h to get the SPI working;

#define SCK_PIN  18
#define MOSI_PIN 23
#define MISO_PIN 19

Also, connect the ESP32 based variant entirely at your own risk. ;-) No guarantees given.

EDIT: Updated pins. Was looking wrong as ESP32 has two rows of pins. Please see below image for pinout reference used.

image

Note that it is not possible to mix both ESP8266 and ESP32 devices if you edit the core library pins. They are not pin-compatible. We may need to open a feature request to be able to set the pinout from library/core initialisation. Or simply copy the library files and include the correct variants into your projects.

@sanderlv
Copy link
Author

I think from now on ESP32 is the only viable option and most future proof. Lower power and better wifi and BLE.

I really would appreciate support for this 😀

@arpiecodes
Copy link
Contributor

If you can test it out with above pinout and it works, the maintainer of the library could consider the possibility of setting the pins in such a way that it remains drop-in compatible with this project.

@arpiecodes
Copy link
Contributor

Have you tested it out yet with above config? I also got intrigued by the possibilities of using an ESP32 instead of an 8266 and eventually extending the module in the AC with (for example) a PM2.5/PM10 sensor. So I've also ordered some ESP32 Mini's now.

@sanderlv
Copy link
Author

sanderlv commented Nov 8, 2022

Hi, no not yet and no active plans. Since I discovered shelly plus which have esp32 and I can flash with esphome I do not really need them yet...

@sanderlv
Copy link
Author

Can you please elaborate on "how to submit" a feature request? Still would like to have ESP32's in my aircos...

@ElBarto333
Copy link

Little update for everybody else who might want to try to use an ESP32 D1 Mini.
I got it running by changing the pin definitions in MHI-AC-Ctrl-core.h as pointed out by @synegic.

#define SCK_PIN  18
#define MOSI_PIN 23
#define MISO_PIN 19

My config in ESPHome looks like this:

esphome:
  name: some-name
  platform: ESP32
  board: esp32dev
  platformio_options:
    # Run CPU at 160Mhz to fix mhi_ac_ctrl_core.loop error: -2
    board_build.f_cpu: 160000000L
  includes:
    - mhi_ac_ctrl.h
    - MHI-AC-Ctrl-core.h
    - MHI-AC-Ctrl-core.cpp

Everything else is unchanged.

When the ESP32 is only connected via USB to my PC I get the same error as in #29.
But as soon as I plug it into my indoor unit I can control my air conditioner via ESPHome/Home Assistant.

Hope this helps.

@acfnews
Copy link

acfnews commented Jan 15, 2023

Hi all, I also like to help with this (as I would really like to use WPA3 WiFi features only available on ESP32), but to enlarge the success factor, I am wondering where you guys but your ESP32 boards, and what version?
I am thinking on buying 5 pieces at once (to have some spare and for fiddling around).

I only have 2 TTGO devices left, which do not suffice for the MHI interface.

Any tips for decent price versus normal shipping times in Europe are greatly appreciated.
I did find for example:
amazon

I just want to buy the proper board so I can focus on the MHI side of things.

@ervee
Copy link

ervee commented Jan 15, 2023

Last time I bought an ESP it was from TinyTronics. I bought this one:
https://www.tinytronics.nl/shop/nl/development-boards/microcontroller-boards/met-wi-fi/wemos-c3-mini-esp32-c3

Mind you this is not a D1 but C3 variant with the RiscV processor architecture and I'm not sure if it does WPA3. They have other variants too.

I also order from HobbyElectronica:
https://www.hobbyelectronica.nl/product-categorie/wemos/boards-wemos/

I don't know too much about the success factor thought. I think the D1 mini V3 is pretty okay but heard people who order from sketchy sources getting bad clones with mixed results.

@hberntsen
Copy link

hberntsen commented Jan 16, 2023

I've got an Ai-Thinker ESP-C3-32S-Kit board. I'm rewriting the code to use hardware SPI on the IDF platform, which works fine :). So harware-wise that's possible

@ervee
Copy link

ervee commented Jan 16, 2023

That's nice!
I also got an ESP32 C3 13U 2MB board a while ago . It was cheap but it does not have a wifi antenna on the board (you need an antenna with a wire) so keep that in mind. Also the small flash size is a pain but I got my project running on it with OTA capability but I'm pretty sure the MHI project is way too big for this board so...

@glsf91
Copy link

glsf91 commented Feb 7, 2023

I've got an Ai-Thinker ESP-C3-32S-Kit board. I'm rewriting the code to use hardware SPI on the IDF platform, which works fine :). So harware-wise that's possible

Did you had any success with this?
Are still using esphome with this modified code?

@hberntsen
Copy link

Yes, I've got two running in my home right now, works great. I'm not on full feature parity with this repo yet but works fine so far. I'm looking at the developments in absalom-muc/MHI-AC-Ctrl#77 to implement those as well.

@glsf91 are you interested? My code needs some cleaning but I can upload whatever I already have if that helps

@glsf91
Copy link

glsf91 commented Feb 7, 2023

@hberntsen
Yes, I'm interested. If you can upload your code somewhere (github?) that would be nice.
I already used an esp32 with MHI-AC-Ctrl code (not esphome) but experience too much mhi_ac_ctrl_core.loop errors. I managed to make a better but I'm not satisfied yet. Have also to take a look again.
So I was interested if IDF and hw SPI was doing a lot better.

@hberntsen
Copy link

I'm also tracking Bluetooth advertisements on both ESPs (for temperature), the one with 8 temperature sensors attached to it sometimes generates frame errors:
screenshot-2023-02-07-134558

The other one with just one sensor a lot less (0 since last boot). I did not investigate the cause of them. Given that we receive a new frame every 40ms the error rate is quite low :). I'm planning to report the Bluetooth temperature to the AC as reference temp.

The trick with Hardware SPI on my ESP32-C3 was to generate a CS signal on the ESP itself, and loop it back to the hardware SPI CS pin. Otherwise It would never receive a frame. The ESP docs say that it should be able to operate without CS signal but I could not get that to work at all.

I've dumped my code at https://github.com/hberntsen/mhi-ac-ctrl-esp32-c3 :)

@glsf91
Copy link

glsf91 commented Feb 7, 2023

A lot of work to change this. I'm not familiar with IDF, so takes some time to try to understand your code.
I also want tracking Bluetooth advertisements.

The trick with Hardware SPI on my ESP32-C3 was to generate a CS signal on the ESP itself, and loop it back to the hardware SPI CS pin. Otherwise It would never receive a frame. The ESP docs say that it should be able to operate without CS signal but I could not get that to work at all.

Strange that the other project you referring to (homekit) is not using a CS.

@hberntsen
Copy link

Strange that the other project you referring to (homekit) is not using a CS.

Indeed, though that project is targeting the ESP32, not the C3 variant.

@glsf91
Copy link

glsf91 commented Feb 8, 2023

I have an ESP32 (D1 mini ESP32 clone). So this means it maybe could work without CS and therefore I can use the mhi-ac-ctrl PCB.
I will give it a try later. First trying some other stuff.

@HarrisonPace
Copy link

@ElBarto333

Little update for everybody else who might want to try to use an ESP32 D1 Mini.

Can anyone comment on the long term stability, I am considering using a ESP32 as it's a lot better option in most contexts in 2023.

Did you encounter any issues? Apart from setting the pin definitions and CPU frequency, did everything else simply 'work'?

@ElBarto333
Copy link

ElBarto333 commented Aug 20, 2023

@thehaxxa

Can anyone comment on the long term stability, I am considering using a ESP32 as it's a lot better option in most contexts in 2023.

I have ESP32s and and 8266 running in my units. None of them had any issues until now.

@HpNoTiQ56
Copy link

HpNoTiQ56 commented May 20, 2024

Hi,
I've switch to ESP32 over 8266 to get BT proxies. I had no error before so it's not an hardware problem.
I've got lots of [mhi_ac_ctrl:141]: mhi_ac_ctrl_core.loop error: -1 and -4 with this code :

# Version 2.1
substitutions:
  # Unique device ID in HA
  deviceid: "XXX"
  # Unique device name in HA (sensor names will be prefixed by this name)
  devicename: "Climatisation salon"
  adress_ip: XXX

esphome:
  name: ${deviceid}
  friendly_name: XXX
  #platformio_options:
    # Run CPU at 160Mhz to fix mhi_ac_ctrl_core.loop error: -2
  #  board_build.f_cpu: 240000000L
  includes:
    - mhi_ac_ctrl.h
    - MHI-AC-Ctrl-core.h
    - MHI-AC-Ctrl-core.cpp


esp32:
  board: wemos_d1_mini32
  framework:
    type: arduino


ota:
  password: ""

packages:
  # Comment if you encounter mhi_ac_ctrl_core.loop error: -2 errors and uncomment the legacy_framesize file
  mhi-ac-ctrl: !include conf/large_framesize.yaml
  # Uncomment this to allow for a working configuration on floor units or older units
  # mhi-ac-ctrl: !include conf/legacy_framesize.yaml


wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  fast_connect: true
  


  
# Optional manual IP
  manual_ip:
    static_ip: ${adress_ip}
    gateway: 
    subnet:

  ap:
    ssid: ${devicename}

captive_portal:

# Enable bluetooth tracker/proxy

esp32_ble_tracker:
  scan_parameters:
    interval: 1100ms
    window: 1100ms
    active: false

bluetooth_proxy:
  active: true

logger:
  level: DEBUG
  baud_rate: 0
  logs:
    component: ERROR

button:
  - platform: restart
    name: Restart
    entity_category: diagnostic

api:
  encryption:
    key: 

  reboot_timeout: 0s
  services:
    # Call the set_api_room_temperature service from HA to override the room temperature
    # If a new value has not been received after room_temp_api_timeout seconds, it will fall back to internal sensor
    - service: set_api_room_temperature
      variables:
        value: float
      then:
        - lambda: |-
            return ((MhiAcCtrl*)id(${deviceid}))->set_room_temperature(value);
    # Call the set_vanes service from HA to set the vane position
    # Needed because the ESPHome Climate class does not support this natively
    # Possible values: 1-4: static positions, 5: swing, 0: unknown
    - service: set_vanes
      variables:
        value: int
      then:
        - lambda: |-
            return ((MhiAcCtrl*)id(${deviceid}))->set_vanes(value);

sensor:
  - platform: uptime
    name: Uptime
  - platform: wifi_signal
    name: WiFi Signal
    update_interval: 60s

text_sensor:
  - platform: version
    name: ESPHome Version
  - platform: wifi_info
    ip_address:
      name: IP
    ssid:
      name: SSID
    bssid:
      name: BSSID

Do anyone using esp 32 got rid of these errors?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants