sparkfun / SparkFun_SCD30_Arduino_Library

An Arduino library for the SCD30 NDIR CO2 sensor.
Other
84 stars 47 forks source link

Properly initialize Wire on ESP32 #35

Open gimdh opened 1 year ago

gimdh commented 1 year ago

Wire now seems to require method begin() to be called before beginTransmission(). This patch accomodates such new requirement by executing _i2cPort->begin(); if Wire is used.

Tested on Lolin32, and can confirm it works now with the fix. Not sure if this change should be specifically applied for ESP32, or can be generalized to non-TEENSY3_I2C implementations.

Error message

[581391][E][Wire.cpp:422] beginTransmission(): could not acquire lock
[581392][E][Wire.cpp:526] write(): NULL TX buffer pointer
[581392][E][Wire.cpp:448] endTransmission(): NULL TX buffer pointer
[581398][E][Wire.cpp:481] requestFrom(): NULL buffer pointer

Related links

https://community.platformio.org/t/updating-espressif-32-to-5-2-0-breaks-wire-cpp/30282/2 https://github.com/espressif/arduino-esp32/commit/9bceb280e3a53492278dddf08fadcf540549dcdf https://github.com/espressif/arduino-esp32/blob/master/libraries/Wire/src/Wire.cpp#L278-L308