mirror of https://github.com/arendst/Tasmota.git
Add Analog Voltage and Current
This commit is contained in:
parent
9f99633f43
commit
d7c6474104
|
@ -222,6 +222,7 @@ enum UserSelectablePins {
|
|||
GPIO_TCP_TX_EN, // TCP to serial bridge, EN pin
|
||||
GPIO_ASR650X_TX, GPIO_ASR650X_RX, // ASR650X LoRaWan node Serial interface
|
||||
GPIO_WOOLIIS_RX, // Wooliis Battery capacity monitor Serial RX
|
||||
GPIO_ADC_VOLTAGE, GPIO_ADC_CURRENT, // Analog Voltage and Current
|
||||
GPIO_SENSOR_END };
|
||||
|
||||
// Error as warning to rethink GPIO usage with max 2045
|
||||
|
@ -491,6 +492,7 @@ const char kSensorNames[] PROGMEM =
|
|||
D_SENSOR_TCP_TXD_EN "|"
|
||||
D_GPIO_ASR650X_TX "|" D_GPIO_ASR650X_RX "|"
|
||||
D_SENSOR_WOOLIIS_RX "|"
|
||||
D_SENSOR_ADC_VOLTAGE "|" D_SENSOR_ADC_CURRENT "|"
|
||||
;
|
||||
|
||||
const char kSensorNamesFixed[] PROGMEM =
|
||||
|
@ -1224,6 +1226,11 @@ const uint16_t kGpioNiceList[] PROGMEM = {
|
|||
AGPIO(GPIO_ETH_PHY_MDC),
|
||||
AGPIO(GPIO_ETH_PHY_MDIO), // Ethernet
|
||||
#endif // USE_ETHERNET
|
||||
#ifdef USE_BIOPDU
|
||||
AGPIO(GPIO_BIOPDU_PZEM0XX_TX), // Biomine BioPDU pins
|
||||
AGPIO(GPIO_BIOPDU_PZEM016_RX),
|
||||
AGPIO(GPIO_BIOPDU_BIT) + 3,
|
||||
#endif
|
||||
|
||||
/*-------------------------------------------------------------------------------------------*\
|
||||
* ESP32 multiple Analog / Digital converter inputs
|
||||
|
@ -1239,12 +1246,8 @@ const uint16_t kGpioNiceList[] PROGMEM = {
|
|||
AGPIO(GPIO_ADC_JOY) + MAX_ADCS, // Joystick
|
||||
AGPIO(GPIO_ADC_PH) + MAX_ADCS, // Analog PH Sensor
|
||||
AGPIO(GPIO_ADC_MQ) + MAX_ADCS, // Analog MQ Sensor
|
||||
|
||||
#ifdef USE_BIOPDU
|
||||
AGPIO(GPIO_BIOPDU_PZEM0XX_TX), // Biomine BioPDU pins
|
||||
AGPIO(GPIO_BIOPDU_PZEM016_RX),
|
||||
AGPIO(GPIO_BIOPDU_BIT) + 3,
|
||||
#endif
|
||||
AGPIO(GPIO_ADC_VOLTAGE) + MAX_ADCS, // Voltage
|
||||
AGPIO(GPIO_ADC_CURRENT) + MAX_ADCS, // Current
|
||||
#endif // ESP32
|
||||
};
|
||||
|
||||
|
@ -1265,22 +1268,26 @@ const uint16_t kAdcNiceList[] PROGMEM = {
|
|||
AGPIO(GPIO_ADC_JOY), // Joystick
|
||||
AGPIO(GPIO_ADC_PH), // Analog PH Sensor
|
||||
AGPIO(GPIO_ADC_MQ), // Analog MQ Sensor
|
||||
AGPIO(GPIO_ADC_VOLTAGE), // Voltage
|
||||
AGPIO(GPIO_ADC_CURRENT), // Current
|
||||
};
|
||||
#endif // ESP8266
|
||||
|
||||
// User selectable ADC functionality
|
||||
enum UserSelectableAdc {
|
||||
ADC_NONE, // Not used
|
||||
ADC_INPUT, // Analog input
|
||||
ADC_TEMP, // Thermistor
|
||||
ADC_LIGHT, // Light sensor
|
||||
ADC_BUTTON, // Button
|
||||
ADC_BUTTON_INV,
|
||||
ADC_RANGE, // Range
|
||||
ADC_CT_POWER, // Current
|
||||
ADC_JOY, // Joystick
|
||||
ADC_PH, // Analog PH Sensor
|
||||
ADC_MQ, // Analog MQ Sensor
|
||||
ADC_NONE, // 0 = Not used
|
||||
ADC_INPUT, // 1 = Analog input
|
||||
ADC_TEMP, // 2 = Thermistor
|
||||
ADC_LIGHT, // 3 =Light sensor
|
||||
ADC_BUTTON, // 4 =Button
|
||||
ADC_BUTTON_INV, // 5 = Inverted button
|
||||
ADC_RANGE, // 6 = Range
|
||||
ADC_CT_POWER, // 7 = Current
|
||||
ADC_JOY, // 8 = Joystick
|
||||
ADC_PH, // 9 = Analog PH Sensor
|
||||
ADC_MQ, // 10 = Analog MQ Sensor
|
||||
ADC_VOLTAGE, // 11 = Voltage
|
||||
ADC_CURRENT, // 12 = Current
|
||||
// ADC_SWITCH, // Switch
|
||||
// ADC_SWITCH_INV,
|
||||
ADC_END };
|
||||
|
|
|
@ -913,6 +913,8 @@
|
|||
#define D_SENSOR_ADC_JOYSTICK "ADC Joystick"
|
||||
#define D_SENSOR_ADC_PH "ADC pH"
|
||||
#define D_SENSOR_ADC_MQ "ADC MQ"
|
||||
#define D_SENSOR_ADC_VOLTAGE "ADC Voltage"
|
||||
#define D_SENSOR_ADC_CURRENT "ADC Current"
|
||||
#define D_GPIO_WEBCAM_PWDN "CAM_PWDN"
|
||||
#define D_GPIO_WEBCAM_RESET "CAM_RESET"
|
||||
#define D_GPIO_WEBCAM_XCLK "CAM_XCLK"
|
||||
|
|
|
@ -913,6 +913,8 @@
|
|||
#define D_SENSOR_ADC_JOYSTICK "ADC Joystick"
|
||||
#define D_SENSOR_ADC_PH "ADC pH"
|
||||
#define D_SENSOR_ADC_MQ "ADC MQ"
|
||||
#define D_SENSOR_ADC_VOLTAGE "ADC Voltage"
|
||||
#define D_SENSOR_ADC_CURRENT "ADC Current"
|
||||
#define D_GPIO_WEBCAM_PWDN "CAM_PWDN"
|
||||
#define D_GPIO_WEBCAM_RESET "CAM_RESET"
|
||||
#define D_GPIO_WEBCAM_XCLK "CAM_XCLK"
|
||||
|
|
|
@ -913,6 +913,8 @@
|
|||
#define D_SENSOR_ADC_JOYSTICK "ADC Joystick"
|
||||
#define D_SENSOR_ADC_PH "ADC pH"
|
||||
#define D_SENSOR_ADC_MQ "ADC MQ"
|
||||
#define D_SENSOR_ADC_VOLTAGE "ADC Voltage"
|
||||
#define D_SENSOR_ADC_CURRENT "ADC Current"
|
||||
#define D_GPIO_WEBCAM_PWDN "CAM_PWDN"
|
||||
#define D_GPIO_WEBCAM_RESET "CAM_RESET"
|
||||
#define D_GPIO_WEBCAM_XCLK "CAM_XCLK"
|
||||
|
|
|
@ -913,6 +913,8 @@
|
|||
#define D_SENSOR_ADC_JOYSTICK "ADC Joystick"
|
||||
#define D_SENSOR_ADC_PH "ADC pH"
|
||||
#define D_SENSOR_ADC_MQ "ADC MQ"
|
||||
#define D_SENSOR_ADC_VOLTAGE "ADC Voltage"
|
||||
#define D_SENSOR_ADC_CURRENT "ADC Current"
|
||||
#define D_GPIO_WEBCAM_PWDN "CAM_PWDN"
|
||||
#define D_GPIO_WEBCAM_RESET "CAM_RESET"
|
||||
#define D_GPIO_WEBCAM_XCLK "CAM_XCLK"
|
||||
|
|
|
@ -913,6 +913,8 @@
|
|||
#define D_SENSOR_ADC_JOYSTICK "ADC Joystick"
|
||||
#define D_SENSOR_ADC_PH "ADC pH"
|
||||
#define D_SENSOR_ADC_MQ "ADC MQ"
|
||||
#define D_SENSOR_ADC_VOLTAGE "ADC Voltage"
|
||||
#define D_SENSOR_ADC_CURRENT "ADC Current"
|
||||
#define D_GPIO_WEBCAM_PWDN "CAM_PWDN"
|
||||
#define D_GPIO_WEBCAM_RESET "CAM_RESET"
|
||||
#define D_GPIO_WEBCAM_XCLK "CAM_XCLK"
|
||||
|
|
|
@ -913,6 +913,8 @@
|
|||
#define D_SENSOR_ADC_JOYSTICK "ADC Joystick"
|
||||
#define D_SENSOR_ADC_PH "ADC pH"
|
||||
#define D_SENSOR_ADC_MQ "ADC MQ"
|
||||
#define D_SENSOR_ADC_VOLTAGE "ADC Voltage"
|
||||
#define D_SENSOR_ADC_CURRENT "ADC Current"
|
||||
#define D_GPIO_WEBCAM_PWDN "CAM_PWDN"
|
||||
#define D_GPIO_WEBCAM_RESET "CAM_RESET"
|
||||
#define D_GPIO_WEBCAM_XCLK "CAM_XCLK"
|
||||
|
|
|
@ -913,6 +913,8 @@
|
|||
#define D_SENSOR_ADC_JOYSTICK "ADC Joystick"
|
||||
#define D_SENSOR_ADC_PH "ADC pH"
|
||||
#define D_SENSOR_ADC_MQ "ADC MQ"
|
||||
#define D_SENSOR_ADC_VOLTAGE "ADC Voltage"
|
||||
#define D_SENSOR_ADC_CURRENT "ADC Current"
|
||||
#define D_GPIO_WEBCAM_PWDN "CAM_PWDN"
|
||||
#define D_GPIO_WEBCAM_RESET "CAM_RESET"
|
||||
#define D_GPIO_WEBCAM_XCLK "CAM_XCLK"
|
||||
|
|
|
@ -913,6 +913,8 @@
|
|||
#define D_SENSOR_ADC_JOYSTICK "ADC Joystick"
|
||||
#define D_SENSOR_ADC_PH "ADC pH"
|
||||
#define D_SENSOR_ADC_MQ "ADC MQ"
|
||||
#define D_SENSOR_ADC_VOLTAGE "ADC Voltage"
|
||||
#define D_SENSOR_ADC_CURRENT "ADC Current"
|
||||
#define D_GPIO_WEBCAM_PWDN "CAM_PWDN"
|
||||
#define D_GPIO_WEBCAM_RESET "CAM_RESET"
|
||||
#define D_GPIO_WEBCAM_XCLK "CAM_XCLK"
|
||||
|
|
|
@ -913,6 +913,8 @@
|
|||
#define D_SENSOR_ADC_JOYSTICK "ADC Manette"
|
||||
#define D_SENSOR_ADC_PH "ADC pH"
|
||||
#define D_SENSOR_ADC_MQ "ADC MQ"
|
||||
#define D_SENSOR_ADC_VOLTAGE "ADC Voltage"
|
||||
#define D_SENSOR_ADC_CURRENT "ADC Current"
|
||||
#define D_GPIO_WEBCAM_PWDN "CAM_PwDn"
|
||||
#define D_GPIO_WEBCAM_RESET "CAM_Reset"
|
||||
#define D_GPIO_WEBCAM_XCLK "CAM_XClk"
|
||||
|
|
|
@ -913,6 +913,8 @@
|
|||
#define D_SENSOR_ADC_JOYSTICK "ADC Joystick"
|
||||
#define D_SENSOR_ADC_PH "ADC pH"
|
||||
#define D_SENSOR_ADC_MQ "ADC MQ"
|
||||
#define D_SENSOR_ADC_VOLTAGE "ADC Voltage"
|
||||
#define D_SENSOR_ADC_CURRENT "ADC Current"
|
||||
#define D_GPIO_WEBCAM_PWDN "CAM_PWDN"
|
||||
#define D_GPIO_WEBCAM_RESET "CAM_RESET"
|
||||
#define D_GPIO_WEBCAM_XCLK "CAM_XCLK"
|
||||
|
|
|
@ -913,6 +913,8 @@
|
|||
#define D_SENSOR_ADC_JOYSTICK "ADC Joystick"
|
||||
#define D_SENSOR_ADC_PH "ADC pH"
|
||||
#define D_SENSOR_ADC_MQ "ADC MQ"
|
||||
#define D_SENSOR_ADC_VOLTAGE "ADC Voltage"
|
||||
#define D_SENSOR_ADC_CURRENT "ADC Current"
|
||||
#define D_GPIO_WEBCAM_PWDN "CAM_PWDN"
|
||||
#define D_GPIO_WEBCAM_RESET "CAM_RESET"
|
||||
#define D_GPIO_WEBCAM_XCLK "CAM_XCLK"
|
||||
|
|
|
@ -913,6 +913,8 @@
|
|||
#define D_SENSOR_ADC_JOYSTICK "ADC Joystick"
|
||||
#define D_SENSOR_ADC_PH "ADC pH"
|
||||
#define D_SENSOR_ADC_MQ "ADC MQ"
|
||||
#define D_SENSOR_ADC_VOLTAGE "ADC Voltage"
|
||||
#define D_SENSOR_ADC_CURRENT "ADC Current"
|
||||
#define D_GPIO_WEBCAM_PWDN "CAM_PWDN"
|
||||
#define D_GPIO_WEBCAM_RESET "CAM_RESET"
|
||||
#define D_GPIO_WEBCAM_XCLK "CAM_XCLK"
|
||||
|
|
|
@ -913,6 +913,8 @@
|
|||
#define D_SENSOR_ADC_JOYSTICK "ADC - Joystick"
|
||||
#define D_SENSOR_ADC_PH "ADC - pH"
|
||||
#define D_SENSOR_ADC_MQ "ADC - MQ"
|
||||
#define D_SENSOR_ADC_VOLTAGE "ADC Voltage"
|
||||
#define D_SENSOR_ADC_CURRENT "ADC Current"
|
||||
#define D_GPIO_WEBCAM_PWDN "Webcam - PWDN"
|
||||
#define D_GPIO_WEBCAM_RESET "Webcam - RESET"
|
||||
#define D_GPIO_WEBCAM_XCLK "Webcam - XCLK"
|
||||
|
|
|
@ -913,6 +913,8 @@
|
|||
#define D_SENSOR_ADC_JOYSTICK "ADC Joystick"
|
||||
#define D_SENSOR_ADC_PH "ADC pH"
|
||||
#define D_SENSOR_ADC_MQ "ADC MQ"
|
||||
#define D_SENSOR_ADC_VOLTAGE "ADC Voltage"
|
||||
#define D_SENSOR_ADC_CURRENT "ADC Current"
|
||||
#define D_GPIO_WEBCAM_PWDN "CAM_PWDN"
|
||||
#define D_GPIO_WEBCAM_RESET "CAM_RESET"
|
||||
#define D_GPIO_WEBCAM_XCLK "CAM_XCLK"
|
||||
|
|
|
@ -913,6 +913,8 @@
|
|||
#define D_SENSOR_ADC_JOYSTICK "ADC Joystick"
|
||||
#define D_SENSOR_ADC_PH "ADC pH"
|
||||
#define D_SENSOR_ADC_MQ "ADC MQ"
|
||||
#define D_SENSOR_ADC_VOLTAGE "ADC Voltage"
|
||||
#define D_SENSOR_ADC_CURRENT "ADC Current"
|
||||
#define D_GPIO_WEBCAM_PWDN "CAM_PWDN"
|
||||
#define D_GPIO_WEBCAM_RESET "CAM_RESET"
|
||||
#define D_GPIO_WEBCAM_XCLK "CAM_XCLK"
|
||||
|
|
|
@ -913,6 +913,8 @@
|
|||
#define D_SENSOR_ADC_JOYSTICK "ADC Dżojstik"
|
||||
#define D_SENSOR_ADC_PH "ADC pH"
|
||||
#define D_SENSOR_ADC_MQ "ADC MQ"
|
||||
#define D_SENSOR_ADC_VOLTAGE "ADC Voltage"
|
||||
#define D_SENSOR_ADC_CURRENT "ADC Current"
|
||||
#define D_GPIO_WEBCAM_PWDN "CAM_PWDN"
|
||||
#define D_GPIO_WEBCAM_RESET "CAM_RESET"
|
||||
#define D_GPIO_WEBCAM_XCLK "CAM_XCLK"
|
||||
|
|
|
@ -913,6 +913,8 @@
|
|||
#define D_SENSOR_ADC_JOYSTICK "Joystick ADC"
|
||||
#define D_SENSOR_ADC_PH "pH ADC"
|
||||
#define D_SENSOR_ADC_MQ "ADC MQ"
|
||||
#define D_SENSOR_ADC_VOLTAGE "ADC Voltage"
|
||||
#define D_SENSOR_ADC_CURRENT "ADC Current"
|
||||
#define D_GPIO_WEBCAM_PWDN "CAM_PWDN"
|
||||
#define D_GPIO_WEBCAM_RESET "CAM_RESET"
|
||||
#define D_GPIO_WEBCAM_XCLK "CAM_XCLK"
|
||||
|
|
|
@ -913,6 +913,8 @@
|
|||
#define D_SENSOR_ADC_JOYSTICK "Joystick ADC"
|
||||
#define D_SENSOR_ADC_PH "pH ADC"
|
||||
#define D_SENSOR_ADC_MQ "MQ ADC"
|
||||
#define D_SENSOR_ADC_VOLTAGE "ADC Voltage"
|
||||
#define D_SENSOR_ADC_CURRENT "ADC Current"
|
||||
#define D_GPIO_WEBCAM_PWDN "CAM_PWDN"
|
||||
#define D_GPIO_WEBCAM_RESET "CAM_RESET"
|
||||
#define D_GPIO_WEBCAM_XCLK "CAM_XCLK"
|
||||
|
|
|
@ -913,6 +913,8 @@
|
|||
#define D_SENSOR_ADC_JOYSTICK "ADC Joystick"
|
||||
#define D_SENSOR_ADC_PH "ADC pH"
|
||||
#define D_SENSOR_ADC_MQ "ADC MQ"
|
||||
#define D_SENSOR_ADC_VOLTAGE "ADC Voltage"
|
||||
#define D_SENSOR_ADC_CURRENT "ADC Current"
|
||||
#define D_GPIO_WEBCAM_PWDN "CAM_PWDN"
|
||||
#define D_GPIO_WEBCAM_RESET "CAM_RESET"
|
||||
#define D_GPIO_WEBCAM_XCLK "CAM_XCLK"
|
||||
|
|
|
@ -914,6 +914,8 @@
|
|||
#define D_SENSOR_ADC_JOYSTICK "ADC Joystick"
|
||||
#define D_SENSOR_ADC_PH "ADC pH"
|
||||
#define D_SENSOR_ADC_MQ "ADC MQ"
|
||||
#define D_SENSOR_ADC_VOLTAGE "ADC Voltage"
|
||||
#define D_SENSOR_ADC_CURRENT "ADC Current"
|
||||
#define D_GPIO_WEBCAM_PWDN "CAM_PWDN"
|
||||
#define D_GPIO_WEBCAM_RESET "CAM_RESET"
|
||||
#define D_GPIO_WEBCAM_XCLK "CAM_XCLK"
|
||||
|
|
|
@ -913,6 +913,8 @@
|
|||
#define D_SENSOR_ADC_JOYSTICK "ADC Joystick"
|
||||
#define D_SENSOR_ADC_PH "ADC pH"
|
||||
#define D_SENSOR_ADC_MQ "ADC MQ"
|
||||
#define D_SENSOR_ADC_VOLTAGE "ADC Voltage"
|
||||
#define D_SENSOR_ADC_CURRENT "ADC Current"
|
||||
#define D_GPIO_WEBCAM_PWDN "CAM_PWDN"
|
||||
#define D_GPIO_WEBCAM_RESET "CAM_RESET"
|
||||
#define D_GPIO_WEBCAM_XCLK "CAM_XCLK"
|
||||
|
|
|
@ -913,6 +913,8 @@
|
|||
#define D_SENSOR_ADC_JOYSTICK "ADC Joystick"
|
||||
#define D_SENSOR_ADC_PH "ADC pH"
|
||||
#define D_SENSOR_ADC_MQ "ADC MQ"
|
||||
#define D_SENSOR_ADC_VOLTAGE "ADC Voltage"
|
||||
#define D_SENSOR_ADC_CURRENT "ADC Current"
|
||||
#define D_GPIO_WEBCAM_PWDN "CAM_PWDN"
|
||||
#define D_GPIO_WEBCAM_RESET "CAM_RESET"
|
||||
#define D_GPIO_WEBCAM_XCLK "CAM_XCLK"
|
||||
|
|
|
@ -913,6 +913,8 @@
|
|||
#define D_SENSOR_ADC_JOYSTICK "ADC Joystick"
|
||||
#define D_SENSOR_ADC_PH "ADC pH"
|
||||
#define D_SENSOR_ADC_MQ "ADC MQ"
|
||||
#define D_SENSOR_ADC_VOLTAGE "ADC Voltage"
|
||||
#define D_SENSOR_ADC_CURRENT "ADC Current"
|
||||
#define D_GPIO_WEBCAM_PWDN "CAM_PWDN"
|
||||
#define D_GPIO_WEBCAM_RESET "CAM_RESET"
|
||||
#define D_GPIO_WEBCAM_XCLK "CAM_XCLK"
|
||||
|
|
|
@ -913,6 +913,8 @@
|
|||
#define D_SENSOR_ADC_JOYSTICK "ADC Joystick"
|
||||
#define D_SENSOR_ADC_PH "ADC pH"
|
||||
#define D_SENSOR_ADC_MQ "ADC MQ"
|
||||
#define D_SENSOR_ADC_VOLTAGE "ADC Voltage"
|
||||
#define D_SENSOR_ADC_CURRENT "ADC Current"
|
||||
#define D_GPIO_WEBCAM_PWDN "CAM_PWDN"
|
||||
#define D_GPIO_WEBCAM_RESET "CAM_RESET"
|
||||
#define D_GPIO_WEBCAM_XCLK "CAM_XCLK"
|
||||
|
|
|
@ -913,6 +913,8 @@
|
|||
#define D_SENSOR_ADC_JOYSTICK "ADC Joystick"
|
||||
#define D_SENSOR_ADC_PH "ADC pH"
|
||||
#define D_SENSOR_ADC_MQ "ADC MQ"
|
||||
#define D_SENSOR_ADC_VOLTAGE "ADC Voltage"
|
||||
#define D_SENSOR_ADC_CURRENT "ADC Current"
|
||||
#define D_GPIO_WEBCAM_PWDN "CAM_PWDN"
|
||||
#define D_GPIO_WEBCAM_RESET "CAM_RESET"
|
||||
#define D_GPIO_WEBCAM_XCLK "CAM_XCLK"
|
||||
|
|
|
@ -913,6 +913,8 @@
|
|||
#define D_SENSOR_ADC_JOYSTICK "ADC Joystick"
|
||||
#define D_SENSOR_ADC_PH "ADC pH"
|
||||
#define D_SENSOR_ADC_MQ "ADC MQ"
|
||||
#define D_SENSOR_ADC_VOLTAGE "ADC Voltage"
|
||||
#define D_SENSOR_ADC_CURRENT "ADC Current"
|
||||
#define D_GPIO_WEBCAM_PWDN "CAM_PWDN"
|
||||
#define D_GPIO_WEBCAM_RESET "CAM_RESET"
|
||||
#define D_GPIO_WEBCAM_XCLK "CAM_XCLK"
|
||||
|
|
|
@ -913,6 +913,8 @@
|
|||
#define D_SENSOR_ADC_JOYSTICK "ADC Joystick"
|
||||
#define D_SENSOR_ADC_PH "ADC pH"
|
||||
#define D_SENSOR_ADC_MQ "ADC MQ"
|
||||
#define D_SENSOR_ADC_VOLTAGE "ADC Voltage"
|
||||
#define D_SENSOR_ADC_CURRENT "ADC Current"
|
||||
#define D_GPIO_WEBCAM_PWDN "CAM_PWDN"
|
||||
#define D_GPIO_WEBCAM_RESET "CAM_RESET"
|
||||
#define D_GPIO_WEBCAM_XCLK "CAM_XCLK"
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
\*********************************************************************************************/
|
||||
|
||||
#define XSNS_02 2
|
||||
#define XNRG_33 33
|
||||
|
||||
#ifdef ESP32
|
||||
#include "esp32-hal-adc.h"
|
||||
|
@ -246,6 +247,18 @@ void AdcInitParams(uint8_t idx) {
|
|||
Adc[idx].param3 = (int)(ANALOG_MQ_B * ANALOG_MQ_DECIMAL_MULTIPLIER); // Exponential regression
|
||||
Adc[idx].param4 = (int)(ANALOG_MQ_RatioMQCleanAir * ANALOG_MQ_DECIMAL_MULTIPLIER); // Exponential regression
|
||||
}
|
||||
else if (ADC_VOLTAGE == Adc[idx].type) {
|
||||
Adc[idx].param1 = 0;
|
||||
Adc[idx].param2 = ANALOG_RANGE;
|
||||
Adc[idx].param3 = 0;
|
||||
Adc[idx].param4 = ANALOG_V33 * 10000;
|
||||
}
|
||||
else if (ADC_CURRENT == Adc[idx].type) {
|
||||
Adc[idx].param1 = 0;
|
||||
Adc[idx].param2 = ANALOG_RANGE;
|
||||
Adc[idx].param3 = 0;
|
||||
Adc[idx].param4 = ANALOG_V33 * 10000;
|
||||
}
|
||||
}
|
||||
if ((Adcs.type != Adc[idx].type) || (0 == Adc[idx].param1) || (Adc[idx].param1 > ANALOG_RANGE)) {
|
||||
if ((ADC_BUTTON == Adc[idx].type) || (ADC_BUTTON_INV == Adc[idx].type)) {
|
||||
|
@ -297,6 +310,12 @@ void AdcInit(void) {
|
|||
if (PinUsed(GPIO_ADC_MQ, i)) {
|
||||
AdcAttach(Pin(GPIO_ADC_MQ, i), ADC_MQ);
|
||||
}
|
||||
if (PinUsed(GPIO_ADC_VOLTAGE, i)) {
|
||||
AdcAttach(Pin(GPIO_ADC_VOLTAGE, i), ADC_VOLTAGE);
|
||||
}
|
||||
if (PinUsed(GPIO_ADC_CURRENT, i)) {
|
||||
AdcAttach(Pin(GPIO_ADC_CURRENT, i), ADC_CURRENT);
|
||||
}
|
||||
}
|
||||
for (uint32_t i = 0; i < MAX_KEYS; i++) {
|
||||
if (PinUsed(GPIO_ADC_BUTTON, i)) {
|
||||
|
@ -540,6 +559,8 @@ void AdcGetCurrentPower(uint8_t idx, uint8_t factor) {
|
|||
}
|
||||
|
||||
void AdcEverySecond(void) {
|
||||
uint32_t voltage_index = 0;
|
||||
uint32_t current_index = 0;
|
||||
for (uint32_t idx = 0; idx < Adcs.present; idx++) {
|
||||
if (ADC_TEMP == Adc[idx].type) {
|
||||
int adc = AdcRead(Adc[idx].pin, 2);
|
||||
|
@ -572,7 +593,27 @@ void AdcEverySecond(void) {
|
|||
AddSampleMq(idx);
|
||||
AdcGetMq(idx);
|
||||
}
|
||||
#ifdef USE_ENERGY_SENSOR
|
||||
else if (ADC_VOLTAGE == Adc[idx].type) {
|
||||
Energy->voltage_available = true;
|
||||
Energy->voltage[voltage_index++] = AdcGetRange(idx) / 10000;
|
||||
}
|
||||
else if (ADC_CURRENT == Adc[idx].type) {
|
||||
Energy->current_available = true;
|
||||
Energy->current[current_index++] = AdcGetRange(idx) / 10000;
|
||||
}
|
||||
#endif // USE_ENERGY_SENSOR
|
||||
}
|
||||
#ifdef USE_ENERGY_SENSOR
|
||||
if (voltage_index && current_index) {
|
||||
for (uint32_t phase = 0; phase < current_index; phase++) {
|
||||
uint32_t voltage_phase = (voltage_index == current_index) ? phase : 0;
|
||||
Energy->active_power[phase] = Energy->voltage[voltage_phase] * Energy->current[phase];
|
||||
Energy->kWhtoday_delta[phase] += (uint32_t)(Energy->active_power[phase] * 1) / 36;
|
||||
}
|
||||
EnergyUpdateToday();
|
||||
}
|
||||
#endif // USE_ENERGY_SENSOR
|
||||
}
|
||||
|
||||
void AdcShowContinuation(bool *jsonflg) {
|
||||
|
@ -774,9 +815,13 @@ void CmndAdcParam(void) {
|
|||
// AdcParam 3, 10000, 12518931, -1.405
|
||||
// AdcParam 4, 128, 0, 0
|
||||
// AdcParam 5, 128, 0, 0
|
||||
// AdcParam 6, 0, ANALOG_RANGE, 0, 100
|
||||
// AdcParam 6, 0, ANALOG_RANGE, 0, 100 ADC_RANGE
|
||||
// AdcParam 7, 0, 2146, 0.23
|
||||
// AdcParam 8, 1000, 0, 0
|
||||
// AdcParam 9, ADC_PH
|
||||
// AdcParam 10, ADC_MQ
|
||||
// AdcParam 11, 0, ANALOG_RANGE, 0, 33000 ADC_VOLTAGE
|
||||
// AdcParam 12, 0, ANALOG_RANGE, 0, 33000 ADC_CURRENT
|
||||
Adc[idx].type = XdrvMailbox.payload;
|
||||
Adc[idx].param1 = strtol(ArgV(argument, 2), nullptr, 10);
|
||||
Adc[idx].param2 = strtol(ArgV(argument, 3), nullptr, 10);
|
||||
|
@ -889,7 +934,36 @@ void CmndAdcParam(void) {
|
|||
}
|
||||
|
||||
/*********************************************************************************************\
|
||||
* Interface
|
||||
* Energy Interface
|
||||
\*********************************************************************************************/
|
||||
|
||||
#ifdef USE_ENERGY_SENSOR
|
||||
bool Xnrg33(uint32_t function) {
|
||||
bool result = false;
|
||||
|
||||
if (FUNC_PRE_INIT == function) {
|
||||
uint32_t voltage_count = 0;
|
||||
uint32_t current_count = 0;
|
||||
for (uint32_t idx = 0; idx < Adcs.present; idx++) {
|
||||
if (ADC_VOLTAGE == Adc[idx].type) { voltage_count++; }
|
||||
if (ADC_CURRENT == Adc[idx].type) { current_count++; }
|
||||
}
|
||||
if (voltage_count || current_count) {
|
||||
Energy->type_dc = true;
|
||||
Energy->phase_count = (voltage_count > current_count) ? voltage_count : current_count;
|
||||
Energy->current_available = false;
|
||||
Energy->voltage_available = false;
|
||||
Energy->voltage_common = (1 == voltage_count);
|
||||
Energy->use_overtemp = true; // Use global temperature for overtemp detection
|
||||
TasmotaGlobal.energy_driver = XNRG_33;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
#endif // USE_ENERGY_SENSOR
|
||||
|
||||
/*********************************************************************************************\
|
||||
* Sensor Interface
|
||||
\*********************************************************************************************/
|
||||
|
||||
bool Xsns02(uint32_t function) {
|
||||
|
|
|
@ -150,7 +150,11 @@ bool (* const xnrg_func_ptr[])(uint32_t) = { // Energy driver Function Pointer
|
|||
#endif
|
||||
|
||||
#ifdef XNRG_32 // Reserved for use by xdrv_16_tuyamcu.ino
|
||||
&Xnrg32
|
||||
&Xnrg32,
|
||||
#endif
|
||||
|
||||
#ifdef XNRG_33 // Reserved for use by xsns_02_analog.ino
|
||||
&Xnrg33
|
||||
#endif
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue