GithubHelp home page GithubHelp logo

Comments (6)

RobTillaart avatar RobTillaart commented on July 24, 2024

Good morning Stefan,

I tested the examples mainly with an UNO, but I understand you use them with an ESP8266 module.
Can you confirm?
Did you test the other examples?
Did that result in the same error message (no need to dump them here right now)

I'll have a look asap

from sht31.

RobTillaart avatar RobTillaart commented on July 24, 2024

reverting SHT library to 0.2.1

  • selecting sketch - SHT31_I2Cspeed.ino (0.02)
  • compiling with UNO works
  • compiling ESP32 fails so I can recreate the error (I do not have 8266 nearby so this should be close enough)

from sht31.

RobTillaart avatar RobTillaart commented on July 24, 2024

OK, compiling now works

  1. replace void with bool in line 32 of the SHT31.h file
  bool begin(const uint8_t address, uint8_t dataPin, uint8_t clockPin);
  1. replace the setHeatTimeout function in SHT31.cpp so it does not use min()
void SHT31::setHeatTimeout(uint8_t seconds)
{
  _heatTimeOut = seconds;
  if (_heatTimeOut > 180) _heatTimeOut = 180;
}

Thanks for finding this bug, can you please verify above fix works?
I will prepare a pull request right away.

from sht31.

StefanL38 avatar StefanL38 commented on July 24, 2024

Ho Rob,

thank you very much. Now it compiles.

Your I2C-speed test also explains how to do fast or slow readings

best regards Stefan

from sht31.

RobTillaart avatar RobTillaart commented on July 24, 2024

Not investigated the latest Adafruit lib but from my head:

When my library doeas a read(), it reads both the T and H does the math for both and puts them into 2 variables. This takes time (~15 millis). When you call getTemperature() or getHumidity() it just copies the variables from the library to your code. This is fast.
To update the internal variables you must call read again, otherwise you get the cached variables again.

The Adafruit library works slightly differently.
A call to getTemperature() or getHumidity() always reads the sensor again, but when reading the T it ignores the H and vice versa.
So it throws away information e.g. H and most of the time it rereads it immediately again. This results in a double delay (don't know if that is 500 ms but it will do double work. The advantage is that you will have the latest measurement, always.

Conclusion
My library stores all fetched information and can deliver info faster as 99% of the cases applications ask temperature and humidity right after each other. If you want my lib to behave like the Adafruit's, you must call read() before every getTemperature() or getHumidity().

from sht31.

RobTillaart avatar RobTillaart commented on July 24, 2024

Ho Rob,

thank you very much. Now it compiles.

Your I2C-speed test also explains how to do fast or slow readings

best regards Stefan

I will merge the pull request, thanks for pointing out the bug and testing.

from sht31.

Related Issues (13)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.