Closed cgmcintyr closed 6 years ago
Fork of arduino-esp32 that may be related to this issue (I have not looked into it thoroughly).
The SDA and SCL pins are flexible - but seem to be defined correctly for the esp32 Feather we're using in .../Arduino/hardware/espressif/esp32/variants/feather_esp32/pins_arduino.h
static const uint8_t SDA = 23;
static const uint8_t SCL = 22;
However, the I2C subsystem does appear to be a bit of a nightmare due to the differences in the way the AVR chips (original Arduino's) implemented I2C compared to the ESP32 - hence the necessity of the fork you referenced.
Can you check that you had the ESP32 Feather selected in the arduino environment - that may resolve the pin issue. The timing issue looks more fundamental.
I2C is a critical subsystem for many if not most users and the fork is new and under active development (last commit 2 hours ago!) - the author of the fork is requesting testing and feedback - this is a great opportunity for us to contribute to the wider community.
Also please either assign yourself to this one - or let me know if you are already too busy and I'll take it - it's important enough that I'd like one of us to look at it asap.
I would like to prioritise issue #8. A more modular codebase would hopefully make fixing these types of issues easier in the future.
I agree re. #8 -- I think ideally the config for stuff like this would migrate out into a spiffs file... So could be good to collaborate over #18
That makes sense, and we can work around the bug in the I2C system by various means (ugliest would be to reboot when it goes south...)
As this issue is more about fundamental bugs in I2C subsystem than wrong pin definitions, I'm going to close it for now, we can open a new one to track the I2C bug if needed.
Problem
The pins for SDA and SCL on the esp32 are 23 and 22. Calling
Wire.begin
with no args seems to use incorrect pins for the esp32. This results in the TSL2591 never being found instartPeripherals
: https://github.com/hamishcunningham/fishy-wifi/blob/c7e3cb415f0ee15786c1d1fe610efdc433e5f889/ardesp/waterelf32/waterelf32.ino#L832-L835Furthermore the Adafruit_TSL2591_Library's function
tsl.begin()
callsWire.begin
with no args, making it incompatible with the esp32.Example
Running the example tsl2591.ino results in:
Possible Fix
Replacing all
Wire.begin()
withWire.begin(23, 22)
in Adafruit_TSL2591_Library and waterelf32.ino.After applying fix, tsl2591.ino can be run with the ESP32.
Problems with 'Fix'
After applying the fix the waterelf32.ino reports errors with addresses 20 and 29 being busy.
Example waterelf32 output after applying 'fix'
``` startPeripherals... [W][esp32-hal-i2c.c:231] i2cWrite(): Ack Error! Addr: 4e Soft AP started AP SSID: WaterElf-BC130CC40A24; IP address(es): local=0.0.0.0; AP=192.168.99.1 [D][WiFiGeneric.cpp:258] _eventCallback(): Event: 13 - AP_STOP [D][WiFiGeneric.cpp:258] _eventCallback(): Event: 13 - AP_STOP HTTP server started doing flow controller and mcp init... [E][esp32-hal-i2c.c:465] i2cInitFix(): Busy at initialization! [E][esp32-hal-i2c.c:160] i2cWrite(): Busy Timeout! Addr: 20 [E][esp32-hal-i2c.c:160] i2cWrite(): Busy Timeout! Addr: 20 [W][esp32-hal-i2c.c:263] i2cRead(): Busy Timeout! Addr: 20 [E][esp32-hal-i2c.c:160] i2cWrite(): Busy Timeout! Addr: 20 [E][esp32-hal-i2c.c:160] i2cWrite(): Busy Timeout! Addr: 20 [W][esp32-hal-i2c.c:263] i2cRead(): Busy Timeout! Addr: 20 [E][esp32-hal-i2c.c:160] i2cWrite(): Busy Timeout! Addr: 20 [E][esp32-hal-i2c.c:160] i2cWrite(): Busy Timeout! Addr: 20 [W][esp32-hal-i2c.c:263] i2cRead(): Busy Timeout! Addr: 20 [E][esp32-hal-i2c.c:160] i2cWrite(): Busy Timeout! Addr: 20 [E][esp32-hal-i2c.c:160] i2cWrite(): Busy Timeout! Addr: 20 [W][esp32-hal-i2c.c:263] i2cRead(): Busy Timeout! Addr: 20 [E][esp32-hal-i2c.c:160] i2cWrite(): Busy Timeout! Addr: 20 [E][esp32-hal-i2c.c:160] i2cWrite(): Busy Timeout! Addr: 20 [W][esp32-hal-i2c.c:263] i2cRead(): Busy Timeout! Addr: 20 [E][esp32-hal-i2c.c:160] i2cWrite(): Busy Timeout! Addr: 20 [E][esp32-hal-i2c.c:160] i2cWrite(): Busy Timeout! Addr: 20 [W][esp32-hal-i2c.c:263] i2cRead(): Busy Timeout! Addr: 20 [E][esp32-hal-i2c.c:160] i2cWrite(): Busy Timeout! Addr: 20 Air Temp: 26.20 C, Humidity: 25.90 %RH, [E][esp32-hal-i2c.c:160] i2cWrite(): Busy Timeout! Addr: 29 [E][esp32-hal-i2c.c:160] i2cWrite(): Busy Timeout! Addr: 29 [W][esp32-hal-i2c.c:263] i2cRead(): Busy Timeout! Addr: 29 [E][esp32-hal-i2c.c:160] i2cWrite(): Busy Timeout! Addr: 29 [W][esp32-hal-i2c.c:263] i2cRead(): Busy Timeout! Addr: 29 [E][esp32-hal-i2c.c:160] i2cWrite(): Busy Timeout! Addr: 29 [E][esp32-hal-i2c.c:160] i2cWrite(): Busy Timeout! Addr: 29 [E][esp32-hal-i2c.c:160] i2cWrite(): Busy Timeout! Addr: 29 [W][esp32-hal-i2c.c:263] i2cRead(): Busy Timeout! Addr: 29 [E][esp32-hal-i2c.c:160] i2cWrite(): Busy Timeout! Addr: 29 [W][esp32-hal-i2c.c:263] i2cRead(): Busy Timeout! Addr: 29 [E][esp32-hal-i2c.c:160] i2cWrite(): Busy Timeout! Addr: 29 Light: 0 Lux Water Level: 103 cm, Water Level: 74 cm, Water Level: 75 cm, getAnalog [E][esp32-hal-i2c.c:160] i2cWrite(): Busy Timeout! Addr: 20 [W][esp32-hal-i2c.c:263] i2cRead(): Busy Timeout! Addr: 20 [E][esp32-hal-i2c.c:160] i2cWrite(): Busy Timeout! Addr: 20 [E][esp32-hal-i2c.c:160] i2cWrite(): Busy Timeout! Addr: 20 [W][esp32-hal-i2c.c:263] i2cRead(): Busy Timeout! Addr: 20 [E][esp32-hal-i2c.c:160] i2cWrite(): Busy Timeout! Addr: 20 free heap=140748 Air Temp: 26.20 C, Humidity: 25.90 %RH, [E][esp32-hal-i2c.c:160] i2cWrite(): Busy Timeout! Addr: 29 [E][esp32-hal-i2c.c:160] i2cWrite(): Busy Timeout! Addr: 29 [W][esp32-hal-i2c.c:263] i2cRead(): Busy Timeout! Addr: 29 [E][esp32-hal-i2c.c:160] i2cWrite(): Busy Timeout! Addr: 29 [W][esp32-hal-i2c.c:263] i2cRead(): Busy Timeout! Addr: 29 [E][esp32-hal-i2c.c:160] i2cWrite(): Busy Timeout! Addr: 29 [E][esp32-hal-i2c.c:160] i2cWrite(): Busy Timeout! Addr: 29 [E][esp32-hal-i2c.c:160] i2cWrite(): Busy Timeout! Addr: 29 [W][esp32-hal-i2c.c:263] i2cRead(): Busy Timeout! Addr: 29 [E][esp32-hal-i2c.c:160] i2cWrite(): Busy Timeout! Addr: 29 [W][esp32-hal-i2c.c:263] i2cRead(): Busy Timeout! Addr: 29 [E][esp32-hal-i2c.c:160] i2cWrite(): Busy Timeout! Addr: 29 Light: 0 Lux Water Level: 103 cm, Water Level: 105 cm, Water Level: 70 cm, getAnalog free heap=140748 Air Temp: 26.20 C, Humidity: 25.90 %RH, [E][esp32-hal-i2c.c:160] i2cWrite(): Busy Timeout! Addr: 29 [E][esp32-hal-i2c.c:160] i2cWrite(): Busy Timeout! Addr: 29 [W][esp32-hal-i2c.c:263] i2cRead(): Busy Timeout! Addr: 29 [E][esp32-hal-i2c.c:160] i2cWrite(): Busy Timeout! Addr: 29 [W][esp32-hal-i2c.c:263] i2cRead(): Busy Timeout! Addr: 29 [E][esp32-hal-i2c.c:160] i2cWrite(): Busy Timeout! Addr: 29 [E][esp32-hal-i2c.c:160] i2cWrite(): Busy Timeout! Addr: 29 [E][esp32-hal-i2c.c:160] i2cWrite(): Busy Timeout! Addr: 29 [W][esp32-hal-i2c.c:263] i2cRead(): Busy Timeout! Addr: 29 [E][esp32-hal-i2c.c:160] i2cWrite(): Busy Timeout! Addr: 29 [W][esp32-hal-i2c.c:263] i2cRead(): Busy Timeout! Addr: 29 [E][esp32-hal-i2c.c:160] i2cWrite(): Busy Timeout! Addr: 29 Light: 0 Lux Water Level: 103 cm, Water Level: 96 cm, Water Level: 122 cm, getAnalog free heap=140752 Air Temp: 26.20 C, Humidity: 25.90 %RH, [E][esp32-hal-i2c.c:160] i2cWrite(): Busy Timeout! Addr: 29 [E][esp32-hal-i2c.c:160] i2cWrite(): Busy Timeout! Addr: 29 [W][esp32-hal-i2c.c:263] i2cRead(): Busy Timeout! Addr: 29 [E][esp32-hal-i2c.c:160] i2cWrite(): Busy Timeout! Addr: 29 [W][esp32-hal-i2c.c:263] i2cRead(): Busy Timeout! Addr: 29 [E][esp32-hal-i2c.c:160] i2cWrite(): Busy Timeout! Addr: 29 [E][esp32-hal-i2c.c:160] i2cWrite(): Busy Timeout! Addr: 29 [E][esp32-hal-i2c.c:160] i2cWrite(): Busy Timeout! Addr: 29 [W][esp32-hal-i2c.c:263] i2cRead(): Busy Timeout! Addr: 29 [E][esp32-hal-i2c.c:160] i2cWrite(): Busy Timeout! Addr: 29 [W][esp32-hal-i2c.c:263] i2cRead(): Busy Timeout! Addr: 29 [E][esp32-hal-i2c.c:160] i2cWrite(): Busy Timeout! Addr: 29 Light: 0 Lux Water Level: 103 cm, Water Level: 91 cm, Water Level: 100 cm, getAnalog free heap=140752 Air Temp: 26.20 C, Humidity: 25.90 %RH, [E][esp32-hal-i2c.c:160] i2cWrite(): Busy Timeout! Addr: 29 [E][esp32-hal-i2c.c:160] i2cWrite(): Busy Timeout! Addr: 29 [W][esp32-hal-i2c.c:263] i2cRead(): Busy Timeout! Addr: 29 [E][esp32-hal-i2c.c:160] i2cWrite(): Busy Timeout! Addr: 29 [W][esp32-hal-i2c.c:263] i2cRead(): Busy Timeout! Addr: 29 [E][esp32-hal-i2c.c:160] i2cWrite(): Busy Timeout! Addr: 29 [E][esp32-hal-i2c.c:160] i2cWrite(): Busy Timeout! Addr: 29 [E][esp32-hal-i2c.c:160] i2cWrite(): Busy Timeout! Addr: 29 [W][esp32-hal-i2c.c:263] i2cRead(): Busy Timeout! Addr: 29 [E][esp32-hal-i2c.c:160] i2cWrite(): Busy Timeout! Addr: 29 [W][esp32-hal-i2c.c:263] i2cRead(): Busy Timeout! Addr: 29 [E][esp32-hal-i2c.c:160] i2cWrite(): Busy Timeout! Addr: 29 Light: 0 Lux Water Level: 103 cm, Water Level: 117 cm, Water Level: 78 cm, getAnalog free heap=140396 ```