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

Add support for NewPing #1116

Merged
merged 1 commit into from
Aug 13, 2018
Merged

Conversation

ruimarinho
Copy link
Contributor

  • Works with many different ultrasonic sensor models: HC-SR04, SRF05, SRF06, DYP-ME007, JSN-SR04T & Parallax PING)))™.
  • Built-in digital filter method ping_median() for easy error correction (use SONAR_ITERATIONS build flag to configure).
  • Allows setting of a maximum distance where pings beyond that distance are read as no ping or clear (use SONAR_MAX_DISTANCE build flag).

@mcspr
Copy link
Collaborator

mcspr commented Aug 8, 2018

Quick note: TRAVIS02 (in hardware.h) still has HCSR04_SUPPORT.

edit: hcsr04 board that I had successfully works with this.

sensor->setEcho(HCSR04_ECHO);
SonarSensor * sensor = new SonarSensor();
sensor->setEcho(SONAR_ECHO);
sensor->setIterations(SONAR_PING_ITERATIONS);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Typo. Should be SONAR_ITERATIONS

Copy link
Owner

Choose a reason for hiding this comment

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

Right

@@ -112,6 +112,9 @@
#define I2C_SDA_PIN 12 // D6
#define I2C_SCL_PIN 14 // D5

#define SONAR_TRIGGER 12 // D6
#define SONAR_ECHO 13 // D7

Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe just keep as defaults in sensor.h?

Copy link
Owner

Choose a reason for hiding this comment

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

Agree, these should not be here.

Copy link
Contributor Author

@ruimarinho ruimarinho Aug 9, 2018

Choose a reason for hiding this comment

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

Not sure I understood. sensors.h already has defaults. This is just the override for the Wemos. Is this incorrect?

Copy link
Collaborator

@mcspr mcspr Aug 10, 2018

Choose a reason for hiding this comment

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

Oops. Pins on d1 do not include gpio 7 and 8 (6-11 are not mapped to pins at all so they do nothing): https://github.com/esp8266/Arduino/blob/master/variants/d1/pins_arduino.h
What i meant to say, change the defaults in hw.h to these and do not define them twice for wemos hw here. and note overlapping pin 12 for sda :) Sry for confusion

edit: ...phone autocomplete...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@xoseperez I don't think these will work on Wemos — https://github.com/xoseperez/espurna/blob/dev/code/espurna/config/hardware.h#L2669-L2671. Wasn't this change correct after all?

Copy link
Collaborator

Choose a reason for hiding this comment

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

@ruimarinho nah you linked travis-only hw that is only a built test, no real boards involved. these are fine

#ifndef SONAR_TRIGGER
#define SONAR_TRIGGER 12 // GPIO for the trigger pin (output)
#endif
#ifndef SONAR_ECHO
#define SONAR_ECHO 14 // GPIO for the echo pin (input)
#endif

@@ -112,6 +112,9 @@
#define I2C_SDA_PIN 12 // D6
#define I2C_SCL_PIN 14 // D5

#define SONAR_TRIGGER 12 // D6
#define SONAR_ECHO 13 // D7

Copy link
Owner

Choose a reason for hiding this comment

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

Agree, these should not be here.

sensor->setEcho(HCSR04_ECHO);
SonarSensor * sensor = new SonarSensor();
sensor->setEcho(SONAR_ECHO);
sensor->setIterations(SONAR_PING_ITERATIONS);
Copy link
Owner

Choose a reason for hiding this comment

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

Right

* Works with many different ultrasonic sensor models: HC-SR04, SRF05,
  SRF06, DYP-ME007, JSN-SR04T & Parallax PING)))™.
* Built-in digital filter method ping_median() for easy error correction
  (use SONAR_ITERATIONS build flag to configure).
* Allows setting of a maximum distance where pings beyond that distance
  are read as no ping or clear (use SONAR_MAX_DISTANCE build flag).
@ruimarinho
Copy link
Contributor Author

Rebased and fixed some comments.

@xoseperez xoseperez merged commit 4956e69 into xoseperez:dev Aug 13, 2018
@ruimarinho ruimarinho deleted the support/new-ping branch August 15, 2018 00:34
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