enjoyneering / AHTxx

This is an Arduino library for Aosong ASAIR AHT1x, AHT2x Digital Humidity & Temperature Sensor
99 stars 25 forks source link

AHTxx.cpp:101:8: error: 'class TwoWire' has no member named 'setClockStretchLimit' #2

Closed gotfredsen closed 2 years ago

gotfredsen commented 3 years ago

I get this:

/Users/.../Documents/Arduino/libraries/AHTxx/src/AHTxx.cpp:101:8: error: 'class TwoWire' has no member named 'setClockStretchLimit'
   Wire.setClockStretchLimit(stretch); //experimental! default 150000usec
        ^~~~~~~~~~~~~~~~~~~~

so I commented out the line and now it works.

My Arduino installation is brand new, with latest libraries, on a new Mac. I used to use AHT10, but this pointed me to this library, so I haven't used it before. Running on a ESP32.

davidkleng commented 3 years ago

Hi, im using ATMEGA328 with MiniCore and have the same problem. My solution was to simply go to AHTxx.cpp, line 91 and changed the following:

Wire.setWireTimeout(stretch, false);   

with

Wire.setTimeout(stretch);

Everything works just fine.

enjoyneering commented 3 years ago

Hi folks,

Thank you for feedback. You probably need to update Arduino AVR Core. Recently Wire.setWireTimeout() timeout API method was added to the AVR Wire library. See https://github.com/arduino/reference-en/issues/895

gotfredsen commented 3 years ago

Hi folks,

Thank you for feedback. You probably need to update Arduino AVR Core. Recently Wire.setWireTimeout() timeout API method was added to the AVR Wire library. See arduino/reference-en#895

I am using an ESP32, not an AVR Core, and both Arduino and ESP32 board files were installed same day. Maybe the changes you are referring to has not yet been implemented for the ESP cores.

enjoyneering commented 3 years ago

Hi gotfredsen,

You're right. For some reason, Arduino ESP32 uses Wire.setTimeout(stretch) in milliseconds, while Arduino ESP8266 uses setClockStretchLimit(uint32_t) in microseconds. I believe the timeout for the I2C bus in milliseconds is too long, so in the library I'm using microseconds.

The library has been updated. Thank you for your help.

enjoyneering commented 2 years ago

fixed, see https://github.com/enjoyneering/AHTxx/issues/5