Giter Site home page Giter Site logo

ESP32 error about dhtnew HOT 13 CLOSED

robtillaart avatar robtillaart commented on May 28, 2024
ESP32 error

from dhtnew.

Comments (13)

willy2764 avatar willy2764 commented on May 28, 2024 1

Hmmm. you are right concerning the file size. With or without noInterrupts() it is the same.
I use two DHT22.
I am using also ESP32 package (1.0.6).
Just running new tests. They take a while. An error appearance is easy to see. A non appearance takes more time to be sure.
I am running the reading loop every 5 seconds. The error affects both sensors and appear randomly.
Actual test is running with the original library:
Always error -4 after an average of about 70 readings in a test of about 700 readings. Distributed about 50/50 between the sensors.
Now running test with your first version and afterwards I'll do the test with the actual development version and I will comment...

from dhtnew.

RobTillaart avatar RobTillaart commented on May 28, 2024

Thanks for reporting this issue. The solution you propose sounds interesting and I need to investigate. Might take a few days as I am quite busy.

from dhtnew.

RobTillaart avatar RobTillaart commented on May 28, 2024

A first look in the ESP32 package (1.0.6) shows in Arduino.h:

#define sei()
#define cli()
#define interrupts() sei()
#define noInterrupts() cli()

so it looks like the noInterrupts() is doing nothing on ESP32, so it will not help.

I will make a develop branch to fix the issue.

from dhtnew.

RobTillaart avatar RobTillaart commented on May 28, 2024

Develop branch created - https://github.com/RobTillaart/DHTNew/tree/develop
PR is building.

@willy2764
Please give it a try if you have time

from dhtnew.

willy2764 avatar willy2764 commented on May 28, 2024

@RobTillaart
Just trying it. Interesting, your modification also gives errors from time to time.
If I change the code as follows, leaving the "noInterrupts()" command in, I don't get anymore errors

#if defined(ESP32)  
    portDISABLE_INTERRUPTS();
#endif
    noInterrupts();

respectively

#if defined(ESP32)
  portENABLE_INTERRUPTS();
#endif
  interrupts();

So, seems that both commands are needed for the ESP32.

from dhtnew.

RobTillaart avatar RobTillaart commented on May 28, 2024

interesting result, as noInterrupts() is defined as an empty statemen,

test compiling minimal sketch for UNO with and without noInterrupts() differs 4 bytes.
For ESP32 with and without noInterrupts() differs 0 bytes.

If my test (and theory) is correct you should get also the same file size with your sketch,
Can you check that?

I do not understand why inserting noInterrupts() (nothing) in your proposal solves the problem.

How often (approx) does the failure pops up?
1 in 10, 1 in 100, 1 in 1000?

from dhtnew.

RobTillaart avatar RobTillaart commented on May 28, 2024

Q: which DHT sensor do you use?

from dhtnew.

RobTillaart avatar RobTillaart commented on May 28, 2024

Note: I updated the develop branch code to your proposal but still do not understand why it should work.

from dhtnew.

willy2764 avatar willy2764 commented on May 28, 2024

Now since about 2h running the test. No error.
Probably I mixed something up on the last trials.
So, your first developement version excluding the noInterrupts() command for the ESP32 seems fine.

from dhtnew.

RobTillaart avatar RobTillaart commented on May 28, 2024

Ok, will check code again later.
Please let me know if you find a cause.

from dhtnew.

willy2764 avatar willy2764 commented on May 28, 2024

The root cause. That's easy. Somewhere between my ears..... :-)

from dhtnew.

RobTillaart avatar RobTillaart commented on May 28, 2024

I reverted to the first version, build is running,
will merge tomorrow unless new problems pop up.

from dhtnew.

RobTillaart avatar RobTillaart commented on May 28, 2024

Merged into 0.4.13

from dhtnew.

Related Issues (20)

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.