File tree 1 file changed +17
-0
lines changed
1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -40,6 +40,23 @@ boolean SCD30::begin(TwoWire &wirePort)
40
40
// We expect caller to begin their I2C port, with the speed of their choice external to the library
41
41
// But if they forget, we start the hardware here.
42
42
_i2cPort->begin ();
43
+
44
+ /* Especially during obtaining the ACK BIT after a byte sent the SCD30 is using clock stretching (but NOT only there)!
45
+ * The need for clock stretching is described in the Sensirion_CO2_Sensors_SCD30_Interface_Description.pdf
46
+ *
47
+ * The default clock stretch (maximum wait time) on the ESP8266-library (2.4.2) is 230us which is set during _i2cPort->begin();
48
+ * In the current implementation of the ESP8266 I2C driver there is NO error message when this time expired, while
49
+ * the clock stretch is still happening, causing uncontrolled behaviour of the hardware combination.
50
+ *
51
+ * To set ClockStretchlimit() a check for ESP8266 boards has been added in the driver.
52
+ *
53
+ * With setting to 20000, we set a max timeout of 20mS (> 20x the maximum measured) basically disabling the time-out
54
+ * and now wait for clock stretch to be controlled by the client.
55
+ */
56
+
57
+ #if defined(ARDUINO_ARCH_ESP32) || defined(ARDUINO_ARCH_ESP8266)
58
+ _i2cPort->setClockStretchLimit (200000 );
59
+ #endif
43
60
44
61
// Check for device to respond correctly
45
62
if (beginMeasuring () == true ) // Start continuous measurements
You can’t perform that action at this time.
0 commit comments