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

pulseIn does not return 0 on timeout (it returns 1 or timeout value depending on pin state) #1072

Closed
darkskiez opened this issue Nov 22, 2015 · 6 comments
Assignees
Labels
component: core type: bug waiting for feedback Waiting on additional info. If it's not received, the issue may be closed.
Milestone

Comments

@darkskiez
Copy link

darkskiez commented Nov 22, 2015

In core_esp8266_wiring_pulse.c, it seems to return duration=timeout rather than duration=0 on a timeout, or, because it resets the start time after a timeout, it can also return duration=1.

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

@darkskiez
Copy link
Author

Whilst you're in that file, you could remove the pinMode setting, I may have set PULLUP etc.

@igrr igrr added this to the 2.1.0 milestone Nov 30, 2015
@framb00s
Copy link

I have the same problem
const int dustPin= D2;
pinMode(dustPin,INPUT_PULLUP);
int i=0;
void loop() {
duration = pulseIn(dustPin, LOW);
if(duration!=0){ // number positive readings
i++;
}
lowpulseoccupancy = lowpulseoccupancy+duration;
.....
give with nothing attached after 30 seconds 30 reads (i==30)
and a total pulse-low_time between 30 and 35

@igrr igrr modified the milestones: 2.2.0, 2.1.0 Feb 27, 2016
igrr added a commit that referenced this issue Mar 13, 2016
- fix return value on timeout
- add optimistic_yield to allow WiFi/network tasks to run
- use ccount instead of micros (which causes an integer division on every call)
@igrr igrr mentioned this issue Mar 13, 2016
@igrr igrr modified the milestones: 2.2.0, 2.3.0 Apr 18, 2016
@igrr igrr modified the milestones: 2.3.0, 2.4.0 Jun 3, 2016
@me-no-dev me-no-dev self-assigned this Jul 19, 2016
@devyte
Copy link
Collaborator

devyte commented Oct 19, 2017

@igrr the referenced PR was merged quite some time ago. Can this be closed, or is there something pending?

@devyte
Copy link
Collaborator

devyte commented Oct 19, 2017

@me-no-dev I just realized this is assigned to you, maybe you're the right person to ask?

@devyte devyte added the waiting for feedback Waiting on additional info. If it's not received, the issue may be closed. label Oct 19, 2017
@me-no-dev
Copy link
Collaborator

Yeah I have no clue how and when I assigned this to myself. I guess it should be closed, unless the current implementation also does not work

@devyte
Copy link
Collaborator

devyte commented Oct 19, 2017

Alright, closing. If there is still a problem, let's handle it in a new issue.

@devyte devyte closed this as completed Oct 19, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: core type: bug waiting for feedback Waiting on additional info. If it's not received, the issue may be closed.
Projects
None yet
Development

No branches or pull requests

5 participants