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

I2C and WiFi won't work at the same time on ESP32-S2 #4796

Closed
makermelissa opened this issue Feb 10, 2021 · 12 comments
Closed

I2C and WiFi won't work at the same time on ESP32-S2 #4796

makermelissa opened this issue Feb 10, 2021 · 12 comments
Labels
Status: Stale Issue is stale stage (outdated/stuck)

Comments

@makermelissa
Copy link
Contributor

makermelissa commented Feb 10, 2021

If I use I2C on some other pins (like 33 and 34), I2C works fine, but WiFi does not connect.

If I try pins 21 and 22, WiFi appears to work, but I get a Core 0 panic:

Guru Meditation Error: Core  0 panic'ed (LoadProhibited). Exception was unhandled.

Core  0 register dump:
PC      : 0x4009f7c6  PS      : 0x00060a30  A0      : 0x8009ced0  A1      : 0x3ffd20c0  
A2      : 0x00000000  A3      : 0x00000001  A4      : 0x3ffc7a7a  A5      : 0x00000000  
A6      : 0x3ffd74ec  A7      : 0x00000032  A8      : 0x8009f7c3  A9      : 0x3ffd2080  
A10     : 0x00000000  A11     : 0x3ffc7a7a  A12     : 0x00000000  A13     : 0x00000001  
A14     : 0x00000000  A15     : 0x00000021  SAR     : 0x00000016  EXCCAUSE: 0x0000001c  
EXCVADDR: 0x00000000  LBEG    : 0x00000000  LEND    : 0x00000001  LCOUNT  : 0x400278c5  

Backtrace:0x4009f7c3:0x3ffd20c0 0x4009cecd:0x3ffd20e0 0x4009cf41:0x3ffd2100 0x40088c1c:0x3ffd2120 0x4008fe81:0x3ffd2140 0x4009218a:0x3ffd2170 0x400a04dd:0x3ffd2190


ELF file SHA256: 0000000000000000

Rebooting...

If I don't use I2C at all, WiFi has no problems.

This is on the ESP32-S2 using the idf-release/v4.2 branch. I had previously mentioned this is #4760, but realized that was for the ESP32.

Tagging @ladyada.

@makermelissa
Copy link
Contributor Author

I noticed this issue when attempting to add support to ESPHome. In order to reproduce this issue with the ESP32 Saola, you can do the following. Sorry it's so long, but I've been working on this for over a week.

  1. Git clone the ESPHome Dev branch: https://github.com/esphome/esphome.git
  2. Apply PR Fix build issues for idf 4.2 (Support ESP32-S2) esphome/esphome#1433 so WiFi compiles.
  3. Add the following board config esphome/pins.py:
    'esp32-s2-saola-1': {
        'TX': 43, 'RX': 44, 'SDA': 8, 'SCL': 9, 'SS': 34, 'MOSI': 35,
        'MISO': 37, 'SCK': 36, 'A0': 1, 'A1': 2, 'A2': 3, 'A3': 4, 'A4': 5,
        'A5': 6, 'A6': 7, 'A7': 8, 'A8': 9, 'A9': 10, 'A10': 11, 'A11': 12,
        'A12': 13, 'A13': 14, 'A14': 15, 'A15': 16, 'A16': 17, 'A17': 18,
        'A18': 19, 'A19': 20, 'T1': 1, 'T2': 2, 'T3': 3, 'T4': 4, 'T5': 5,
        'T6': 6, 'T7': 7, 'T8': 8, 'T9': 9, 'T10': 10, 'T11': 11, 'T12': 12,
        'T13': 13, 'T14': 14, 'DAC1': 17, 'DAC2': 18
    },
  1. Use the following YAML file for your config. Save it in test.yaml:
esphome:
  name: esp32s2test
  platform: ESP32
  board: esp32-s2-saola-1
  platformio_options:
    platform: espressif32 @ https://github.com/adafruit/platform-espressif32.git
    platform_packages: framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git#idf-release/v4.2

