From 487f4a9191194cd69934f8a757aba169c05273ac Mon Sep 17 00:00:00 2001 From: VanillaFord <48869131+VanillaFord@users.noreply.github.com> Date: Wed, 15 Apr 2020 09:36:23 +0200 Subject: [PATCH] if GPIO_SR04_TRIG is not configured use single PIN mode with GPIO_SR04_ECHO only enable single PIN mode for SR04 sensor. If pin GPIO_SR04_TRIG is not configured, use sensor interface in single PIN mode with GPIO_SR04_ECHO only See as depicted in newping library, see: https://bitbucket.org/teckel12/arduino-new-ping/wiki/Home#!single-pin-sketch --- tasmota/xsns_22_sr04.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasmota/xsns_22_sr04.ino b/tasmota/xsns_22_sr04.ino index 636992a57..54e1c00f8 100644 --- a/tasmota/xsns_22_sr04.ino +++ b/tasmota/xsns_22_sr04.ino @@ -47,7 +47,7 @@ uint8_t Sr04TModeDetect(void) if (pin[GPIO_SR04_ECHO]>=99) return sr04_type; sr04_echo_pin = pin[GPIO_SR04_ECHO]; - sr04_trig_pin = (pin[GPIO_SR04_TRIG] < 99) ? pin[GPIO_SR04_TRIG] : -1; + sr04_trig_pin = (pin[GPIO_SR04_TRIG] < 99) ? pin[GPIO_SR04_TRIG] : pin[GPIO_SR04_ECHO]; // if GPIO_SR04_TRIG is not configured use single PIN mode with GPIO_SR04_ECHO only sonar_serial = new TasmotaSerial(sr04_echo_pin, sr04_trig_pin, 1); if (sonar_serial->begin(9600,1)) {