Skip to content

Update to the correct distance call #20

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

Merged
merged 4 commits into from
Aug 20, 2020

Conversation

dannystaple
Copy link

It looks like the distance property replaces the dist_cm()` function.
Also gave a hint here that the board pin objects are needed, and not just integers.

It looks like the `distance property replaces the `dist_cm()` function. 
Also gave a hint here that the board pin objects are needed, and not just integers.
README.rst Outdated
@@ -99,15 +99,15 @@ Without a Context Manager
-------------------------

In the example below, we create the `HCSR04` object directly, get the distance every 2 seconds, then
de-initialize the device.
de-initialize the device. Note trig and echo should come from the `board` module - they aren't just integers.

::

from adafruit_hcsr04 import HCSR04
sonar = HCSR04(trig, echo)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for fixing the out of date example in the readme!

Instead of making a note in the paragraph above can you update this line in the example code to show it's usage with the board pins. You can copy it form the example file in the repo if you want:
https://github.com/adafruit/Adafruit_CircuitPython_HCSR04/blob/master/examples/hcsr04_simpletest.py

You can add import board at the top and then change the sonar constructor like this:

sonar = HCSR04(trigger_pin=board.D5, echo_pin=board.D6)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea. I've committed this change.

@FoamyGuy
Copy link

Thank you @dannystaple. There is a minor issue with the docs building on this PR currently. I've submitted a PR on your branch that should fix it. I think if you merge my PR it should automatically show up here as well and fix the docs building when it retries the CI actions.

@dannystaple
Copy link
Author

Looks like putting in the import, I missed the blank line - RST doesn't like that. The language hints can't hurt. More fool me for not trying the Sphinx build locally - done so now and it looks good.

@FoamyGuy
Copy link

FoamyGuy commented Jun 21, 2020

@dannystaple Testing this out now on a HC0SR04 sensor I've hit a few more snags. The code in the readme is using sleep() but not importing it, so we'll need to add that import.

Also it seems like there is some sort of RuntimeError that needs to be caught and then retried after in order for the sensor to work (at least for my sensor with Itsy Bitsy M0). Though I also realized from this learn guide page: https://learn.adafruit.com/ultrasonic-sonar-distance-sensors/python-circuitpython that it is required to use some resistors to hook this up and I didn't do that the first time, so perhaps that is part of my problem.

Can you go ahead and copy the entire contents hcsr04_simpletest.py into the readme please. It looks like the example was updated at some point to address these things, but the readme never was.

Sorry for all of the changes, I didn't notice some of these issues until putting the circuit together. I really appreciate you working on this to get the readme example back to functional.

I will try to get some resistors dug up and get my circuit set up to properly test this out all the way a bit later on today.

@kattni
Copy link

kattni commented Aug 17, 2020

@dannystaple Have you had a chance to follow up on FoamyGuy's latest comment?

@dannystaple
Copy link
Author

dannystaple commented Aug 18, 2020 via email

@kattni
Copy link

kattni commented Aug 19, 2020

@dannystaple Thank you for letting me know. I will see if FoamyGuy can finish it up.

@kattni
Copy link

kattni commented Aug 19, 2020

@FoamyGuy The original author is unavailable at the moment. Would you mind finishing up this PR as per your suggestions? Thanks!

@FoamyGuy FoamyGuy merged commit ac31193 into adafruit:master Aug 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants