RobTillaart / SHT85

Arduino library for the SHT85 temperature and humidity sensor
MIT License
11 stars 4 forks source link

Looking forward to the non block methed as SHT85 #13

Closed countrysideboy closed 1 year ago

RobTillaart commented 1 year ago

@countrysideboy Thanks for this issue, I will transfer it to the SHT85 and look into it if it is feasable.

RobTillaart commented 1 year ago

@countrysideboy

What do you expect from no-blocking in terms of time? == What amount of blocking is acceptable? Did you investigate the datasheet of what is possible?

RobTillaart commented 1 year ago
bool SHT::read(bool fast)
{
  if (writeCmd(fast ? SHT_MEASUREMENT_FAST : SHT_MEASUREMENT_SLOW) == false)
  {
    return false;
  }
  delay(fast ? 4 : 15); // table 4 datasheet
  return readData(fast);
}

can be split up in something like this

bool SHT::request(bool fast)
{
  if (writeCmd(fast ? SHT_MEASUREMENT_FAST : SHT_MEASUREMENT_SLOW) == false)
  {
    return false;
  }
  requestTime = millis();
  requestPending = true;
}

//  returns false or reads the data and returns true
bool requestReady(bool fast)
{
  if (requestPending == false) return false;
  if ( ( millis() - requestTime ) < (fast ? 4 : 15) ) return false;
  readData(fast);
  requestPending = false;
  return true;
}
RobTillaart commented 1 year ago

Alternative, without requestPending...

//  returns false or reads the data and returns true
bool requestReady(bool fast)
{
  if ( ( millis() - requestTime ) > 3000 ) return false;
  if ( ( millis() - requestTime ) < (fast ? 4 : 15) ) return false;
  readData(fast);
  return true;
}
RobTillaart commented 1 year ago

Think without request pending is better. User is responsible for tracking requests.

RobTillaart commented 1 year ago

@countrysideboy Can you tell more about what you exactly requested .

I interpreted it that you want a asynchronous interface for the SHT85 but that already exists. (there are a few small problems that are under investigation)

Or did you mean you want an async interface for the SHT2X library. The I interpreted your oneliner wrong.

countrysideboy commented 1 year ago

Hello, Robtillaart, thanks for your project.I use both si7021 and sht30 sensors in my diy clock, and I have successfully running the sht30 in async mode with the sht85 code.I hope that I could use the si7021 too, cause my clock will request the ntp time and alarm hourly.

countrysideboy commented 1 year ago

I used to create a lib of si7021 myself, and makes the temperature request and read splitly.I use a library called pthead (pt.h), which provides the emulate multiple threads ability, and use a PT_DELAY macro instead of the delay() function.

RobTillaart commented 1 year ago

OK, sounds like a nice project. But I still do not understand your question.

About Si7021

https://github.com/RobTillaart/DHTNew does work with the SOnOff Si7021 since oktober 2022 Did not test it myself. See for discussion - https://github.com/RobTillaart/DHTNew/issues/79

The Si7021 does not work with the SHT85 library.

RobTillaart commented 1 year ago

There might be more Si7021 named sensors in the world. As my SHT2X library derives it and it is a way different protocol.

Do you have a link to the Si7021 you use?

countrysideboy commented 1 year ago

There might be more Si7021 named sensors in the world. As my SHT2X library derives it and it is a way different protocol.

Do you have a link to the Si7021 you use?

https://www.amazon.com/ACEIRMC-Digital-Humidity-Temperature-Replace/dp/B08ZN9K927/ref=mp_s_a_1_3?keywords=si7021&qid=1671041603&sr=8-3

RobTillaart commented 1 year ago

There might be more Si7021 named sensors in the world. As my SHT2X library derives it and it is a way different protocol. Do you have a link to the Si7021 you use?

https://www.amazon.com/ACEIRMC-Digital-Humidity-Temperature-Replace/dp/B08ZN9K927/ref=mp_s_a_1_3?keywords=si7021&qid=1671041603&sr=8-3

Those should work with the SHT2X library

OK, and your question is to have an ASYNC interface on the SHT2X library.?

countrysideboy commented 1 year ago

I try to use SHT2X library, and find it does not provide the asynchronous interface like SHT85.Maybe I can merge the SHT2X code into SHT85, although it has different i2c address and protocol.

countrysideboy commented 1 year ago

have

Yes, sorry for my confused request. I am looking forward to have an ASYNC interface on the SHT2X.

RobTillaart commented 1 year ago

Those are not compatible enough to merge.

I created a new issue - https://github.com/RobTillaart/SHT2x/issues/16 - describing the problem a bit. Furthermore it describes your request in more detail.

SO I close this issue, and we can continue in the other.

countrysideboy commented 1 year ago

Those are not compatible enough to merge.

I created a new issue - RobTillaart/SHT2x#16 - describing the problem a bit. Furthermore it describes your request in more detail.

SO I close this issue, and we can continue in the other.

Thank you.