Add support for DYP ME007

Add support for DYP ME007 ultrasonic distance sensor by Janusz Kostorz (#9113)
This commit is contained in:
Theo Arends 2020-08-17 16:25:24 +02:00
parent 44e2c6b6a7
commit 4724fa2c49
9 changed files with 151 additions and 98 deletions

View File

@ -56,9 +56,13 @@ The following binary downloads have been compiled with ESP8266/Arduino library c
### Version 8.4.0.2
- Remove support for 1-step upgrade from versions before 6.6.0.11 to versions after 8.4.0.1
- Change White blend mode moved to using ``SetOption 105`` instead of ``RGBWWTable``
- Fix ESP32 PWM range
- Add Zigbee better support for IKEA Motion Sensor
- Fix display power control (#9114)
- Add command ``SetOption108 0/1`` to enable Teleinfo telemetry into Tasmota Energy MQTT (0) or Teleinfo only (1) - Add Zigbee better support for IKEA Motion Sensor
- Add command ``Restart 2`` to halt system. Needs hardware reset or power cycle to restart (#9046)
- Add ESP32 Analog input support for GPIO32 to GPIO39
- Add Zigbee options to ``ZbSend`` ``Config`` and ``ReadCondig``
- Add command ``Restart 2`` to halt system. Needs hardware reset or power cycle to restart (#9046)
- Add better config corruption recovery (#9046)
- Add virtual CT for 4 channels lights, emulating a 5th channel
- Add support for DYP ME007 ultrasonic distance sensor by Janusz Kostorz (#9113)

View File

@ -2,11 +2,12 @@
### 8.4.0.2 20200813
- Add better config corruption recovery (#9046)
- Remove support for 1-step upgrade from versions before 6.6.0.11 to versions after 8.4.0.1
- Add command ``SetOption108 0/1`` to enable Teleinfo telemetry into Tasmota Energy MQTT (0) or Teleinfo only (1) in this case MQTT will send RAW Teleinfo telemetry on each frame received and not into Tasmota energy calculation telemetry.
- Change White blend mode moved to using ``SetOption 105`` instead of ``RGBWWTable``
- Add Virtual CT for 4 channels lights, emulating a 5th channel
- Fix display power control (#9114)
- Add command ``SetOption108 0/1`` to enable Teleinfo telemetry into Tasmota Energy MQTT (0) or Teleinfo only (1) - Add better config corruption recovery (#9046)
- Add virtual CT for 4 channels lights, emulating a 5th channel
- Add support for DYP ME007 ultrasonic distance sensor by Janusz Kostorz (#9113)
### 8.4.0.1 20200730

View File

@ -604,6 +604,8 @@
//#define USE_NOVA_SDS // Add support for SDS011 and SDS021 particle concentration sensor (+1k5 code)
#define STARTING_OFFSET 30 // Turn on NovaSDS XX-seconds before tele_period is reached
//#define USE_HPMA // Add support for Honeywell HPMA115S0 particle concentration sensor (+1k4)
//#define USE_SR04 // Add support for HC-SR04 ultrasonic devices (+1k code)
//#define USE_DYP // Add support for DYP ME-007 ultrasonic distance sensor, serial port version (+0k5 code)
#define USE_SERIAL_BRIDGE // Add support for software Serial Bridge (+0k8 code)
//#define USE_TCP_BRIDGE // Add support for Serial to TCP bridge (+1.3k code)
//#define USE_MP3_PLAYER // Use of the DFPlayer Mini MP3 Player RB-DFR-562 commands: play, volume and stop
@ -619,7 +621,6 @@
// #define USE_FLOG // Add support for GPS logging in OTA's Flash (Experimental) (+2k9 code, +8 bytes RAM)
//#define USE_HM10 // (ESP8266 only) Add support for HM-10 as a BLE-bridge (+9k3 code)
//#define USE_HRXL // Add support for MaxBotix HRXL-MaxSonar ultrasonic range finders (+0k7)
//#define USE_DYP // Add support for DYP ME-007 ultrasonic distance sensor, serial port version (+0k5 code)
//#define USE_TASMOTA_CLIENT // Add support for Arduino Uno/Pro Mini via serial interface including flashing (+2k6 code, 64 mem)
#define USE_TASMOTA_CLIENT_FLASH_SPEED 57600 // Usually 57600 for 3.3V variants and 115200 for 5V variants
#define USE_TASMOTA_CLIENT_SERIAL_SPEED 57600 // Depends on the sketch that is running on the Uno/Pro Mini
@ -699,8 +700,6 @@
// -- Other sensors/drivers -----------------------
//#define USE_SR04 // Add support for HC-SR04 ultrasonic devices (+1k code)
//#define USE_TM1638 // Add support for TM1638 switches copying Switch1 .. Switch8 (+1k code)
//#define USE_HX711 // Add support for HX711 load cell (+1k5 code)
// #define USE_HX711_GUI // Add optional web GUI to HX711 as scale (+1k8 code)

View File

@ -479,7 +479,7 @@ void CmndStatus(void)
",\"" D_JSON_FLASHCHIPID "\":\"%06X\""
#endif
",\"FlashFrequency\":%d,\"" D_JSON_FLASHMODE "\":%d,\""
D_JSON_FEATURES "\":[\"%08X\",\"%08X\",\"%08X\",\"%08X\",\"%08X\",\"%08X\",\"%08X\"]"),
D_JSON_FEATURES "\":[\"%08X\",\"%08X\",\"%08X\",\"%08X\",\"%08X\",\"%08X\",\"%08X\",\"%08X\"]"),
ESP_getSketchSize()/1024, ESP.getFreeSketchSpace()/1024, ESP_getFreeHeap()/1024,
#ifdef ESP32
ESP.getPsramSize()/1024, ESP.getFreePsram()/1024,
@ -489,7 +489,7 @@ void CmndStatus(void)
, ESP.getFlashChipId()
#endif
, ESP.getFlashChipSpeed()/1000000, ESP.getFlashChipMode(),
LANGUAGE_LCID, feature_drv1, feature_drv2, feature_sns1, feature_sns2, feature5, feature6);
LANGUAGE_LCID, feature_drv1, feature_drv2, feature_sns1, feature_sns2, feature5, feature6, feature7);
XsnsDriverState();
ResponseAppend_P(PSTR(",\"Sensors\":"));
XsnsSensorState();

View File

@ -595,7 +595,9 @@ void GetFeatures(void)
#if defined(USE_ENERGY_SENSOR) && defined(USE_IEM3000)
feature6 |= 0x00200000; // xnrg_16_iem3000.ino
#endif
// feature6 |= 0x00400000;
#ifdef USE_DYP
feature6 |= 0x00400000; // xsns_76_dyp.ino
#endif
// feature6 |= 0x00800000;
// feature6 |= 0x01000000;
@ -611,4 +613,50 @@ void GetFeatures(void)
#if defined(ESP32) && defined(USE_WEBCAM)
feature6 |= 0x80000000; // xdrv_81_webcam.ino
#endif
}
/*********************************************************************************************/
feature7 = 0x00000000;
// feature7 |= 0x00000001;
// feature7 |= 0x00000002;
// feature7 |= 0x00000004;
// feature7 |= 0x00000008;
// feature7 |= 0x00000010;
// feature7 |= 0x00000020;
// feature7 |= 0x00000040;
// feature7 |= 0x00000080;
// feature7 |= 0x00000100;
// feature7 |= 0x00000200;
// feature7 |= 0x00000400;
// feature7 |= 0x00000800;
// feature7 |= 0x00001000;
// feature7 |= 0x00002000;
// feature7 |= 0x00004000;
// feature7 |= 0x00008000;
// feature7 |= 0x00010000;
// feature7 |= 0x00020000;
// feature7 |= 0x00040000;
// feature7 |= 0x00080000;
// feature7 |= 0x00100000;
// feature7 |= 0x00200000;
// feature7 |= 0x00400000;
// feature7 |= 0x00800000;
// feature7 |= 0x01000000;
// feature7 |= 0x02000000;
// feature7 |= 0x04000000;
// feature7 |= 0x08000000;
// feature7 |= 0x10000000;
// feature7 |= 0x20000000;
// feature7 |= 0x40000000;
// feature7 |= 0x80000000;
} // GetFeatures

View File

@ -82,6 +82,7 @@ unsigned long feature_sns1; // Compiled sensor feature map
unsigned long feature_sns2; // Compiled sensor feature map
unsigned long feature5; // Compiled feature map
unsigned long feature6; // Compiled feature map
unsigned long feature7; // Compiled feature map
unsigned long serial_polling_window = 0; // Serial polling window
unsigned long state_second = 0; // State second timer
unsigned long state_50msecond = 0; // State 50msecond timer

View File

@ -140,6 +140,8 @@
//#define PMS_MODEL_PMS3003 // Enable support of PMS3003 instead of PMS5003/PMS7003 (needs the USE_PMS5003 above)
#define USE_NOVA_SDS // Add support for SDS011 and SDS021 particle concentration sensor (+0k7 code)
#define USE_HPMA // Add support for Honeywell HPMA115S0 particle concentration sensor
#define USE_SR04 // Add support for HC-SR04 ultrasonic devices (+1k code)
//#define USE_DYP // Add support for DYP ME-007 ultrasonic distance sensor, serial port version (+0k5 code)
#define USE_SERIAL_BRIDGE // Add support for software Serial Bridge (+0k8 code)
#define USE_MP3_PLAYER // Use of the DFPlayer Mini MP3 Player RB-DFR-562 commands: play, volume and stop
#define MP3_VOLUME 10 // Set the startup volume on init, the range can be 0..30(max)
@ -177,7 +179,6 @@
#define USE_IR_RECEIVE // Support for IR receiver (+5k5 code, 264 iram)
#define USE_LMT01 // Add support for TI LMT01 temperature sensor, count pulses on single GPIO (+0k5 code)
#define USE_SR04 // Add support for HC-SR04 ultrasonic devices (+1k code)
#define USE_TM1638 // Add support for TM1638 switches copying Switch1 .. Switch8 (+1k code)
#define USE_HX711 // Add support for HX711 load cell (+1k5 code)
//#define USE_HX711_GUI // Add optional web GUI to HX711 as scale (+1k8 code)
@ -374,6 +375,8 @@
#undef USE_PMS5003 // Disable support for PMS5003 and PMS7003 particle concentration sensor
#undef USE_NOVA_SDS // Disable support for SDS011 and SDS021 particle concentration sensor
#undef USE_HPMA // Disable support for Honeywell HPMA115S0 particle concentration sensor
#undef USE_SR04 // Disable support for HC-SR04 ultrasonic devices (+1k code)
#undef USE_DYP // Disable support for DYP ME-007 ultrasonic distance sensor, serial port version (+0k5 code)
#undef USE_SERIAL_BRIDGE // Disable support for software Serial Bridge
#undef USE_MP3_PLAYER // Disable DFPlayer Mini MP3 Player RB-DFR-562 commands: play, volume and stop
#undef USE_AZ7798 // Disable support for AZ-Instrument 7798 CO2 datalogger
@ -391,7 +394,6 @@
#undef USE_DHT // Disable support for DHT11, AM2301 (DHT21, DHT22, AM2302, AM2321) and SI7021 Temperature and Humidity sensor
#undef USE_MAX31855 // Disable MAX31855 K-Type thermocouple sensor using softSPI
#undef USE_MAX31865 // Disable support for MAX31865 RTD sensors using softSPI
#undef USE_SR04 // Disable support for for HC-SR04 ultrasonic devices
#undef USE_TM1638 // Disable support for TM1638 switches copying Switch1 .. Switch8
#undef USE_HX711 // Disable support for HX711 load cell
#undef USE_TX20_WIND_SENSOR // Disable support for La Crosse TX20 anemometer
@ -477,7 +479,7 @@
#undef USE_COUNTER // Disable counters
#define USE_ADC_VCC // Display Vcc in Power status. Disable for use as Analog input on selected devices
#undef USE_DS18x20 // Disable DS18x20 sensor
//#undef USE_I2C // Enable I2C, zbbridge uses i2c EEprom
//#undef USE_I2C // Enable I2C, zbbridge uses i2c EEprom
#undef USE_SPI // Disable all SPI devices
#undef USE_DISPLAY // Disable Display support
#undef USE_MHZ19 // Disable support for MH-Z19 CO2 sensor
@ -485,6 +487,8 @@
#undef USE_PMS5003 // Disable support for PMS5003 and PMS7003 particle concentration sensor
#undef USE_NOVA_SDS // Disable support for SDS011 and SDS021 particle concentration sensor
#undef USE_HPMA // Disable support for Honeywell HPMA115S0 particle concentration sensor
#undef USE_SR04 // Disable support for HC-SR04 ultrasonic devices (+1k code)
#undef USE_DYP // Disable support for DYP ME-007 ultrasonic distance sensor, serial port version (+0k5 code)
#undef USE_SERIAL_BRIDGE // Disable support for software Serial Bridge
#undef USE_MP3_PLAYER // Disable DFPlayer Mini MP3 Player RB-DFR-562 commands: play, volume and stop
#undef USE_AZ7798 // Disable support for AZ-Instrument 7798 CO2 datalogger
@ -519,7 +523,6 @@
#undef USE_MAX31865 // Disable support for MAX31865 RTD sensors using softSPI
#undef USE_IR_REMOTE // Disable IR driver
#undef USE_SR04 // Disable support for for HC-SR04 ultrasonic devices
#undef USE_TM1638 // Disable support for TM1638 switches copying Switch1 .. Switch8
#undef USE_HX711 // Disable support for HX711 load cell
#undef USE_TX20_WIND_SENSOR // Disable support for La Crosse TX20 anemometer
@ -618,6 +621,8 @@
#undef USE_PMS5003 // Disable support for PMS5003 and PMS7003 particle concentration sensor
#undef USE_NOVA_SDS // Disable support for SDS011 and SDS021 particle concentration sensor
#undef USE_HPMA // Disable support for Honeywell HPMA115S0 particle concentration sensor
#undef USE_SR04 // Disable support for HC-SR04 ultrasonic devices (+1k code)
#undef USE_DYP // Disable support for DYP ME-007 ultrasonic distance sensor, serial port version (+0k5 code)
#undef USE_SERIAL_BRIDGE // Disable support for software Serial Bridge
#undef USE_MP3_PLAYER // Disable DFPlayer Mini MP3 Player RB-DFR-562 commands: play, volume and stop
#undef USE_AZ7798 // Disable support for AZ-Instrument 7798 CO2 datalogger
@ -651,7 +656,6 @@
#undef USE_MAX31865 // Disable support for MAX31865 RTD sensors using softSPI
#undef USE_IR_REMOTE // Disable IR driver
#undef USE_SR04 // Disable support for for HC-SR04 ultrasonic devices
#undef USE_TM1638 // Disable support for TM1638 switches copying Switch1 .. Switch8
#undef USE_HX711 // Disable support for HX711 load cell
#undef USE_TX20_WIND_SENSOR // Disable support for La Crosse TX20 anemometer
@ -749,6 +753,8 @@
#undef USE_PMS5003 // Disable support for PMS5003 and PMS7003 particle concentration sensor
#undef USE_NOVA_SDS // Disable support for SDS011 and SDS021 particle concentration sensor
#undef USE_HPMA // Disable support for Honeywell HPMA115S0 particle concentration sensor
#undef USE_SR04 // Disable support for HC-SR04 ultrasonic devices (+1k code)
#undef USE_DYP // Disable support for DYP ME-007 ultrasonic distance sensor, serial port version (+0k5 code)
#undef USE_SERIAL_BRIDGE // Disable support for software Serial Bridge
#undef USE_TCP_BRIDGE // DIsable support for Serial to TCP bridge (+1.3k code)
#undef USE_MP3_PLAYER // Disable DFPlayer Mini MP3 Player RB-DFR-562 commands: play, volume and stop
@ -784,7 +790,6 @@
#undef USE_MAX31865 // Disable support for MAX31865 RTD sensors using softSPI
#undef USE_LMT01 // Disable support for TI LMT01 temperature sensor, count pulses on single GPIO (+0k5 code)
#undef USE_IR_REMOTE // Disable IR driver
#undef USE_SR04 // Disable support for for HC-SR04 ultrasonic devices
#undef USE_TM1638 // Disable support for TM1638 switches copying Switch1 .. Switch8
#undef USE_HX711 // Disable support for HX711 load cell
#undef USE_TX20_WIND_SENSOR // Disable support for La Crosse TX20 anemometer

View File

@ -3,12 +3,12 @@
Copyright (C) 2020 Janusz Kostorz
This program is free software: you can reDYPDistanceribute it and/or modify
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is DYPDistanceributed in the hope that it will be useful,
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
@ -20,7 +20,7 @@
#ifdef USE_DYP
/*********************************************************************************************\
* DYP ME007 ultrasonic distanceance sensor (300...4000mm), serial version
* DYP ME007 ultrasonic distance sensor (300...4000mm), serial version
*
* Every one second code check last received value from sensor via serial port and return:
* -1 for checksum error
@ -49,93 +49,79 @@ bool DYPSensor = false; // sensor available
/*********************************************************************************************/
void DYPInit(void)
{
DYPSensor = false;
if (PinUsed(GPIO_DYP_RX))
{
DYPSerial = new TasmotaSerial(Pin(GPIO_DYP_RX), -1, 1);
if (DYPSerial->begin(9600))
{
if (DYPSerial->hardwareSerial())
ClaimSerial();
DYPSensor = true;
}
void DYPInit(void) {
DYPSensor = false;
if (PinUsed(GPIO_DYP_RX)) {
DYPSerial = new TasmotaSerial(Pin(GPIO_DYP_RX), -1, 1);
if (DYPSerial->begin(9600)) {
if (DYPSerial->hardwareSerial()) {
ClaimSerial();
}
DYPSensor = true;
}
}
}
void DYPEverySecond(void)
{
if (!DYPSensor)
return;
void DYPEverySecond(void) {
if (!DYPSensor) { return; }
// check for serial data
if (DYPSerial->available() < 6)
{
DYPDistance = DYP_NOSENSOR;
return;
// check for serial data
if (DYPSerial->available() < 6) {
DYPDistance = DYP_NOSENSOR;
return;
}
// trash old data (only 7 last bytes are needed for calculate distance)
while (DYPSerial->available() > 7) {
DYPSerial->read();
}
// read data from serial port - * 0xFF MSB LSB CRC *
while (DYPSerial->available() > 3) {
// check for start byte signature
if (DYPSerial->read() != 0xFF) {
continue;
}
// trash old data (only 7 last bytes are needed for calculate distance)
while (DYPSerial->available() > 7)
DYPSerial->read();
// read data from serial port - * 0xFF MSB LSB CRC *
while (DYPSerial->available() > 3)
{
// check for start byte signature
if (DYPSerial->read() != 0xFF)
continue;
// check for data bytes
if (DYPSerial->available() > 2)
{
uint8_t msb = DYPSerial->read();
uint8_t lsb = DYPSerial->read();
if (((uint16_t)(0xFF + msb + lsb) & 0xFF) == DYPSerial->read()) {
uint16_t data = (msb << 8) | lsb;
if (data < DYP_MIN)
data = DYP_BELOWMIN;
if (data > DYP_MAX)
data = DYP_ABOVEMAX;
DYPDistance = data;
}
else {
DYPDistance = DYP_CRCERROR;
}
// check for data bytes
if (DYPSerial->available() > 2) {
uint8_t msb = DYPSerial->read();
uint8_t lsb = DYPSerial->read();
if (((uint16_t)(0xFF + msb + lsb) & 0xFF) == DYPSerial->read()) {
uint16_t data = (msb << 8) | lsb;
if (data < DYP_MIN) {
data = DYP_BELOWMIN;
}
if (data > DYP_MAX) {
data = DYP_ABOVEMAX;
}
DYPDistance = data;
} else {
DYPDistance = DYP_CRCERROR;
}
}
}
}
void DYPShow(bool json)
{
char types[5] = "DYP";
if (json)
{
ResponseAppend_P(PSTR(",\"%s\":{\"" D_DISTANCE "\":%d}"), types, DYPDistance);
#ifdef USE_WEBSERVER
}
else
{
WSContentSend_PD(HTTP_SNS_RANGE, types, DYPDistance);
#endif // USE_WEBSERVER
}
void DYPShow(bool json) {
char types[5] = "DYP";
if (json) {
ResponseAppend_P(PSTR(",\"%s\":{\"" D_DISTANCE "\":%d}"), types, DYPDistance);
#ifdef USE_WEBSERVER
} else {
WSContentSend_PD(HTTP_SNS_RANGE, types, DYPDistance);
#endif // USE_WEBSERVER
}
}
/*********************************************************************************************\
* Interface
\*********************************************************************************************/
bool Xsns76(uint8_t function)
{
if (!PinUsed(GPIO_DYP_RX))
return false;
bool Xsns76(uint8_t function) {
if (!PinUsed(GPIO_DYP_RX)) { return false; }
switch (function)
{
switch (function) {
case FUNC_INIT:
DYPInit();
break;
@ -145,13 +131,13 @@ bool Xsns76(uint8_t function)
case FUNC_JSON_APPEND:
DYPShow(1);
break;
#ifdef USE_WEBSERVER
#ifdef USE_WEBSERVER
case FUNC_WEB_SENSOR:
DYPShow(0);
break;
#endif // USE_WEBSERVER
}
return false;
#endif // USE_WEBSERVER
}
return false;
}
#endif // USE_DYP

View File

@ -220,9 +220,18 @@ a_features = [[
"USE_WINDMETER","USE_OPENTHERM","USE_THERMOSTAT","USE_VEML6075",
"USE_VEML7700","USE_MCP9808","USE_BL0940","USE_TELEGRAM",
"USE_HP303B","USE_TCP_BRIDGE","USE_TELEINFO","USE_LMT01",
"USE_PROMETHEUS","USE_IEM3000","","",
"USE_PROMETHEUS","USE_IEM3000","USE_DYP","",
"","","","",
"","","USE_ETHERNET","USE_WEBCAM"
],[
"","","","",
"","","","",
"","","","",
"","","","",
"","","","",
"","","","",
"","","","",
"","","",""
]]
usage = "usage: decode-status {-d | -f} arg"
@ -250,7 +259,7 @@ else:
obj = json.load(fp)
def StartDecode():
print ("\n*** decode-status.py v20200721 by Theo Arends and Jacek Ziolkowski ***")
print ("\n*** decode-status.py v20200817 by Theo Arends and Jacek Ziolkowski ***")
# print("Decoding\n{}".format(obj))
@ -300,7 +309,7 @@ def StartDecode():
if "StatusMEM" in obj:
if "Features" in obj["StatusMEM"]:
features = []
for f in range(6):
for f in range(7):
feature = obj["StatusMEM"]["Features"][f]
i_feature = int(feature,16)
if f == 0: