mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-26 04:06:34 +00:00
Fix sensor coexistence
This commit is contained in:
parent
0e40de58dd
commit
dd4f16526e
@ -826,6 +826,7 @@ const char HTTP_SNS_GPM[] PROGMEM = "{s}%s " D_FLOW_RATE "{
|
|||||||
const char HTTP_SNS_MOISTURE[] PROGMEM = "{s}%s " D_MOISTURE "{m}%d " D_UNIT_PERCENT "{e}";
|
const char HTTP_SNS_MOISTURE[] PROGMEM = "{s}%s " D_MOISTURE "{m}%d " D_UNIT_PERCENT "{e}";
|
||||||
const char HTTP_SNS_RANGE[] PROGMEM = "{s}%s " D_RANGE "{m}%d" "{e}";
|
const char HTTP_SNS_RANGE[] PROGMEM = "{s}%s " D_RANGE "{m}%d" "{e}";
|
||||||
const char HTTP_SNS_DISTANCE[] PROGMEM = "{s}%s " D_DISTANCE "{m}%d " D_UNIT_MILLIMETER "{e}";
|
const char HTTP_SNS_DISTANCE[] PROGMEM = "{s}%s " D_DISTANCE "{m}%d " D_UNIT_MILLIMETER "{e}";
|
||||||
|
const char HTTP_SNS_DISTANCE_CM[] PROGMEM = "{s}%s " D_DISTANCE "{m}%s " D_UNIT_CENTIMETER "{e}";
|
||||||
const char HTTP_SNS_VOLTAGE[] PROGMEM = "{s}" D_VOLTAGE "{m}%s " D_UNIT_VOLT "{e}";
|
const char HTTP_SNS_VOLTAGE[] PROGMEM = "{s}" D_VOLTAGE "{m}%s " D_UNIT_VOLT "{e}";
|
||||||
const char HTTP_SNS_CURRENT[] PROGMEM = "{s}" D_CURRENT "{m}%s " D_UNIT_AMPERE "{e}";
|
const char HTTP_SNS_CURRENT[] PROGMEM = "{s}" D_CURRENT "{m}%s " D_UNIT_AMPERE "{e}";
|
||||||
const char HTTP_SNS_POWER[] PROGMEM = "{s}" D_POWERUSAGE "{m}%s " D_UNIT_WATT "{e}";
|
const char HTTP_SNS_POWER[] PROGMEM = "{s}" D_POWERUSAGE "{m}%s " D_UNIT_WATT "{e}";
|
||||||
|
@ -725,11 +725,18 @@ void ResponseAppendFeatures(void)
|
|||||||
|
|
||||||
static uint32_t feature8 = 0x00000000;
|
static uint32_t feature8 = 0x00000000;
|
||||||
if (!feature8) { // Only fill this once
|
if (!feature8) { // Only fill this once
|
||||||
// feature8 |= 0x00000001;
|
#if defined(USE_I2C) && defined(USE_MPU6886)
|
||||||
// feature8 |= 0x00000002;
|
feature8 |= 0x00000001; // xsns_85_mpu6886.ino
|
||||||
// feature8 |= 0x00000004;
|
#endif
|
||||||
// feature8 |= 0x00000008;
|
#ifdef USE_TFMINIPLUS
|
||||||
|
feature8 |= 0x00000002; // xsns_86_tfminiplus.ino
|
||||||
|
#endif
|
||||||
|
#if defined(USE_ENERGY_SENSOR) && defined(USE_CSE7761)
|
||||||
|
feature8 |= 0x00000004; // xnrg_19_cse7761.ino
|
||||||
|
#endif
|
||||||
|
#ifdef USE_BERRY
|
||||||
|
feature8 |= 0x00000008; // xdrv_52_9_berry.ino
|
||||||
|
#endif
|
||||||
// feature8 |= 0x00000010;
|
// feature8 |= 0x00000010;
|
||||||
// feature8 |= 0x00000020;
|
// feature8 |= 0x00000020;
|
||||||
// feature8 |= 0x00000040;
|
// feature8 |= 0x00000040;
|
||||||
|
@ -159,11 +159,6 @@ void Sr04TReading(void) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef USE_WEBSERVER
|
|
||||||
const char HTTP_SNS_DISTANCE_CM[] PROGMEM =
|
|
||||||
"{s}SR04 " D_DISTANCE "{m}%s" D_UNIT_CENTIMETER "{e}"; // {s} = <tr><th>, {m} = </th><td>, {e} = </td></tr>
|
|
||||||
#endif // USE_WEBSERVER
|
|
||||||
|
|
||||||
void Sr04Show(bool json)
|
void Sr04Show(bool json)
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -180,7 +175,7 @@ void Sr04Show(bool json)
|
|||||||
#endif // USE_DOMOTICZ
|
#endif // USE_DOMOTICZ
|
||||||
#ifdef USE_WEBSERVER
|
#ifdef USE_WEBSERVER
|
||||||
} else {
|
} else {
|
||||||
WSContentSend_PD(HTTP_SNS_DISTANCE_CM, distance_chr);
|
WSContentSend_PD(HTTP_SNS_DISTANCE_CM, "SR04", distance_chr);
|
||||||
#endif // USE_WEBSERVER
|
#endif // USE_WEBSERVER
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
xsns_86_tfminiplus.ino - TFmini Plus interface for Tasmota
|
xsns_86_tfminiplus.ino - TFmini Plus interface for Tasmota
|
||||||
|
|
||||||
Created by Raphael Breiting on 12.11.2020.
|
|
||||||
|
|
||||||
Copyright (C) 2021 Raphael Breiting and Theo Arends
|
Copyright (C) 2021 Raphael Breiting and Theo Arends
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
@ -19,23 +17,21 @@
|
|||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Conditional compilation of driver
|
|
||||||
#ifdef USE_TFMINIPLUS
|
#ifdef USE_TFMINIPLUS
|
||||||
|
|
||||||
/*****************************************************************************\
|
/*****************************************************************************\
|
||||||
* TFmini, TFmini Plus, TFmini Plus (Indoor Version), TFmini-S - LiDAR Module
|
* TFmini, TFmini Plus, TFmini Plus (Indoor Version), TFmini-S - LiDAR Module
|
||||||
* Manufacturer: Benewake (Beijing) Co. Ltd.
|
* Manufacturer: Benewake (Beijing) Co. Ltd.
|
||||||
*
|
*
|
||||||
* Code for Time-Of-Flight (TOF) family single-point short-range LiDAR sensor
|
* Code for Time-Of-Flight (TOF) family single-point short-range LiDAR sensor
|
||||||
* modules with UART interface.
|
* modules with UART interface.
|
||||||
*
|
*
|
||||||
* Connection Description for GH1.25-4P (Molex51021-0400) connector:
|
* Connection Description for GH1.25-4P (Molex51021-0400) connector:
|
||||||
* No Color Corresponding PIN Function Comment
|
* No Color Corresponding PIN Function Comment
|
||||||
* 1 RED PIN-1 +5V Power Supply
|
* 1 RED PIN-1 +5V Power Supply
|
||||||
* 2 WHITE PIN-2 RxD/SDA Receiving/Data
|
* 2 WHITE PIN-2 RxD/SDA Receiving/Data
|
||||||
* 3 GREEN PIN-3 TxD/SCL Transmitting/Clock
|
* 3 GREEN PIN-3 TxD/SCL Transmitting/Clock
|
||||||
* 4 BLACK PIN-4 GND Ground
|
* 4 BLACK PIN-4 GND Ground
|
||||||
*
|
*
|
||||||
* Before connecting module to Tasmota, please prepare module with
|
* Before connecting module to Tasmota, please prepare module with
|
||||||
* the following sequence through terminal program (e.g. Termite):
|
* the following sequence through terminal program (e.g. Termite):
|
||||||
* 1. Connect sensor to USB-to-UART (TTL 3.3V)
|
* 1. Connect sensor to USB-to-UART (TTL 3.3V)
|
||||||
@ -54,33 +50,27 @@
|
|||||||
* 7. When point 6 returned OK, than ready to connect to Tasmota! :)
|
* 7. When point 6 returned OK, than ready to connect to Tasmota! :)
|
||||||
* When point 6 returned FAIL, start with item 1 and
|
* When point 6 returned FAIL, start with item 1 and
|
||||||
* - check connection of RX and TX pin are not exchanged
|
* - check connection of RX and TX pin are not exchanged
|
||||||
* - check power supply
|
* - check power supply
|
||||||
* - 5V +-0,5V
|
* - 5V +-0,5V
|
||||||
* - 110mA average
|
* - 110mA average
|
||||||
* - 140mA max peak
|
* - 140mA max peak
|
||||||
*
|
*
|
||||||
* References:
|
* References:
|
||||||
* - http://en.benewake.com/product
|
* - http://en.benewake.com/product
|
||||||
* - https://de.aliexpress.com/item/32852024277.html?spm=a2g0s.9042311.0.0.27424c4d5Edizk
|
* - https://de.aliexpress.com/item/32852024277.html?spm=a2g0s.9042311.0.0.27424c4d5Edizk
|
||||||
* - https://de.aliexpress.com/item/4001076614996.html?spm=a2g0s.9042311.0.0.27424c4d5Edizk
|
* - https://de.aliexpress.com/item/4001076614996.html?spm=a2g0s.9042311.0.0.27424c4d5Edizk
|
||||||
\*****************************************************************************/
|
\*****************************************************************************/
|
||||||
|
|
||||||
#include <TasmotaSerial.h>
|
|
||||||
|
|
||||||
// Define driver ID
|
|
||||||
#define XSNS_86 86
|
#define XSNS_86 86
|
||||||
|
|
||||||
// Use special no wait serial driver, should be always on
|
|
||||||
#ifndef ESP32
|
|
||||||
#define SPECIAL_SS
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Default baudrate
|
// Default baudrate
|
||||||
#define BAUDRATE 9600
|
#define TFMP_SPEED 9600
|
||||||
|
|
||||||
// Serial buffer length for incoming data
|
// Serial buffer length for incoming data
|
||||||
#define TFMP_MAX_DATA_LEN 9
|
#define TFMP_MAX_DATA_LEN 9
|
||||||
|
|
||||||
|
#include <TasmotaSerial.h>
|
||||||
|
|
||||||
char Tfmp_buffer[TFMP_MAX_DATA_LEN + 1];
|
char Tfmp_buffer[TFMP_MAX_DATA_LEN + 1];
|
||||||
|
|
||||||
struct xsns_86_tfminiplus
|
struct xsns_86_tfminiplus
|
||||||
@ -101,7 +91,7 @@ void TfmpInit(void)
|
|||||||
if (PinUsed(GPIO_TFMINIPLUS_RX) && PinUsed(GPIO_TFMINIPLUS_TX))
|
if (PinUsed(GPIO_TFMINIPLUS_RX) && PinUsed(GPIO_TFMINIPLUS_TX))
|
||||||
{
|
{
|
||||||
TfmpSerial = new TasmotaSerial(Pin(GPIO_TFMINIPLUS_RX), Pin(GPIO_TFMINIPLUS_TX), 1);
|
TfmpSerial = new TasmotaSerial(Pin(GPIO_TFMINIPLUS_RX), Pin(GPIO_TFMINIPLUS_TX), 1);
|
||||||
if (TfmpSerial->begin(BAUDRATE))
|
if (TfmpSerial->begin(TFMP_SPEED))
|
||||||
{
|
{
|
||||||
if (TfmpSerial->hardwareSerial())
|
if (TfmpSerial->hardwareSerial())
|
||||||
{
|
{
|
||||||
@ -155,7 +145,7 @@ void TfmpProcessSerialData (void)
|
|||||||
bool dataReady;
|
bool dataReady;
|
||||||
if (TfmpSerial && tfminiplus_sensor.ready)
|
if (TfmpSerial && tfminiplus_sensor.ready)
|
||||||
{
|
{
|
||||||
while (TfmpSerial->available() > 0)
|
while (TfmpSerial->available() > 0)
|
||||||
{
|
{
|
||||||
data = TfmpSerial->read();
|
data = TfmpSerial->read();
|
||||||
dataReady = TfmpAddData((char)data);
|
dataReady = TfmpAddData((char)data);
|
||||||
@ -168,7 +158,7 @@ void TfmpProcessSerialData (void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool TfmpAddData(char nextChar)
|
bool TfmpAddData(char nextChar)
|
||||||
{
|
{
|
||||||
// Buffer position
|
// Buffer position
|
||||||
static uint8_t currentIndex = 0;
|
static uint8_t currentIndex = 0;
|
||||||
// Store data into buffer at position
|
// Store data into buffer at position
|
||||||
@ -187,27 +177,30 @@ bool TfmpAddData(char nextChar)
|
|||||||
|
|
||||||
#ifdef USE_WEBSERVER
|
#ifdef USE_WEBSERVER
|
||||||
// {s} = <tr><th>, {m} = </th><td>, {e} = </td></tr>
|
// {s} = <tr><th>, {m} = </th><td>, {e} = </td></tr>
|
||||||
const char HTTP_SNS_DISTANCE_CM[] PROGMEM = "{s} " D_DISTANCE "{m}%d" D_UNIT_CENTIMETER "{e}";
|
const char HTTP_SNS_SIGNALSTRENGTH[] PROGMEM = "{s}%s " D_SIGNALSTRENGTH "{m}%d{e}";
|
||||||
const char HTTP_SNS_SIGNALSTRENGTH[] PROGMEM = "{s} " D_SIGNALSTRENGTH "{m}%d{e}";
|
const char HTTP_SNS_CHIPTEMPERATURE[] PROGMEM = "{s}%s " D_CHIPTEMPERATURE "{m}%d " D_UNIT_DEGREE "%c{e}";
|
||||||
const char HTTP_SNS_CHIPTEMPERATURE[] PROGMEM = "{s} " D_CHIPTEMPERATURE "{m}%d" D_UNIT_DEGREE D_UNIT_CELSIUS "{e}";
|
|
||||||
#endif // USE_WEBSERVER
|
#endif // USE_WEBSERVER
|
||||||
|
|
||||||
void TfmpShow(bool json)
|
void TfmpShow(bool json)
|
||||||
{
|
{
|
||||||
|
char sensor_name[12];
|
||||||
|
strcpy_P(sensor_name, "TFminiPlus");
|
||||||
|
char distance_chr[FLOATSZ];
|
||||||
|
dtostrfd(tfminiplus_sensor.distance, 3, distance_chr);
|
||||||
|
|
||||||
if (json) {
|
if (json) {
|
||||||
ResponseAppend_P(PSTR(",\"TFmini Plus\":{\"" D_JSON_DISTANCE "\":\"%d\",\"" D_JSON_SIGNALSTRENGTH "\":\"%d\",\"" D_JSON_CHIPTEMPERATURE "\":%d}"),
|
ResponseAppend_P(PSTR(",\"%s\":{\"" D_JSON_DISTANCE "\":\"%s\",\"" D_JSON_SIGNALSTRENGTH "\":\"%d\",\"" D_JSON_CHIPTEMPERATURE "\":%d}"),
|
||||||
tfminiplus_sensor.distance, tfminiplus_sensor.sigstrength, tfminiplus_sensor.chiptemp);
|
sensor_name, distance_chr, tfminiplus_sensor.sigstrength, tfminiplus_sensor.chiptemp);
|
||||||
#ifdef USE_DOMOTICZ
|
#ifdef USE_DOMOTICZ
|
||||||
if (0 == TasmotaGlobal.tele_period) {
|
if (0 == TasmotaGlobal.tele_period) {
|
||||||
DomoticzFloatSensor(DZ_COUNT, tfminiplus_sensor.distance);
|
DomoticzSensor(DZ_COUNT, distance_chr);
|
||||||
}
|
}
|
||||||
#endif // USE_DOMOTICZ
|
#endif // USE_DOMOTICZ
|
||||||
#ifdef USE_WEBSERVER
|
#ifdef USE_WEBSERVER
|
||||||
} else {
|
} else {
|
||||||
WSContentSend_P("{s}TFmini Plus");
|
WSContentSend_P(HTTP_SNS_DISTANCE_CM, sensor_name, distance_chr);
|
||||||
WSContentSend_P(HTTP_SNS_DISTANCE_CM, tfminiplus_sensor.distance);
|
WSContentSend_P(HTTP_SNS_SIGNALSTRENGTH, sensor_name, tfminiplus_sensor.sigstrength);
|
||||||
WSContentSend_P(HTTP_SNS_SIGNALSTRENGTH, tfminiplus_sensor.sigstrength);
|
WSContentSend_P(HTTP_SNS_CHIPTEMPERATURE, sensor_name, tfminiplus_sensor.chiptemp, TempUnit());
|
||||||
WSContentSend_P(HTTP_SNS_CHIPTEMPERATURE, tfminiplus_sensor.chiptemp);
|
|
||||||
#endif // USE_WEBSERVER
|
#endif // USE_WEBSERVER
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -177,7 +177,9 @@ a_setoption = [[
|
|||||||
"(Zigbee) Append endpoint number to topic if device dependent (use with SetOption89)",
|
"(Zigbee) Append endpoint number to topic if device dependent (use with SetOption89)",
|
||||||
"(MQTT) Retain on State",
|
"(MQTT) Retain on State",
|
||||||
"(MQTT) Retain on Info",
|
"(MQTT) Retain on Info",
|
||||||
"","","",
|
"(Wiegand) switch tag number output to hex format (1)",
|
||||||
|
"(Wiegand) send key pad stroke as single char (0) or one tag (ending char #) (1)",
|
||||||
|
"(Zigbee) Hide bridge topic from zigbee topic (use with SetOption89) (1)",
|
||||||
"","","","",
|
"","","","",
|
||||||
"","","","",
|
"","","","",
|
||||||
"","","","",
|
"","","","",
|
||||||
@ -249,7 +251,7 @@ a_features = [[
|
|||||||
"USE_BS814A2","USE_SEESAW_SOIL","USE_WIEGAND","USE_NEOPOOL",
|
"USE_BS814A2","USE_SEESAW_SOIL","USE_WIEGAND","USE_NEOPOOL",
|
||||||
"USE_TOF10120","USE_SDM72","USE_DISPLAY_TM1637","USE_PROJECTOR_CTRL"
|
"USE_TOF10120","USE_SDM72","USE_DISPLAY_TM1637","USE_PROJECTOR_CTRL"
|
||||||
],[
|
],[
|
||||||
"USE_TFMINIPLUS","","","",
|
"USE_MPU6886","USE_TFMINIPLUS","USE_CSE7761","USE_BERRY",
|
||||||
"","","","",
|
"","","","",
|
||||||
"","","","",
|
"","","","",
|
||||||
"","","","",
|
"","","","",
|
||||||
@ -284,7 +286,7 @@ else:
|
|||||||
obj = json.load(fp)
|
obj = json.load(fp)
|
||||||
|
|
||||||
def StartDecode():
|
def StartDecode():
|
||||||
print ("\n*** decode-status.py v20210222 by Theo Arends and Jacek Ziolkowski ***")
|
print ("\n*** decode-status.py v20210323 by Theo Arends and Jacek Ziolkowski ***")
|
||||||
|
|
||||||
# print("Decoding\n{}".format(obj))
|
# print("Decoding\n{}".format(obj))
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user