wifi:
  ssid: "YouWiFi"
  password: "YourPassword"
  
  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Esp32-S2 Test Fallback Hotspot"
    password: "test"

captive_portal:

# Enable logging
logger:
  level: VERBOSE

# Enable Home Assistant API
api:
  password: "password"

ota:
  password: "pwasword"

# I2C Bus
i2c:
  sda: SDA
  scl: SCL
  1. Inside the repo run pip3 install -e . which will install any packages
  2. Run esphome test.yaml run which will install the packages and attempt to program the board. You don't need to actually install yet.
  3. Go into your platformio packages (mine were installed to ~/.platformio/packages)
  4. Apply PR [2.0.0] Fix issue with init I2C for esp32 S2 #4776 to this repo which should be inside of the framework-arduinoespressif32 folder. this fixes an I2C initialization error.
  5. Run esphome test.yaml run again and program your board.
  6. You may need to connect a USB to UART cable to the ground, TX, and RX pins to see debug output

@stale
Copy link

stale bot commented Jun 20, 2021

[STALE_SET] This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. Thank you for your contributions.

@stale stale bot added the Status: Stale Issue is stale stage (outdated/stuck) label Jun 20, 2021
@ladyada
Copy link
Contributor

ladyada commented Jun 20, 2021

@makermelissa wanna retry with latest main with/without @dhalbert's mutex fix ?

@stale
Copy link

stale bot commented Jun 20, 2021

[STALE_CLR] This issue has been removed from the stale queue. Please ensure activity to keep it openin the future.

@stale stale bot removed the Status: Stale Issue is stale stage (outdated/stuck) label Jun 20, 2021
@stale
Copy link

stale bot commented Aug 21, 2021

[STALE_SET] This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. Thank you for your contributions.

@stale stale bot added the Status: Stale Issue is stale stage (outdated/stuck) label Aug 21, 2021
@ladyada
Copy link
Contributor

ladyada commented Aug 21, 2021

to the best of our knowledge, this has not been fixed yet

@stale
Copy link

stale bot commented Sep 6, 2021

[STALE_DEL] This stale issue has been automatically closed. Thank you for your contributions.

@stale stale bot closed this as completed Sep 6, 2021
@Collin7
Copy link

Collin7 commented Oct 25, 2021

Hi, does anybody know if this has been fixed. I am having this issue with an ESP32 dev board, and a I2C 4x20 lcd. It works well for a while, but then the wifi disconnects, and will not reconnect.
Seems to be a interference issue. If I open up the project box, and move the LCD away about 10cm or so. It works, When I close the project box again, the wifi disconnects.

@VojtechBartoska
Copy link
Contributor

@me-no-dev PTAL

@Matssa56
Copy link

Hey guys I'm having the same issue. I'm trying to use I2C on my devkit board using GPIO 22 for SCL and GPIO21 for SDA and as soon as I have the I2C configuration in my yaml the wifi stops working... Anyone has a fix?
Thanks!

@Matssa56
Copy link

Ok so tested with a higher PSU amps and it works now, apparently 5W isn't enough (5V / 1A).

@ncohen17
Copy link

ncohen17 commented Jun 7, 2022

Hi,

I am having a similar issue. I am trying to run the ESP-NOW protocol together with the I2C interface but I am getting an error.

I am using the M5Stack ATOM, which uses the ESP32-PICO chip.

This is what I am getting on the serial terminal.

E (39) i2c: i2c_param_config(671): i2c clock choice is invalid, please check flag and frequency I2C slave init failed

I have tried adding this conf.clk_flags= 0; and this i2c_config_t conf; memset(conf, 0, sizeof(i2c_config_t)); to the header file but it is still not working. I am getting the same error message on ther serial terminal.

Can someone please advise on the fix to this issue ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Stale Issue is stale stage (outdated/stuck)
Projects
None yet
Development

No branches or pull requests

6 participants