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

SR04 Ultrasonic sensor support? #113

Closed
Killobite opened this issue Feb 26, 2017 · 21 comments
Closed

SR04 Ultrasonic sensor support? #113

Killobite opened this issue Feb 26, 2017 · 21 comments
Labels
enhancement Type - Enhancement that will be worked on help needed Action - Asking for help from the community question Type - Asking for Information

Comments

@Killobite
Copy link

First off, fantastic firmware! I have installed this firmware on more than 20 Sonoffs and am really appreciating the capabilities and attention to detail!

I do find that I would really like to add the use of a SR04 distance sensor for one of my implementation and am wondering if there may be any plan or ideas on how to do so?

Thanks!

@arendst
Copy link
Owner

arendst commented Mar 5, 2017

The SR04 needs 5V. Sonoff can only supply 3V3. Do you expect the SR04 to work reliably on 3V3?

@arendst arendst added the question Type - Asking for Information label Mar 5, 2017
@AlexTransit
Copy link

Sonoff basic - use 2 power
5v - via trancformater (power relay)
3.3v - afrer stabiliser

@Killobite
Copy link
Author

I will actually be using it with a Wemos D Mini and can take the 5V right off the VCC pin. I have a mock up working with 3.9.21 and just threw the sonar code in the void loop and sent the output to serial. I started to dig into an "easy" way to publish the distance into MQTT but that's when I thought I would reach out and see if anybody has any plan/code on it. I had to put a little millis delay in to get it to read correctly and only report out if the distant changes by more than 10 inches but it works reliably, I just have to figure out hot to make it pretty for the web interface and MQTT output.

My use case is a garage door control with open/closed (distance) indicator and a sump pump monitor/override with water level (distance) logging.

Here is my simple loop code in case you are interested:
if (millis() >= lMillis + 250) {

  lMillis = millis();
  sDistNew = Ultrasonic.distanceRead(INC);

  if (sDistNew > sDist + 10 ){
    sDist = sDistNew;
    Serial.print("Distance in Inches: ");
    // Pass INC as a parameter to get the distance in inches
    Serial.println(sDist);
    //delay(1000);
  }
  else{
      if (sDistNew < sDist - 10 ){
      sDist = sDistNew;
      Serial.print("Distance in Inches: ");
      // Pass INC as a parameter to get the distance in inches
      Serial.println(sDist);
      //delay(1000);
  }
 }

}

@f0m3
Copy link

f0m3 commented Mar 18, 2017

Thats a cool idea. Id like to use the sonoff dual for my garage door control but id like to know if it is open or closed too...

@hamwong
Copy link

hamwong commented Mar 24, 2017

Wish SR04/05 will support in sonoff, power should not be the reason make SR04 not add as SR501 also use 5V

@davidelang davidelang added enhancement Type - Enhancement that will be worked on help needed Action - Asking for help from the community labels Mar 27, 2017
@quadflight
Copy link

Great idea. Did you get it to work?

@BernardLaurenzo
Copy link

The sonoff dev board has 5v
Im currently running my SR04 and sonoff dev with ESP easy firmware

@jetema
Copy link

jetema commented Oct 25, 2017

3inferior

Yes, 5 volts are available on D5 ( zenner diode in the middle of the pic ) terminals, you can get a few extra mA from this point to supply SR04

@Gompka
Copy link

Gompka commented Oct 25, 2017

You can also use this sensor https://www.bananarobotics.com/shop/US-100-Ultrasonic-Distance-Sensor-Module as it runs on 3.3v

@nosaj66au
Copy link

Hi Guys,
has this gone any further I required it for rain water tank level

Jason

arendst added a commit that referenced this issue Apr 20, 2018
5.12.0m
* Add support for sensor HC-SR04 ultrasonic (#113, #1964, #2444)
@fragolinux
Copy link

fragolinux commented Apr 30, 2018

HC-SR04P can work at 3.3V, you can recognize it because usually is blue as the other model, but has NO crystal oscillator on the front panel, look at image
s-l300

@scottchristian
Copy link

I'm going to throw my request for this as well.
Would be very nifty

@Frogmore42
Copy link
Contributor

Well you are in luck.
https://github.com/arendst/Sonoff-Tasmota/wiki/Wemos-D1-Mini-and-HC-SR04-Ultrasonic-Sensor

@ascillato
Copy link
Contributor

Now it is implemented. Closing.

@ascillato
Copy link
Contributor

?

@rajil
Copy link

rajil commented Jul 18, 2018

@Gompka I found the manual for US-100 here. Does this device work with 3.3V?

@Gompka
Copy link

Gompka commented Jul 18, 2018

Yea it does, I have been using it for over a year.

@rajil
Copy link

rajil commented Aug 3, 2018

@Gompka I tried to use PingSerial library with US-100 but that did not work. Do you have any example code which works on nodemcu?

@Gompka
Copy link

Gompka commented Aug 3, 2018

@rajil, did you make sure the jumper on the back of the us-100 is in the correct position? I do not have any code, but I am using the sensor with wemos d1 with opengarage. You can check the opengarage project for some code examples.

@rajil
Copy link

rajil commented Aug 4, 2018

@Gompka I was able to get it working after taking off the jumper. Is it possible to hook two ultrasonic sensors on the same ESP8266. In Tasmota 'configure module' 73/74 device type is Trigger/Echo. I assigned these to two devices, but only one device showed up.

curzon01 pushed a commit to curzon01/Tasmota that referenced this issue Sep 6, 2018
5.12.0m
* Add support for sensor HC-SR04 ultrasonic (arendst#113, arendst#1964, arendst#2444)
@nikito7
Copy link

nikito7 commented Oct 13, 2022

Can we change trigger time?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Type - Enhancement that will be worked on help needed Action - Asking for help from the community question Type - Asking for Information
Projects
None yet
Development

No branches or pull requests