Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Si7021 by Sonoff #79

Closed
phiguimaran opened this issue Oct 12, 2022 · 16 comments · Fixed by #80
Closed

Si7021 by Sonoff #79

phiguimaran opened this issue Oct 12, 2022 · 16 comments · Fixed by #80
Assignees
Labels
enhancement New feature or request question Further information is requested

Comments

@phiguimaran
Copy link

Hi, I'm usinng your library in various proyects, it's great !!
I'm trying to use it with the sensor that's came with Sonoff TH.
It's a board that include Si7021 sensor and some circuits to comunicate with 1 wire.
To make this work I have to change the wakeup delay to a value near 500 microseconds
If I coment lines :
do { // HANDLE PENDING IRQ yield(); // 180 gives good wakeup delay on UNO for DHT22 / DHT11 (issue #72) delayMicroseconds(180UL); } while((micros() - startWakeup) < (_wakeupDelay * 1100UL));
and change for delayMicroseconds(500UL); its work well.

I wonder if there is a way to configure this without having to edit the library?

Thanks in advance

@RobTillaart RobTillaart self-assigned this Oct 13, 2022
@RobTillaart RobTillaart added enhancement New feature or request question Further information is requested labels Oct 13, 2022
@RobTillaart
Copy link
Owner

Thanks for the issue.
I will investigate later today.

@RobTillaart
Copy link
Owner

I created a develop branch in which I will introduce a new type 70 besides the 11 and the 22 later today.
Lets get started!

@RobTillaart
Copy link
Owner

@phiguimaran
Pushed initial version of experimental Si7021 support. (not tested as I have no such sensor)

I added the SI7021 to the auto detect part in read().

Please download the develop branch and test if this sensor detection works.
You need to add Serial.println(sensor.getType()) after the read() function.

If detection does not work:

  • force the type to 70 by using the next line in setup()
sensor.setType(70);

@phiguimaran
Copy link
Author

Good morning, and thanks for the fast update.
I tested and the type autodetection works well.
The problem is the total delay now is 720 (because 180x3 < 550 so the next iteration add 180 micros more)
With 720 this sensor doesent work.
Let me test delay min and max that makes the sensor works well and see if it can be a 180 multiple
I'll tell you the results in a bit

@RobTillaart
Copy link
Owner

Good afternoon (15:30 here)
I can patch those numbers relative easily, only thing is that delayMicroseconds() uses a multiple of 4 on AVR.
Can reduce to 40 instead of 180.

@phiguimaran
Copy link
Author

Perfecto I need a time for test and determine a stable wakeupdelay multiple of 40
I write you later

@phiguimaran
Copy link
Author

Well, I make a lot of test and de only way I can use the Sonoff Si7020 stably is the next:
line 71: #define DHTLIB_SI7021_WAKEUP (500UL)
line 233: if ((_type == 22) || (_type == 70)) // DHT22, DHT33, DHT44, compatible
line 360:
if (_type==70){
delayMicroseconds(500); }
else {
original loop
}

This board is extremely sensitive about wekeup time.

@RobTillaart
Copy link
Owner

Thanks for your extensive testing,
I will fix in the library as you proposed. Will be done within 15 minutes.

Need to order such sensor myself to do more testing.

@RobTillaart
Copy link
Owner

RobTillaart commented Oct 14, 2022

Branch pushed, build is running
(just able to fix and run a test in time :)

@RobTillaart RobTillaart linked a pull request Oct 14, 2022 that will close this issue
@RobTillaart
Copy link
Owner

@phiguimaran
I've updated the code to your proposal - used the #define DHTLIB_SI7021_WAKEUP

Other changes do not affect the code

  • Add RP2040 pico in build-CI
  • Add CHANGELOG.md => removed history from .cpp file

Unless there are problems I will merge later today.

@RobTillaart
Copy link
Owner

@phiguimaran
Merged develop branch into master, feel free to reopen this issue if needed.

@RobTillaart
Copy link
Owner

@phiguimaran
FYI #81

@phiguimaran
Copy link
Author

Hi Rob, I was away for the weekend.
You made the changes very quickly :-)
I can't test it today but y see line #183
if (_type == 22) // DHT22, DHT33, DHT44, compatible
should be
if ((_type == 22) || (_type == 70)) // DHT22, DHT33, DHT44, compatible

otherwise we get wrong readings

best regards

@RobTillaart
Copy link
Owner

From - #81

A DHT22 got recognized as a type 70 and still got good data.

Need to look at the code to see if I understand what is happening.

@RobTillaart
Copy link
Owner

RobTillaart commented Oct 17, 2022

Yes, understand the issue.
I will create a new develop branch.

(exactly the reason why testing is so important).

@RobTillaart
Copy link
Owner

TOPIC is continued in #84

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request question Further information is requested
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants