mirror of https://github.com/arendst/Tasmota.git
Merge pull request #6555 from pablozg/ddsu666
add support to chint ddsu666
This commit is contained in:
commit
aeaea9f0b8
|
@ -617,6 +617,8 @@
|
|||
#define D_SENSOR_A4988_MS3 "A4988 MS3"
|
||||
#define D_SENSOR_DDS2382_TX "DDS238-2 Tx"
|
||||
#define D_SENSOR_DDS2382_RX "DDS238-2 Rx"
|
||||
#define D_SENSOR_DDSU666_TX "DDSU666 Tx"
|
||||
#define D_SENSOR_DDSU666_RX "DDSU666 Rx"
|
||||
|
||||
// Units
|
||||
#define D_UNIT_AMPERE "A"
|
||||
|
|
|
@ -617,6 +617,8 @@
|
|||
#define D_SENSOR_A4988_MS3 "A4988 MS3"
|
||||
#define D_SENSOR_DDS2382_TX "DDS238-2 Tx"
|
||||
#define D_SENSOR_DDS2382_RX "DDS238-2 Rx"
|
||||
#define D_SENSOR_DDSU666_TX "DDSU666 Tx"
|
||||
#define D_SENSOR_DDSU666_RX "DDSU666 Rx"
|
||||
|
||||
// Units
|
||||
#define D_UNIT_AMPERE "A"
|
||||
|
|
|
@ -617,6 +617,8 @@
|
|||
#define D_SENSOR_A4988_MS3 "A4988 MS3"
|
||||
#define D_SENSOR_DDS2382_TX "DDS238-2 Tx"
|
||||
#define D_SENSOR_DDS2382_RX "DDS238-2 Rx"
|
||||
#define D_SENSOR_DDSU666_TX "DDSU666 Tx"
|
||||
#define D_SENSOR_DDSU666_RX "DDSU666 Rx"
|
||||
|
||||
// Units
|
||||
#define D_UNIT_AMPERE "A"
|
||||
|
|
|
@ -617,6 +617,8 @@
|
|||
#define D_SENSOR_A4988_MS3 "A4988 MS3"
|
||||
#define D_SENSOR_DDS2382_TX "DDS238-2 Tx"
|
||||
#define D_SENSOR_DDS2382_RX "DDS238-2 Rx"
|
||||
#define D_SENSOR_DDSU666_TX "DDSU666 Tx"
|
||||
#define D_SENSOR_DDSU666_RX "DDSU666 Rx"
|
||||
|
||||
// Units
|
||||
#define D_UNIT_AMPERE "A"
|
||||
|
|
|
@ -617,6 +617,8 @@
|
|||
#define D_SENSOR_A4988_MS3 "A4988 MS3"
|
||||
#define D_SENSOR_DDS2382_TX "DDS238-2 Tx"
|
||||
#define D_SENSOR_DDS2382_RX "DDS238-2 Rx"
|
||||
#define D_SENSOR_DDSU666_TX "DDSU666 Tx"
|
||||
#define D_SENSOR_DDSU666_RX "DDSU666 Rx"
|
||||
|
||||
// Units
|
||||
#define D_UNIT_AMPERE "A"
|
||||
|
|
|
@ -617,6 +617,8 @@
|
|||
#define D_SENSOR_A4988_MS3 "A4988 MS3"
|
||||
#define D_SENSOR_DDS2382_TX "DDS238-2 Tx"
|
||||
#define D_SENSOR_DDS2382_RX "DDS238-2 Rx"
|
||||
#define D_SENSOR_DDSU666_TX "DDSU666 Tx"
|
||||
#define D_SENSOR_DDSU666_RX "DDSU666 Rx"
|
||||
|
||||
// Units
|
||||
#define D_UNIT_AMPERE "A"
|
||||
|
|
|
@ -617,6 +617,8 @@
|
|||
#define D_SENSOR_A4988_MS3 "A4988 MS3"
|
||||
#define D_SENSOR_DDS2382_TX "DDS238-2 Tx"
|
||||
#define D_SENSOR_DDS2382_RX "DDS238-2 Rx"
|
||||
#define D_SENSOR_DDSU666_TX "DDSU666 Tx"
|
||||
#define D_SENSOR_DDSU666_RX "DDSU666 Rx"
|
||||
|
||||
// Units
|
||||
#define D_UNIT_AMPERE "A"
|
||||
|
|
|
@ -617,6 +617,8 @@
|
|||
#define D_SENSOR_A4988_MS3 "A4988 MS3"
|
||||
#define D_SENSOR_DDS2382_TX "DDS238-2 Tx"
|
||||
#define D_SENSOR_DDS2382_RX "DDS238-2 Rx"
|
||||
#define D_SENSOR_DDSU666_TX "DDSU666 Tx"
|
||||
#define D_SENSOR_DDSU666_RX "DDSU666 Rx"
|
||||
|
||||
// Units
|
||||
#define D_UNIT_AMPERE "A"
|
||||
|
|
|
@ -617,6 +617,8 @@
|
|||
#define D_SENSOR_A4988_MS3 "A4988 MS3"
|
||||
#define D_SENSOR_DDS2382_TX "DDS238-2 Tx"
|
||||
#define D_SENSOR_DDS2382_RX "DDS238-2 Rx"
|
||||
#define D_SENSOR_DDSU666_TX "DDSU666 Tx"
|
||||
#define D_SENSOR_DDSU666_RX "DDSU666 Rx"
|
||||
|
||||
// Units
|
||||
#define D_UNIT_AMPERE "A"
|
||||
|
|
|
@ -617,6 +617,8 @@
|
|||
#define D_SENSOR_A4988_MS3 "A4988 MS3"
|
||||
#define D_SENSOR_DDS2382_TX "DDS238-2 Tx"
|
||||
#define D_SENSOR_DDS2382_RX "DDS238-2 Rx"
|
||||
#define D_SENSOR_DDSU666_TX "DDSU666 Tx"
|
||||
#define D_SENSOR_DDSU666_RX "DDSU666 Rx"
|
||||
|
||||
// Units
|
||||
#define D_UNIT_AMPERE "A"
|
||||
|
|
|
@ -617,6 +617,8 @@
|
|||
#define D_SENSOR_A4988_MS3 "A4988 MS3"
|
||||
#define D_SENSOR_DDS2382_TX "DDS238-2 Tx"
|
||||
#define D_SENSOR_DDS2382_RX "DDS238-2 Rx"
|
||||
#define D_SENSOR_DDSU666_TX "DDSU666 Tx"
|
||||
#define D_SENSOR_DDSU666_RX "DDSU666 Rx"
|
||||
|
||||
// Units
|
||||
#define D_UNIT_AMPERE "A"
|
||||
|
|
|
@ -617,6 +617,8 @@
|
|||
#define D_SENSOR_A4988_MS3 "A4988 MS3"
|
||||
#define D_SENSOR_DDS2382_TX "DDS238-2 Tx"
|
||||
#define D_SENSOR_DDS2382_RX "DDS238-2 Rx"
|
||||
#define D_SENSOR_DDSU666_TX "DDSU666 Tx"
|
||||
#define D_SENSOR_DDSU666_RX "DDSU666 Rx"
|
||||
|
||||
// Units
|
||||
#define D_UNIT_AMPERE "A"
|
||||
|
|
|
@ -617,6 +617,8 @@
|
|||
#define D_SENSOR_A4988_MS3 "A4988 MS3"
|
||||
#define D_SENSOR_DDS2382_TX "DDS238-2 Tx"
|
||||
#define D_SENSOR_DDS2382_RX "DDS238-2 Rx"
|
||||
#define D_SENSOR_DDSU666_TX "DDSU666 Tx"
|
||||
#define D_SENSOR_DDSU666_RX "DDSU666 Rx"
|
||||
|
||||
// Units
|
||||
#define D_UNIT_AMPERE "A"
|
||||
|
|
|
@ -617,6 +617,8 @@
|
|||
#define D_SENSOR_A4988_MS3 "A4988 MS3"
|
||||
#define D_SENSOR_DDS2382_TX "DDS238-2 Tx"
|
||||
#define D_SENSOR_DDS2382_RX "DDS238-2 Rx"
|
||||
#define D_SENSOR_DDSU666_TX "DDSU666 Tx"
|
||||
#define D_SENSOR_DDSU666_RX "DDSU666 Rx"
|
||||
|
||||
// Units
|
||||
#define D_UNIT_AMPERE "A"
|
||||
|
|
|
@ -617,6 +617,8 @@
|
|||
#define D_SENSOR_A4988_MS3 "A4988 MS3"
|
||||
#define D_SENSOR_DDS2382_TX "DDS238-2 Tx"
|
||||
#define D_SENSOR_DDS2382_RX "DDS238-2 Rx"
|
||||
#define D_SENSOR_DDSU666_TX "DDSU666 Tx"
|
||||
#define D_SENSOR_DDSU666_RX "DDSU666 Rx"
|
||||
|
||||
// Units
|
||||
#define D_UNIT_AMPERE "A"
|
||||
|
|
|
@ -617,6 +617,8 @@
|
|||
#define D_SENSOR_A4988_MS3 "A4988 MS3"
|
||||
#define D_SENSOR_DDS2382_TX "DDS238-2 Tx"
|
||||
#define D_SENSOR_DDS2382_RX "DDS238-2 Rx"
|
||||
#define D_SENSOR_DDSU666_TX "DDSU666 Tx"
|
||||
#define D_SENSOR_DDSU666_RX "DDSU666 Rx"
|
||||
|
||||
// Units
|
||||
#define D_UNIT_AMPERE "А"
|
||||
|
|
|
@ -617,6 +617,8 @@
|
|||
#define D_SENSOR_A4988_MS3 "A4988 MS3"
|
||||
#define D_SENSOR_DDS2382_TX "DDS238-2 Tx"
|
||||
#define D_SENSOR_DDS2382_RX "DDS238-2 Rx"
|
||||
#define D_SENSOR_DDSU666_TX "DDSU666 Tx"
|
||||
#define D_SENSOR_DDSU666_RX "DDSU666 Rx"
|
||||
|
||||
// Units
|
||||
#define D_UNIT_AMPERE "A"
|
||||
|
|
|
@ -617,6 +617,8 @@
|
|||
#define D_SENSOR_A4988_MS3 "A4988 MS3"
|
||||
#define D_SENSOR_DDS2382_TX "DDS238-2 Tx"
|
||||
#define D_SENSOR_DDS2382_RX "DDS238-2 Rx"
|
||||
#define D_SENSOR_DDSU666_TX "DDSU666 Tx"
|
||||
#define D_SENSOR_DDSU666_RX "DDSU666 Rx"
|
||||
|
||||
// Units
|
||||
#define D_UNIT_AMPERE "A"
|
||||
|
|
|
@ -617,6 +617,8 @@
|
|||
#define D_SENSOR_A4988_MS3 "A4988 MS3"
|
||||
#define D_SENSOR_DDS2382_TX "DDS238-2 Tx"
|
||||
#define D_SENSOR_DDS2382_RX "DDS238-2 Rx"
|
||||
#define D_SENSOR_DDSU666_TX "DDSU666 Tx"
|
||||
#define D_SENSOR_DDSU666_RX "DDSU666 Rx"
|
||||
|
||||
// Units
|
||||
#define D_UNIT_AMPERE "A"
|
||||
|
|
|
@ -617,6 +617,8 @@
|
|||
#define D_SENSOR_A4988_MS3 "A4988 MS3"
|
||||
#define D_SENSOR_DDS2382_TX "DDS238-2 Tx"
|
||||
#define D_SENSOR_DDS2382_RX "DDS238-2 Rx"
|
||||
#define D_SENSOR_DDSU666_TX "DDSU666 Tx"
|
||||
#define D_SENSOR_DDSU666_RX "DDSU666 Rx"
|
||||
|
||||
// Units
|
||||
#define D_UNIT_AMPERE "А"
|
||||
|
|
|
@ -617,6 +617,8 @@
|
|||
#define D_SENSOR_A4988_MS3 "A4988 MS3"
|
||||
#define D_SENSOR_DDS2382_TX "DDS238-2 Tx"
|
||||
#define D_SENSOR_DDS2382_RX "DDS238-2 Rx"
|
||||
#define D_SENSOR_DDSU666_TX "DDSU666 Tx"
|
||||
#define D_SENSOR_DDSU666_RX "DDSU666 Rx"
|
||||
|
||||
// Units
|
||||
#define D_UNIT_AMPERE "安"
|
||||
|
|
|
@ -617,6 +617,8 @@
|
|||
#define D_SENSOR_A4988_MS3 "A4988 MS3"
|
||||
#define D_SENSOR_DDS2382_TX "DDS238-2 Tx"
|
||||
#define D_SENSOR_DDS2382_RX "DDS238-2 Rx"
|
||||
#define D_SENSOR_DDSU666_TX "DDSU666 Tx"
|
||||
#define D_SENSOR_DDSU666_RX "DDSU666 Rx"
|
||||
|
||||
// Units
|
||||
#define D_UNIT_AMPERE "安"
|
||||
|
|
|
@ -447,6 +447,8 @@
|
|||
//#define USE_SOLAX_X1 // Add support for Solax X1 series Modbus log info (+4k1 code)
|
||||
#define SOLAXX1_SPEED 9600 // Solax X1 Modbus RS485 serial speed (default: 9600 baud)
|
||||
#define SOLAXX1_PV2 // Solax X1 using second PV
|
||||
//#define USE_DDSU666 // Add support for Chint DDSU666 Modbus energy monitor (+0k6 code)
|
||||
#define DDSU666_SPEED 9600 // Chint DDSU666 Modbus RS485 serial speed (default: 9600 baud)
|
||||
|
||||
// -- Low level interface devices -----------------
|
||||
#define USE_DHT // Add support for DHT11, AM2301 (DHT21, DHT22, AM2302, AM2321) and SI7021 Temperature and Humidity sensor (1k6 code)
|
||||
|
|
|
@ -165,6 +165,7 @@ char* ToHex_P(const unsigned char * in, size_t insz, char * out, size_t outsz, c
|
|||
#define USE_SDM120_2 // Add support for Eastron SDM120-Modbus energy monitor (+1k1 code)
|
||||
#define USE_SDM630_2 // Add support for Eastron SDM630-Modbus energy monitor (+0k6 code)
|
||||
#define USE_DDS2382 // Add support for Hiking DDS2382 Modbus energy monitor (+0k6 code)
|
||||
#define USE_DDSU666 // Add support for Chint DDSU666 Modbus energy monitor (+0k6 code)
|
||||
|
||||
#define USE_DHT // Add support for DHT11, AM2301 (DHT21, DHT22, AM2302, AM2321) and SI7021 Temperature and Humidity sensor
|
||||
#define USE_MAX31855 // Add support for MAX31855 K-Type thermocouple sensor using softSPI
|
||||
|
@ -251,6 +252,7 @@ char* ToHex_P(const unsigned char * in, size_t insz, char * out, size_t outsz, c
|
|||
#undef USE_SDM120_2 // Disable support for Eastron SDM120-Modbus energy meter
|
||||
#undef USE_SDM630_2 // Disable support for Eastron SDM630-Modbus energy monitor (+0k6 code)
|
||||
#undef USE_DDS2382 // Disable support for Hiking DDS2382 Modbus energy monitor (+0k6 code)
|
||||
#undef USE_DDSU666 // Disable support for Chint DDSU666 Modbus energy monitor (+0k6 code)
|
||||
|
||||
#define USE_DHT // Add 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
|
||||
|
@ -305,6 +307,7 @@ char* ToHex_P(const unsigned char * in, size_t insz, char * out, size_t outsz, c
|
|||
#undef USE_SDM120_2 // Disable support for Eastron SDM120-Modbus energy meter
|
||||
#undef USE_SDM630_2 // Disable support for Eastron SDM630-Modbus energy monitor (+0k6 code)
|
||||
#undef USE_DDS2382 // Disable support for Hiking DDS2382 Modbus energy monitor (+0k6 code)
|
||||
#undef USE_DDSU666 // Disable support for Chint DDSU666 Modbus energy monitor (+0k6 code)
|
||||
#undef USE_EMULATION // Disable Belkin WeMo and Hue Bridge emulation for Alexa (-16k code, -2k mem)
|
||||
#undef USE_DOMOTICZ // Disable Domoticz
|
||||
#undef USE_HOME_ASSISTANT // Disable Home Assistant
|
||||
|
@ -388,6 +391,7 @@ char* ToHex_P(const unsigned char * in, size_t insz, char * out, size_t outsz, c
|
|||
#undef USE_SDM120_2 // Disable support for Eastron SDM120-Modbus energy meter
|
||||
#undef USE_SDM630_2 // Disable support for Eastron SDM630-Modbus energy monitor (+0k6 code)
|
||||
#undef USE_DDS2382 // Disable support for Hiking DDS2382 Modbus energy monitor (+0k6 code)
|
||||
#undef USE_DDSU666 // Disable support for Chint DDSU666 Modbus energy monitor (+0k6 code)
|
||||
|
||||
//#define USE_DHT // Add 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
|
||||
|
@ -484,6 +488,7 @@ char* ToHex_P(const unsigned char * in, size_t insz, char * out, size_t outsz, c
|
|||
#undef USE_SDM120_2 // Disable support for Eastron SDM120-Modbus energy meter
|
||||
#undef USE_SDM630_2 // Disable support for Eastron SDM630-Modbus energy monitor (+0k6 code)
|
||||
#undef USE_DDS2382 // Disable support for Hiking DDS2382 Modbus energy monitor (+0k6 code)
|
||||
#undef USE_DDSU666 // Disable support for Chint DDSU666 Modbus energy monitor (+0k6 code)
|
||||
|
||||
#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
|
||||
|
@ -568,6 +573,7 @@ char* ToHex_P(const unsigned char * in, size_t insz, char * out, size_t outsz, c
|
|||
#undef USE_SDM120_2 // Disable support for Eastron SDM120-Modbus energy meter
|
||||
#undef USE_SDM630_2 // Disable support for Eastron SDM630-Modbus energy monitor (+0k6 code)
|
||||
#undef USE_DDS2382 // Disable support for Hiking DDS2382 Modbus energy monitor (+0k6 code)
|
||||
#undef USE_DDSU666 // Disable support for Chint DDSU666 Modbus energy monitor (+0k6 code)
|
||||
|
||||
#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
|
||||
|
|
|
@ -202,6 +202,8 @@ enum UserSelectablePins {
|
|||
GPIO_A4988_MS3, // A4988 microstep pin3
|
||||
GPIO_DDS2382_TX, // DDS2382 Serial interface
|
||||
GPIO_DDS2382_RX, // DDS2382 Serial interface
|
||||
GPIO_DDSU666_TX, // DDSU666 Serial interface
|
||||
GPIO_DDSU666_RX, // DDSU666 Serial interface
|
||||
GPIO_SENSOR_END };
|
||||
|
||||
// Programmer selectable GPIO functionality
|
||||
|
@ -277,6 +279,7 @@ const char kSensorNames[] PROGMEM =
|
|||
D_SENSOR_IBEACON_TX "|" D_SENSOR_IBEACON_RX "|"
|
||||
D_SENSOR_A4988_DIR "|" D_SENSOR_A4988_STP "|" D_SENSOR_A4988_ENA "|" D_SENSOR_A4988_MS1 "|" D_SENSOR_A4988_MS2 "|" D_SENSOR_A4988_MS3 "|"
|
||||
D_SENSOR_DDS2382_TX "|" D_SENSOR_DDS2382_RX "|"
|
||||
D_SENSOR_DDSU666_TX "|" D_SENSOR_DDSU666_RX "|"
|
||||
;
|
||||
|
||||
// User selectable ADC0 functionality
|
||||
|
@ -645,6 +648,10 @@ const uint8_t kGpioNiceList[] PROGMEM = {
|
|||
GPIO_SOLAXX1_TX, // Solax Inverter tx pin
|
||||
GPIO_SOLAXX1_RX, // Solax Inverter rx pin
|
||||
#endif
|
||||
#ifdef USE_DDSU666
|
||||
GPIO_DDSU666_TX, // DDSU666 Serial interface
|
||||
GPIO_DDSU666_RX, // DDSU666 Serial interface
|
||||
#endif // USE_DDSU666
|
||||
|
||||
#ifdef USE_SERIAL_BRIDGE
|
||||
GPIO_SBR_TX, // Serial Bridge Serial interface
|
||||
|
|
|
@ -459,7 +459,9 @@ void GetFeatures(void)
|
|||
#ifdef USE_PCF8574
|
||||
feature5 |= 0x00000200; // Xdrv_028_pcf8574.ino
|
||||
#endif
|
||||
// feature5 |= 0x00000400;
|
||||
#ifdef USE_DDSU666
|
||||
feature5 |= 0x00000400; // Xnrg_11_ddsu666.ino
|
||||
#endif
|
||||
// feature5 |= 0x00000800;
|
||||
|
||||
// feature5 |= 0x00001000;
|
||||
|
|
|
@ -0,0 +1,175 @@
|
|||
/*
|
||||
xnrg_11_ddsu666.ino - Chint DDSU666-Modbus energy meter support for Sonoff-Tasmota
|
||||
|
||||
Copyright (C) 2019 Pablo Zerón and Theo Arends
|
||||
|
||||
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 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.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifdef USE_ENERGY_SENSOR
|
||||
#ifdef USE_DDSU666
|
||||
/*********************************************************************************************\
|
||||
* Chint DDSU666 Modbus energy meter
|
||||
\*********************************************************************************************/
|
||||
|
||||
#define XNRG_11 11
|
||||
|
||||
// can be user defined in my_user_config.h
|
||||
#ifndef DDSU666_SPEED
|
||||
#define DDSU666_SPEED 9600 // default DDSU66 Modbus address
|
||||
#endif
|
||||
// can be user defined in my_user_config.h
|
||||
#ifndef DDSU666_ADDR
|
||||
#define DDSU666_ADDR 1 // default DDSU66 Modbus address
|
||||
#endif
|
||||
|
||||
#include <TasmotaModbus.h>
|
||||
TasmotaModbus *Ddsu666Modbus;
|
||||
|
||||
const uint16_t Ddsu666_start_addresses[] {
|
||||
0x2000, // DDSU666_VOLTAGE [V]
|
||||
0x2002, // DDSU666_CURRENT [A]
|
||||
0x2004, // DDSU666_POWER [KW]
|
||||
0x2006, // DDSU666_REACTIVE_POWER [KVAR]
|
||||
0x200A, // DDSU666_POWER_FACTOR
|
||||
0x200E, // DDSU666_FREQUENCY [Hz]
|
||||
0X4000, // DDSU666_IMPORT_ACTIVE [kWh]
|
||||
0X400A, // DDSU666_EXPORT_ACTIVE [kWh]
|
||||
};
|
||||
|
||||
struct DDSU666 {
|
||||
float import_active = NAN;
|
||||
uint8_t read_state = 0;
|
||||
uint8_t send_retry = 0;
|
||||
} Ddsu666;
|
||||
|
||||
/*********************************************************************************************/
|
||||
|
||||
void DDSU666Every250ms(void)
|
||||
{
|
||||
bool data_ready = Ddsu666Modbus->ReceiveReady();
|
||||
|
||||
if (data_ready) {
|
||||
uint8_t buffer[14]; // At least 5 + (2 * 2) = 9
|
||||
|
||||
uint32_t error = Ddsu666Modbus->ReceiveBuffer(buffer, 2);
|
||||
AddLogBuffer(LOG_LEVEL_DEBUG_MORE, buffer, Ddsu666Modbus->ReceiveCount());
|
||||
|
||||
if (error) {
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR("SDM: Ddsu666 error %d"), error);
|
||||
} else {
|
||||
Energy.data_valid[0] = 0;
|
||||
|
||||
// 0 1 2 3 4 5 6 7 8
|
||||
// SA FC BC Fh Fl Sh Sl Cl Ch
|
||||
// 01 04 04 43 66 33 34 1B 38 = 230.2 Volt
|
||||
float value;
|
||||
((uint8_t*)&value)[3] = buffer[3]; // Get float values
|
||||
((uint8_t*)&value)[2] = buffer[4];
|
||||
((uint8_t*)&value)[1] = buffer[5];
|
||||
((uint8_t*)&value)[0] = buffer[6];
|
||||
|
||||
switch(Ddsu666.read_state) {
|
||||
case 0:
|
||||
Energy.voltage[0] = value; // 230.2 V
|
||||
break;
|
||||
|
||||
case 1:
|
||||
Energy.current[0] = value; // 1.260 A
|
||||
break;
|
||||
|
||||
case 2:
|
||||
Energy.active_power[0] = value * 1000; // -196.3 W
|
||||
break;
|
||||
|
||||
case 3:
|
||||
Energy.reactive_power[0] = value * 1000; // 92.2
|
||||
break;
|
||||
|
||||
case 4:
|
||||
Energy.power_factor[0] = value; // 0.91
|
||||
break;
|
||||
|
||||
case 5:
|
||||
Energy.frequency[0] = value; // 50.0 Hz
|
||||
break;
|
||||
|
||||
case 6:
|
||||
Ddsu666.import_active = value; // 478.492 kWh
|
||||
break;
|
||||
|
||||
case 7:
|
||||
Energy.export_active = value; // 6.216 kWh
|
||||
break;
|
||||
}
|
||||
|
||||
Ddsu666.read_state++;
|
||||
|
||||
if (Ddsu666.read_state == 8) {
|
||||
Ddsu666.read_state = 0;
|
||||
EnergyUpdateTotal(Ddsu666.import_active, true); // 484.708 kWh
|
||||
}
|
||||
}
|
||||
} // end data ready
|
||||
|
||||
if (0 == Ddsu666.send_retry || data_ready) {
|
||||
Ddsu666.send_retry = 5;
|
||||
Ddsu666Modbus->Send(DDSU666_ADDR, 0x04, Ddsu666_start_addresses[Ddsu666.read_state], 2);
|
||||
} else {
|
||||
Ddsu666.send_retry--;
|
||||
}
|
||||
}
|
||||
|
||||
void Ddsu666SnsInit(void)
|
||||
{
|
||||
Ddsu666Modbus = new TasmotaModbus(pin[GPIO_DDSU666_RX], pin[GPIO_DDSU666_TX]);
|
||||
uint8_t result = Ddsu666Modbus->Begin(DDSU666_SPEED);
|
||||
if (result) {
|
||||
if (2 == result) { ClaimSerial(); }
|
||||
} else {
|
||||
energy_flg = ENERGY_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
void Ddsu666DrvInit(void)
|
||||
{
|
||||
if ((pin[GPIO_DDSU666_RX] < 99) && (pin[GPIO_DDSU666_TX] < 99)) {
|
||||
energy_flg = XNRG_11;
|
||||
}
|
||||
}
|
||||
|
||||
/*********************************************************************************************\
|
||||
* Interface
|
||||
\*********************************************************************************************/
|
||||
|
||||
bool Xnrg11(uint8_t function)
|
||||
{
|
||||
bool result = false;
|
||||
|
||||
switch (function) {
|
||||
case FUNC_EVERY_250_MSECOND:
|
||||
if (uptime > 4) { DDSU666Every250ms(); }
|
||||
break;
|
||||
case FUNC_INIT:
|
||||
Ddsu666SnsInit();
|
||||
break;
|
||||
case FUNC_PRE_INIT:
|
||||
Ddsu666DrvInit();
|
||||
break;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
#endif // USE_DDSU666
|
||||
#endif // USE_ENERGY_SENSOR
|
|
@ -171,7 +171,7 @@ a_features = [[
|
|||
],[
|
||||
"USE_BUZZER","USE_RDM6300","USE_IBEACON","USE_SML_M",
|
||||
"USE_INA226","USE_A4988_Stepper","USE_DDS2382","USE_SM2135",
|
||||
"USE_SHUTTER","USE_PCF8574","","",
|
||||
"USE_SHUTTER","USE_PCF8574","USE_DDSU666","",
|
||||
"","","","",
|
||||
"","","","",
|
||||
"","","","",
|
||||
|
|
Loading…
Reference in New Issue