Tasmota: SR04 Ultrasonic sensor support?

Created on 26 Feb 2017  路  20Comments  路  Source: arendst/Tasmota

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!

enhancement help needed question

Most helpful comment

All 20 comments

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

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

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);
  }
 }

}

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...

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

Great idea. Did you get it to work?

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

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

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

Jason

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

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

Now it is implemented. Closing.

?

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

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

@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?

@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.

@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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

wirelesssolution picture wirelesssolution  路  3Comments

belidzs picture belidzs  路  3Comments

esp32x picture esp32x  路  3Comments

ximonline picture ximonline  路  3Comments

Ndrinta picture Ndrinta  路  3Comments