-
Notifications
You must be signed in to change notification settings - Fork 639
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
Add support for NewPing #1116
Conversation
Quick note: TRAVIS02 (in hardware.h) still has HCSR04_SUPPORT. edit: hcsr04 board that I had successfully works with this. |
code/espurna/sensor.ino
Outdated
sensor->setEcho(HCSR04_ECHO); | ||
SonarSensor * sensor = new SonarSensor(); | ||
sensor->setEcho(SONAR_ECHO); | ||
sensor->setIterations(SONAR_PING_ITERATIONS); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 | |||
|
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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...
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
espurna/code/espurna/config/sensors.h
Lines 570 to 576 in 4f61d3a
#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 | |||
|
There was a problem hiding this comment.
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.
code/espurna/sensor.ino
Outdated
sensor->setEcho(HCSR04_ECHO); | ||
SonarSensor * sensor = new SonarSensor(); | ||
sensor->setEcho(SONAR_ECHO); | ||
sensor->setIterations(SONAR_PING_ITERATIONS); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right
b24ee7c
to
c49df00
Compare
* 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).
c49df00
to
43abc6b
Compare
Rebased and fixed some comments. |
SONAR_ITERATIONS
build flag to configure).SONAR_MAX_DISTANCE
build flag).