mirror of https://github.com/arendst/Tasmota.git
Add ESP32 Analog input support for GPIO32 to GPIO39
This commit is contained in:
parent
4db5a57816
commit
ce388c799f
|
@ -57,3 +57,4 @@ The following binary downloads have been compiled with ESP8266/Arduino library c
|
|||
|
||||
- Fix ESP32 PWM range
|
||||
- Add Zigbee better support for IKEA Motion Sensor
|
||||
- Add ESP32 Analog input support for GPIO32 to GPIO39
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
- Fix ESP32 PWM range
|
||||
- Add Zigbee better support for IKEA Motion Sensor
|
||||
- Add ESP32 Analog input support for GPIO32 to GPIO39
|
||||
|
||||
### 8.4.0 20200730
|
||||
|
||||
|
|
|
@ -687,6 +687,13 @@
|
|||
#define D_SENSOR_TELEINFO_RX "TInfo Rx"
|
||||
#define D_SENSOR_TELEINFO_ENABLE "TInfo EN"
|
||||
#define D_SENSOR_LMT01_PULSE "LMT01 Pulse"
|
||||
#define D_SENSOR_ADC_INPUT "ADC Input"
|
||||
#define D_SENSOR_ADC_TEMP "ADC Temp"
|
||||
#define D_SENSOR_ADC_LIGHT "ADC Light"
|
||||
#define D_SENSOR_ADC_BUTTON "ADC Button"
|
||||
#define D_SENSOR_ADC_RANGE "ADC Range"
|
||||
#define D_SENSOR_ADC_CT_POWER "ADC CT Power"
|
||||
#define D_SENSOR_ADC_JOYSTICK "ADC Joystick"
|
||||
#define D_GPIO_WEBCAM_PWDN "CAM_PWDN"
|
||||
#define D_GPIO_WEBCAM_RESET "CAM_RESET"
|
||||
#define D_GPIO_WEBCAM_XCLK "CAM_XCLK"
|
||||
|
|
|
@ -687,6 +687,13 @@
|
|||
#define D_SENSOR_TELEINFO_RX "TInfo Rx"
|
||||
#define D_SENSOR_TELEINFO_ENABLE "TInfo EN"
|
||||
#define D_SENSOR_LMT01_PULSE "LMT01 Pulse"
|
||||
#define D_SENSOR_ADC_INPUT "ADC Input"
|
||||
#define D_SENSOR_ADC_TEMP "ADC Temp"
|
||||
#define D_SENSOR_ADC_LIGHT "ADC Light"
|
||||
#define D_SENSOR_ADC_BUTTON "ADC Button"
|
||||
#define D_SENSOR_ADC_RANGE "ADC Range"
|
||||
#define D_SENSOR_ADC_CT_POWER "ADC CT Power"
|
||||
#define D_SENSOR_ADC_JOYSTICK "ADC Joystick"
|
||||
#define D_GPIO_WEBCAM_PWDN "CAM_PWDN"
|
||||
#define D_GPIO_WEBCAM_RESET "CAM_RESET"
|
||||
#define D_GPIO_WEBCAM_XCLK "CAM_XCLK"
|
||||
|
|
|
@ -687,6 +687,13 @@
|
|||
#define D_SENSOR_TELEINFO_RX "TInfo Rx"
|
||||
#define D_SENSOR_TELEINFO_ENABLE "TInfo EN"
|
||||
#define D_SENSOR_LMT01_PULSE "LMT01 Pulse"
|
||||
#define D_SENSOR_ADC_INPUT "ADC Input"
|
||||
#define D_SENSOR_ADC_TEMP "ADC Temp"
|
||||
#define D_SENSOR_ADC_LIGHT "ADC Light"
|
||||
#define D_SENSOR_ADC_BUTTON "ADC Button"
|
||||
#define D_SENSOR_ADC_RANGE "ADC Range"
|
||||
#define D_SENSOR_ADC_CT_POWER "ADC CT Power"
|
||||
#define D_SENSOR_ADC_JOYSTICK "ADC Joystick"
|
||||
#define D_GPIO_WEBCAM_PWDN "CAM_PWDN"
|
||||
#define D_GPIO_WEBCAM_RESET "CAM_RESET"
|
||||
#define D_GPIO_WEBCAM_XCLK "CAM_XCLK"
|
||||
|
|
|
@ -687,6 +687,13 @@
|
|||
#define D_SENSOR_TELEINFO_RX "TInfo Rx"
|
||||
#define D_SENSOR_TELEINFO_ENABLE "TInfo EN"
|
||||
#define D_SENSOR_LMT01_PULSE "LMT01 Pulse"
|
||||
#define D_SENSOR_ADC_INPUT "ADC Input"
|
||||
#define D_SENSOR_ADC_TEMP "ADC Temp"
|
||||
#define D_SENSOR_ADC_LIGHT "ADC Light"
|
||||
#define D_SENSOR_ADC_BUTTON "ADC Button"
|
||||
#define D_SENSOR_ADC_RANGE "ADC Range"
|
||||
#define D_SENSOR_ADC_CT_POWER "ADC CT Power"
|
||||
#define D_SENSOR_ADC_JOYSTICK "ADC Joystick"
|
||||
#define D_GPIO_WEBCAM_PWDN "CAM_PWDN"
|
||||
#define D_GPIO_WEBCAM_RESET "CAM_RESET"
|
||||
#define D_GPIO_WEBCAM_XCLK "CAM_XCLK"
|
||||
|
|
|
@ -687,6 +687,13 @@
|
|||
#define D_SENSOR_TELEINFO_RX "TInfo Rx"
|
||||
#define D_SENSOR_TELEINFO_ENABLE "TInfo EN"
|
||||
#define D_SENSOR_LMT01_PULSE "LMT01 Pulse"
|
||||
#define D_SENSOR_ADC_INPUT "ADC Input"
|
||||
#define D_SENSOR_ADC_TEMP "ADC Temp"
|
||||
#define D_SENSOR_ADC_LIGHT "ADC Light"
|
||||
#define D_SENSOR_ADC_BUTTON "ADC Button"
|
||||
#define D_SENSOR_ADC_RANGE "ADC Range"
|
||||
#define D_SENSOR_ADC_CT_POWER "ADC CT Power"
|
||||
#define D_SENSOR_ADC_JOYSTICK "ADC Joystick"
|
||||
#define D_GPIO_WEBCAM_PWDN "CAM_PWDN"
|
||||
#define D_GPIO_WEBCAM_RESET "CAM_RESET"
|
||||
#define D_GPIO_WEBCAM_XCLK "CAM_XCLK"
|
||||
|
|
|
@ -687,6 +687,13 @@
|
|||
#define D_SENSOR_TELEINFO_RX "TInfo Rx"
|
||||
#define D_SENSOR_TELEINFO_ENABLE "TInfo EN"
|
||||
#define D_SENSOR_LMT01_PULSE "LMT01 Pulse"
|
||||
#define D_SENSOR_ADC_INPUT "ADC Input"
|
||||
#define D_SENSOR_ADC_TEMP "ADC Temp"
|
||||
#define D_SENSOR_ADC_LIGHT "ADC Light"
|
||||
#define D_SENSOR_ADC_BUTTON "ADC Button"
|
||||
#define D_SENSOR_ADC_RANGE "ADC Range"
|
||||
#define D_SENSOR_ADC_CT_POWER "ADC CT Power"
|
||||
#define D_SENSOR_ADC_JOYSTICK "ADC Joystick"
|
||||
#define D_GPIO_WEBCAM_PWDN "CAM_PWDN"
|
||||
#define D_GPIO_WEBCAM_RESET "CAM_RESET"
|
||||
#define D_GPIO_WEBCAM_XCLK "CAM_XCLK"
|
||||
|
|
|
@ -687,6 +687,13 @@
|
|||
#define D_SENSOR_TELEINFO_RX "TInfo Rx"
|
||||
#define D_SENSOR_TELEINFO_ENABLE "TInfo EN"
|
||||
#define D_SENSOR_LMT01_PULSE "LMT01 Pulse"
|
||||
#define D_SENSOR_ADC_INPUT "ADC Input"
|
||||
#define D_SENSOR_ADC_TEMP "ADC Temp"
|
||||
#define D_SENSOR_ADC_LIGHT "ADC Light"
|
||||
#define D_SENSOR_ADC_BUTTON "ADC Button"
|
||||
#define D_SENSOR_ADC_RANGE "ADC Range"
|
||||
#define D_SENSOR_ADC_CT_POWER "ADC CT Power"
|
||||
#define D_SENSOR_ADC_JOYSTICK "ADC Joystick"
|
||||
#define D_GPIO_WEBCAM_PWDN "CAM_PWDN"
|
||||
#define D_GPIO_WEBCAM_RESET "CAM_RESET"
|
||||
#define D_GPIO_WEBCAM_XCLK "CAM_XCLK"
|
||||
|
|
|
@ -687,6 +687,13 @@
|
|||
#define D_SENSOR_TELEINFO_RX "TInfo Rx"
|
||||
#define D_SENSOR_TELEINFO_ENABLE "TInfo EN"
|
||||
#define D_SENSOR_LMT01_PULSE "LMT01 Pulse"
|
||||
#define D_SENSOR_ADC_INPUT "ADC Input"
|
||||
#define D_SENSOR_ADC_TEMP "ADC Temp"
|
||||
#define D_SENSOR_ADC_LIGHT "ADC Light"
|
||||
#define D_SENSOR_ADC_BUTTON "ADC Button"
|
||||
#define D_SENSOR_ADC_RANGE "ADC Range"
|
||||
#define D_SENSOR_ADC_CT_POWER "ADC CT Power"
|
||||
#define D_SENSOR_ADC_JOYSTICK "ADC Joystick"
|
||||
#define D_GPIO_WEBCAM_PWDN "CAM_PWDN"
|
||||
#define D_GPIO_WEBCAM_RESET "CAM_RESET"
|
||||
#define D_GPIO_WEBCAM_XCLK "CAM_XCLK"
|
||||
|
|
|
@ -687,6 +687,13 @@
|
|||
#define D_SENSOR_TELEINFO_RX "TInfo Rx"
|
||||
#define D_SENSOR_TELEINFO_ENABLE "TInfo EN"
|
||||
#define D_SENSOR_LMT01_PULSE "LMT01 Pulse"
|
||||
#define D_SENSOR_ADC_INPUT "ADC Input"
|
||||
#define D_SENSOR_ADC_TEMP "ADC Temp"
|
||||
#define D_SENSOR_ADC_LIGHT "ADC Light"
|
||||
#define D_SENSOR_ADC_BUTTON "ADC Button"
|
||||
#define D_SENSOR_ADC_RANGE "ADC Range"
|
||||
#define D_SENSOR_ADC_CT_POWER "ADC CT Power"
|
||||
#define D_SENSOR_ADC_JOYSTICK "ADC Joystick"
|
||||
#define D_GPIO_WEBCAM_PWDN "CAM_PWDN"
|
||||
#define D_GPIO_WEBCAM_RESET "CAM_RESET"
|
||||
#define D_GPIO_WEBCAM_XCLK "CAM_XCLK"
|
||||
|
|
|
@ -687,6 +687,13 @@
|
|||
#define D_SENSOR_TELEINFO_RX "TInfo Rx"
|
||||
#define D_SENSOR_TELEINFO_ENABLE "TInfo EN"
|
||||
#define D_SENSOR_LMT01_PULSE "LMT01 Pulse"
|
||||
#define D_SENSOR_ADC_INPUT "ADC Input"
|
||||
#define D_SENSOR_ADC_TEMP "ADC Temp"
|
||||
#define D_SENSOR_ADC_LIGHT "ADC Light"
|
||||
#define D_SENSOR_ADC_BUTTON "ADC Button"
|
||||
#define D_SENSOR_ADC_RANGE "ADC Range"
|
||||
#define D_SENSOR_ADC_CT_POWER "ADC CT Power"
|
||||
#define D_SENSOR_ADC_JOYSTICK "ADC Joystick"
|
||||
#define D_GPIO_WEBCAM_PWDN "CAM_PWDN"
|
||||
#define D_GPIO_WEBCAM_RESET "CAM_RESET"
|
||||
#define D_GPIO_WEBCAM_XCLK "CAM_XCLK"
|
||||
|
|
|
@ -687,6 +687,13 @@
|
|||
#define D_SENSOR_TELEINFO_RX "TInfo Rx"
|
||||
#define D_SENSOR_TELEINFO_ENABLE "TInfo EN"
|
||||
#define D_SENSOR_LMT01_PULSE "LMT01 Pulse"
|
||||
#define D_SENSOR_ADC_INPUT "ADC Input"
|
||||
#define D_SENSOR_ADC_TEMP "ADC Temp"
|
||||
#define D_SENSOR_ADC_LIGHT "ADC Light"
|
||||
#define D_SENSOR_ADC_BUTTON "ADC Button"
|
||||
#define D_SENSOR_ADC_RANGE "ADC Range"
|
||||
#define D_SENSOR_ADC_CT_POWER "ADC CT Power"
|
||||
#define D_SENSOR_ADC_JOYSTICK "ADC Joystick"
|
||||
#define D_GPIO_WEBCAM_PWDN "CAM_PWDN"
|
||||
#define D_GPIO_WEBCAM_RESET "CAM_RESET"
|
||||
#define D_GPIO_WEBCAM_XCLK "CAM_XCLK"
|
||||
|
|
|
@ -687,6 +687,13 @@
|
|||
#define D_SENSOR_TELEINFO_RX "TInfo Rx"
|
||||
#define D_SENSOR_TELEINFO_ENABLE "TInfo EN"
|
||||
#define D_SENSOR_LMT01_PULSE "LMT01 Pulse"
|
||||
#define D_SENSOR_ADC_INPUT "ADC Input"
|
||||
#define D_SENSOR_ADC_TEMP "ADC Temp"
|
||||
#define D_SENSOR_ADC_LIGHT "ADC Light"
|
||||
#define D_SENSOR_ADC_BUTTON "ADC Button"
|
||||
#define D_SENSOR_ADC_RANGE "ADC Range"
|
||||
#define D_SENSOR_ADC_CT_POWER "ADC CT Power"
|
||||
#define D_SENSOR_ADC_JOYSTICK "ADC Joystick"
|
||||
#define D_GPIO_WEBCAM_PWDN "CAM_PWDN"
|
||||
#define D_GPIO_WEBCAM_RESET "CAM_RESET"
|
||||
#define D_GPIO_WEBCAM_XCLK "CAM_XCLK"
|
||||
|
|
|
@ -687,6 +687,13 @@
|
|||
#define D_SENSOR_TELEINFO_RX "TInfo Rx"
|
||||
#define D_SENSOR_TELEINFO_ENABLE "TInfo EN"
|
||||
#define D_SENSOR_LMT01_PULSE "LMT01 Pulse"
|
||||
#define D_SENSOR_ADC_INPUT "ADC Input"
|
||||
#define D_SENSOR_ADC_TEMP "ADC Temp"
|
||||
#define D_SENSOR_ADC_LIGHT "ADC Light"
|
||||
#define D_SENSOR_ADC_BUTTON "ADC Button"
|
||||
#define D_SENSOR_ADC_RANGE "ADC Range"
|
||||
#define D_SENSOR_ADC_CT_POWER "ADC CT Power"
|
||||
#define D_SENSOR_ADC_JOYSTICK "ADC Joystick"
|
||||
#define D_GPIO_WEBCAM_PWDN "CAM_PWDN"
|
||||
#define D_GPIO_WEBCAM_RESET "CAM_RESET"
|
||||
#define D_GPIO_WEBCAM_XCLK "CAM_XCLK"
|
||||
|
|
|
@ -687,6 +687,13 @@
|
|||
#define D_SENSOR_TELEINFO_RX "TInfo Rx"
|
||||
#define D_SENSOR_TELEINFO_ENABLE "TInfo EN"
|
||||
#define D_SENSOR_LMT01_PULSE "LMT01 Pulse"
|
||||
#define D_SENSOR_ADC_INPUT "ADC Input"
|
||||
#define D_SENSOR_ADC_TEMP "ADC Temp"
|
||||
#define D_SENSOR_ADC_LIGHT "ADC Light"
|
||||
#define D_SENSOR_ADC_BUTTON "ADC Button"
|
||||
#define D_SENSOR_ADC_RANGE "ADC Range"
|
||||
#define D_SENSOR_ADC_CT_POWER "ADC CT Power"
|
||||
#define D_SENSOR_ADC_JOYSTICK "ADC Joystick"
|
||||
#define D_GPIO_WEBCAM_PWDN "CAM_PWDN"
|
||||
#define D_GPIO_WEBCAM_RESET "CAM_RESET"
|
||||
#define D_GPIO_WEBCAM_XCLK "CAM_XCLK"
|
||||
|
|
|
@ -687,6 +687,13 @@
|
|||
#define D_SENSOR_TELEINFO_RX "TInfo Rx"
|
||||
#define D_SENSOR_TELEINFO_ENABLE "TInfo EN"
|
||||
#define D_SENSOR_LMT01_PULSE "LMT01 Pulse"
|
||||
#define D_SENSOR_ADC_INPUT "ADC Input"
|
||||
#define D_SENSOR_ADC_TEMP "ADC Temp"
|
||||
#define D_SENSOR_ADC_LIGHT "ADC Light"
|
||||
#define D_SENSOR_ADC_BUTTON "ADC Button"
|
||||
#define D_SENSOR_ADC_RANGE "ADC Range"
|
||||
#define D_SENSOR_ADC_CT_POWER "ADC CT Power"
|
||||
#define D_SENSOR_ADC_JOYSTICK "ADC Joystick"
|
||||
#define D_GPIO_WEBCAM_PWDN "CAM_PWDN"
|
||||
#define D_GPIO_WEBCAM_RESET "CAM_RESET"
|
||||
#define D_GPIO_WEBCAM_XCLK "CAM_XCLK"
|
||||
|
|
|
@ -687,6 +687,13 @@
|
|||
#define D_SENSOR_TELEINFO_RX "TInfo Rx"
|
||||
#define D_SENSOR_TELEINFO_ENABLE "TInfo EN"
|
||||
#define D_SENSOR_LMT01_PULSE "LMT01 Pulse"
|
||||
#define D_SENSOR_ADC_INPUT "ADC Input"
|
||||
#define D_SENSOR_ADC_TEMP "ADC Temp"
|
||||
#define D_SENSOR_ADC_LIGHT "ADC Light"
|
||||
#define D_SENSOR_ADC_BUTTON "ADC Button"
|
||||
#define D_SENSOR_ADC_RANGE "ADC Range"
|
||||
#define D_SENSOR_ADC_CT_POWER "ADC CT Power"
|
||||
#define D_SENSOR_ADC_JOYSTICK "ADC Joystick"
|
||||
#define D_GPIO_WEBCAM_PWDN "CAM_PWDN"
|
||||
#define D_GPIO_WEBCAM_RESET "CAM_RESET"
|
||||
#define D_GPIO_WEBCAM_XCLK "CAM_XCLK"
|
||||
|
|
|
@ -687,6 +687,13 @@
|
|||
#define D_SENSOR_TELEINFO_RX "TInfo Rx"
|
||||
#define D_SENSOR_TELEINFO_ENABLE "TInfo EN"
|
||||
#define D_SENSOR_LMT01_PULSE "LMT01 Pulse"
|
||||
#define D_SENSOR_ADC_INPUT "ADC Input"
|
||||
#define D_SENSOR_ADC_TEMP "ADC Temp"
|
||||
#define D_SENSOR_ADC_LIGHT "ADC Light"
|
||||
#define D_SENSOR_ADC_BUTTON "ADC Button"
|
||||
#define D_SENSOR_ADC_RANGE "ADC Range"
|
||||
#define D_SENSOR_ADC_CT_POWER "ADC CT Power"
|
||||
#define D_SENSOR_ADC_JOYSTICK "ADC Joystick"
|
||||
#define D_GPIO_WEBCAM_PWDN "CAM_PWDN"
|
||||
#define D_GPIO_WEBCAM_RESET "CAM_RESET"
|
||||
#define D_GPIO_WEBCAM_XCLK "CAM_XCLK"
|
||||
|
|
|
@ -687,6 +687,13 @@
|
|||
#define D_SENSOR_TELEINFO_RX "TInfo Rx"
|
||||
#define D_SENSOR_TELEINFO_ENABLE "TInfo EN"
|
||||
#define D_SENSOR_LMT01_PULSE "LMT01 Pulse"
|
||||
#define D_SENSOR_ADC_INPUT "ADC Input"
|
||||
#define D_SENSOR_ADC_TEMP "ADC Temp"
|
||||
#define D_SENSOR_ADC_LIGHT "ADC Light"
|
||||
#define D_SENSOR_ADC_BUTTON "ADC Button"
|
||||
#define D_SENSOR_ADC_RANGE "ADC Range"
|
||||
#define D_SENSOR_ADC_CT_POWER "ADC CT Power"
|
||||
#define D_SENSOR_ADC_JOYSTICK "ADC Joystick"
|
||||
#define D_GPIO_WEBCAM_PWDN "CAM_PWDN"
|
||||
#define D_GPIO_WEBCAM_RESET "CAM_RESET"
|
||||
#define D_GPIO_WEBCAM_XCLK "CAM_XCLK"
|
||||
|
|
|
@ -687,6 +687,13 @@
|
|||
#define D_SENSOR_TELEINFO_RX "TInfo Rx"
|
||||
#define D_SENSOR_TELEINFO_ENABLE "TInfo EN"
|
||||
#define D_SENSOR_LMT01_PULSE "LMT01 Pulse"
|
||||
#define D_SENSOR_ADC_INPUT "ADC Input"
|
||||
#define D_SENSOR_ADC_TEMP "ADC Temp"
|
||||
#define D_SENSOR_ADC_LIGHT "ADC Light"
|
||||
#define D_SENSOR_ADC_BUTTON "ADC Button"
|
||||
#define D_SENSOR_ADC_RANGE "ADC Range"
|
||||
#define D_SENSOR_ADC_CT_POWER "ADC CT Power"
|
||||
#define D_SENSOR_ADC_JOYSTICK "ADC Joystick"
|
||||
#define D_GPIO_WEBCAM_PWDN "CAM_PWDN"
|
||||
#define D_GPIO_WEBCAM_RESET "CAM_RESET"
|
||||
#define D_GPIO_WEBCAM_XCLK "CAM_XCLK"
|
||||
|
|
|
@ -687,6 +687,13 @@
|
|||
#define D_SENSOR_TELEINFO_RX "TInfo Rx"
|
||||
#define D_SENSOR_TELEINFO_ENABLE "TInfo EN"
|
||||
#define D_SENSOR_LMT01_PULSE "LMT01 Pulse"
|
||||
#define D_SENSOR_ADC_INPUT "ADC Input"
|
||||
#define D_SENSOR_ADC_TEMP "ADC Temp"
|
||||
#define D_SENSOR_ADC_LIGHT "ADC Light"
|
||||
#define D_SENSOR_ADC_BUTTON "ADC Button"
|
||||
#define D_SENSOR_ADC_RANGE "ADC Range"
|
||||
#define D_SENSOR_ADC_CT_POWER "ADC CT Power"
|
||||
#define D_SENSOR_ADC_JOYSTICK "ADC Joystick"
|
||||
#define D_GPIO_WEBCAM_PWDN "CAM_PWDN"
|
||||
#define D_GPIO_WEBCAM_RESET "CAM_RESET"
|
||||
#define D_GPIO_WEBCAM_XCLK "CAM_XCLK"
|
||||
|
|
|
@ -687,6 +687,13 @@
|
|||
#define D_SENSOR_TELEINFO_RX "TInfo Rx"
|
||||
#define D_SENSOR_TELEINFO_ENABLE "TInfo EN"
|
||||
#define D_SENSOR_LMT01_PULSE "LMT01 Pulse"
|
||||
#define D_SENSOR_ADC_INPUT "ADC Input"
|
||||
#define D_SENSOR_ADC_TEMP "ADC Temp"
|
||||
#define D_SENSOR_ADC_LIGHT "ADC Light"
|
||||
#define D_SENSOR_ADC_BUTTON "ADC Button"
|
||||
#define D_SENSOR_ADC_RANGE "ADC Range"
|
||||
#define D_SENSOR_ADC_CT_POWER "ADC CT Power"
|
||||
#define D_SENSOR_ADC_JOYSTICK "ADC Joystick"
|
||||
#define D_GPIO_WEBCAM_PWDN "CAM_PWDN"
|
||||
#define D_GPIO_WEBCAM_RESET "CAM_RESET"
|
||||
#define D_GPIO_WEBCAM_XCLK "CAM_XCLK"
|
||||
|
|
|
@ -687,6 +687,13 @@
|
|||
#define D_SENSOR_TELEINFO_RX "TInfo Rx"
|
||||
#define D_SENSOR_TELEINFO_ENABLE "TInfo EN"
|
||||
#define D_SENSOR_LMT01_PULSE "LMT01 Pulse"
|
||||
#define D_SENSOR_ADC_INPUT "ADC Input"
|
||||
#define D_SENSOR_ADC_TEMP "ADC Temp"
|
||||
#define D_SENSOR_ADC_LIGHT "ADC Light"
|
||||
#define D_SENSOR_ADC_BUTTON "ADC Button"
|
||||
#define D_SENSOR_ADC_RANGE "ADC Range"
|
||||
#define D_SENSOR_ADC_CT_POWER "ADC CT Power"
|
||||
#define D_SENSOR_ADC_JOYSTICK "ADC Joystick"
|
||||
#define D_GPIO_WEBCAM_PWDN "CAM_PWDN"
|
||||
#define D_GPIO_WEBCAM_RESET "CAM_RESET"
|
||||
#define D_GPIO_WEBCAM_XCLK "CAM_XCLK"
|
||||
|
|
|
@ -687,6 +687,13 @@
|
|||
#define D_SENSOR_TELEINFO_RX "TInfo Rx"
|
||||
#define D_SENSOR_TELEINFO_ENABLE "TInfo EN"
|
||||
#define D_SENSOR_LMT01_PULSE "LMT01 Pulse"
|
||||
#define D_SENSOR_ADC_INPUT "ADC Input"
|
||||
#define D_SENSOR_ADC_TEMP "ADC Temp"
|
||||
#define D_SENSOR_ADC_LIGHT "ADC Light"
|
||||
#define D_SENSOR_ADC_BUTTON "ADC Button"
|
||||
#define D_SENSOR_ADC_RANGE "ADC Range"
|
||||
#define D_SENSOR_ADC_CT_POWER "ADC CT Power"
|
||||
#define D_SENSOR_ADC_JOYSTICK "ADC Joystick"
|
||||
#define D_GPIO_WEBCAM_PWDN "CAM_PWDN"
|
||||
#define D_GPIO_WEBCAM_RESET "CAM_RESET"
|
||||
#define D_GPIO_WEBCAM_XCLK "CAM_XCLK"
|
||||
|
|
|
@ -768,6 +768,8 @@
|
|||
// #define ETH_ADDR 0 // [EthAddress] 0 = PHY0 .. 31 = PHY31
|
||||
// #define ETH_CLKMODE 0 // [EthClockMode] 0 = ETH_CLOCK_GPIO0_IN, 1 = ETH_CLOCK_GPIO0_OUT, 2 = ETH_CLOCK_GPIO16_OUT, 3 = ETH_CLOCK_GPIO17_OUT
|
||||
|
||||
#define USE_ADC // Add support for ADC on GPIO32 to GPIO39
|
||||
|
||||
//#define USE_SPI // Add support for hardware SPI
|
||||
//#define USE_MI_ESP32 // Add support for ESP32 as a BLE-bridge (+9k2 mem, +292k flash)
|
||||
//#define USE_WEBCAM // Add support for webcam
|
||||
|
|
|
@ -127,6 +127,18 @@ size_t strchrspn(const char *str1, int character)
|
|||
return ret;
|
||||
}
|
||||
|
||||
uint32_t ChrCount(const char *str, const char *delim) {
|
||||
uint32_t count = 0;
|
||||
char* read = (char*)str;
|
||||
char ch = '.';
|
||||
|
||||
while (ch != '\0') {
|
||||
ch = *read++;
|
||||
if (ch == *delim) { count++; }
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
// Function to return a substring defined by a delimiter at an index
|
||||
char* subStr(char* dest, char* str, const char *delim, int index)
|
||||
{
|
||||
|
@ -152,6 +164,8 @@ float CharToFloat(const char *str)
|
|||
|
||||
strlcpy(strbuf, str, sizeof(strbuf));
|
||||
char *pt = strbuf;
|
||||
if (*pt == '\0') { return 0.0; }
|
||||
|
||||
while ((*pt != '\0') && isblank(*pt)) { pt++; } // Trim leading spaces
|
||||
|
||||
signed char sign = 1;
|
||||
|
@ -394,11 +408,13 @@ char* UpperCase_P(char* dest, const char* source)
|
|||
|
||||
char* Trim(char* p)
|
||||
{
|
||||
while ((*p != '\0') && isblank(*p)) { p++; } // Trim leading spaces
|
||||
char* q = p + strlen(p) -1;
|
||||
while ((q >= p) && isblank(*q)) { q--; } // Trim trailing spaces
|
||||
q++;
|
||||
*q = '\0';
|
||||
if (*p != '\0') {
|
||||
while ((*p != '\0') && isblank(*p)) { p++; } // Trim leading spaces
|
||||
char* q = p + strlen(p) -1;
|
||||
while ((q >= p) && isblank(*q)) { q--; } // Trim trailing spaces
|
||||
q++;
|
||||
*q = '\0';
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
|
|
|
@ -85,7 +85,7 @@ const uint8_t MAX_DEV_GROUP_NAMES = 4; // Max number of Device Group names
|
|||
|
||||
const uint8_t MAX_HUE_DEVICES = 15; // Max number of Philips Hue device per emulation
|
||||
const uint8_t MAX_ROTARIES = 2; // Max number of Rotary Encoders
|
||||
const uint8_t MAX_ADCS = 18; // Max number of ESP32 ADC pins
|
||||
const uint8_t MAX_ADCS = 8; // Max number of ESP32 ADC pins (ADC2 pins are unusable with Wifi enabled)
|
||||
|
||||
const char MQTT_TOKEN_PREFIX[] PROGMEM = "%prefix%"; // To be substituted by mqtt_prefix[x]
|
||||
const char MQTT_TOKEN_TOPIC[] PROGMEM = "%topic%"; // To be substituted by mqtt_topic, mqtt_grptopic, mqtt_buttontopic, mqtt_switchtopic
|
||||
|
@ -297,6 +297,9 @@ enum SettingsTextIndex { SET_OTAURL,
|
|||
SET_DEV_GROUP_NAME1, SET_DEV_GROUP_NAME2, SET_DEV_GROUP_NAME3, SET_DEV_GROUP_NAME4,
|
||||
SET_DEVICENAME,
|
||||
SET_TELEGRAM_TOKEN, SET_TELEGRAM_CHATID,
|
||||
#ifdef ESP32
|
||||
SET_ADC_PARAM1, SET_ADC_PARAM2, SET_ADC_PARAM3, SET_ADC_PARAM4, SET_ADC_PARAM5, SET_ADC_PARAM6, SET_ADC_PARAM7, SET_ADC_PARAM8, // Relates to MAX_ADCS
|
||||
#endif
|
||||
SET_MAX };
|
||||
|
||||
enum DevGroupMessageType { DGR_MSGTYP_FULL_STATUS, DGR_MSGTYP_PARTIAL_UPDATE, DGR_MSGTYP_UPDATE, DGR_MSGTYP_UPDATE_MORE_TO_COME, DGR_MSGTYP_UPDATE_DIRECT, DGR_MSGTYPE_UPDATE_COMMAND };
|
||||
|
|
|
@ -88,8 +88,9 @@ enum UserSelectablePins {
|
|||
GPIO_ARIRFRCV, GPIO_ARIRFSEL, // Arilux RF Receive input
|
||||
GPIO_TXD, GPIO_RXD, // Serial interface
|
||||
GPIO_ROT1A, GPIO_ROT1B, // Rotary switch
|
||||
GPIO_ADC_JOY, // Analog joystick
|
||||
|
||||
GPIO_SPARE1, GPIO_SPARE2, // Spare GPIOs
|
||||
GPIO_SPARE1, // Spare GPIOs
|
||||
|
||||
GPIO_HRE_CLOCK, GPIO_HRE_DATA, // HR-E Water Meter
|
||||
GPIO_ADE7953_IRQ, // ADE7953 IRQ
|
||||
|
@ -193,8 +194,9 @@ const char kSensorNames[] PROGMEM =
|
|||
D_SENSOR_ARIRFRCV "|" D_SENSOR_ARIRFSEL "|"
|
||||
D_SENSOR_TXD "|" D_SENSOR_RXD "|"
|
||||
D_SENSOR_ROTARY "_a|" D_SENSOR_ROTARY "_b|"
|
||||
D_SENSOR_ADC_JOYSTICK "|"
|
||||
|
||||
"Spare1|Spare2|"
|
||||
"Spare1|"
|
||||
|
||||
D_SENSOR_HRE_CLOCK "|" D_SENSOR_HRE_DATA "|"
|
||||
D_SENSOR_ADE7953_IRQ "|"
|
||||
|
@ -216,11 +218,12 @@ const char kSensorNames[] PROGMEM =
|
|||
D_SENSOR_HRXL_RX "|"
|
||||
D_SENSOR_ELECTRIQ_MOODL "|"
|
||||
D_SENSOR_AS3935 "|"
|
||||
D_ANALOG_INPUT "|"
|
||||
D_TEMPERATURE "|" D_LIGHT "|"
|
||||
D_SENSOR_BUTTON "|" D_SENSOR_BUTTON "_i|"
|
||||
D_RANGE "|"
|
||||
D_CT_POWER "|"
|
||||
D_SENSOR_ADC_INPUT "|"
|
||||
D_SENSOR_ADC_TEMP "|"
|
||||
D_SENSOR_ADC_LIGHT "|"
|
||||
D_SENSOR_ADC_BUTTON "|" D_SENSOR_ADC_BUTTON "_i|"
|
||||
D_SENSOR_ADC_RANGE "|"
|
||||
D_SENSOR_ADC_CT_POWER "|"
|
||||
D_GPIO_WEBCAM_PWDN "|" D_GPIO_WEBCAM_RESET "|" D_GPIO_WEBCAM_XCLK "|"
|
||||
D_GPIO_WEBCAM_SIOD "|" D_GPIO_WEBCAM_SIOC "|"
|
||||
D_GPIO_WEBCAM_DATA "|"
|
||||
|
@ -564,6 +567,7 @@ const uint16_t kGpioNiceList[] PROGMEM = {
|
|||
AGPIO(GPIO_ADC_BUTTON_INV) + MAX_ADCS,
|
||||
AGPIO(GPIO_ADC_RANGE) + MAX_ADCS, // Range
|
||||
AGPIO(GPIO_ADC_CT_POWER) + MAX_ADCS, // Current
|
||||
AGPIO(GPIO_ADC_JOY) + MAX_ADCS, // Joystick
|
||||
#endif
|
||||
#ifdef USE_WEBCAM
|
||||
AGPIO(GPIO_WEBCAM_PWDN),
|
||||
|
@ -598,7 +602,7 @@ enum UserSelectableAdc {
|
|||
ADC_BUTTON_INV,
|
||||
ADC_RANGE, // Range
|
||||
ADC_CT_POWER, // Current
|
||||
|
||||
ADC_JOY, // Joystick
|
||||
// ADC_SWITCH, // Switch
|
||||
// ADC_SWITCH_INV,
|
||||
ADC_END };
|
||||
|
@ -609,7 +613,7 @@ enum UserSelectableAdc {
|
|||
#define WEMOS_MODULE 0 // Wemos module
|
||||
|
||||
// 0 1 2 3 4 5 6 7 8 9101112131415161718192021222324252627282930313233343536373839
|
||||
const char PINS_WEMOS[] PROGMEM = "IOTXIORXIOIOflashcFLFLolIOIOIOIOIOIOIOIOIOIOIOIOIOIOIOIOIOIOIOIOIOIOA6A7A0IoIoA3";
|
||||
const char PINS_WEMOS[] PROGMEM = "IOTXIORXIOIOflashcFLFLolIOIOIOIOIOIOIOIOIOIOIOIOIOIOIOIOIOIOIOIOAOAOIAIAIAIAIAIA";
|
||||
|
||||
//********************************************************************************************
|
||||
|
||||
|
|
|
@ -20,11 +20,14 @@
|
|||
#ifdef ESP32
|
||||
#ifdef USE_ADC
|
||||
/*********************************************************************************************\
|
||||
* ADC support
|
||||
* ADC support for up to 8 channels on GPIO32 to GPIO39
|
||||
\*********************************************************************************************/
|
||||
|
||||
#define XSNS_02 2
|
||||
|
||||
#define ANALOG_RESOLUTION 12 // 12 = 4095, 11 = 2047, 10 = 1023
|
||||
#define ANALOG_RANGE 4095
|
||||
|
||||
#define TO_CELSIUS(x) ((x) - 273.15)
|
||||
#define TO_KELVIN(x) ((x) + 273.15)
|
||||
|
||||
|
@ -57,132 +60,140 @@
|
|||
// Default settings for a 20A/1V Current Transformer.
|
||||
// Analog peak to peak range is measured and converted to RMS current using ANALOG_CT_MULTIPLIER
|
||||
#define ANALOG_CT_FLAGS 0 // (uint32_t) reserved for possible future use
|
||||
#define ANALOG_CT_MULTIPLIER 2146 // (uint32_t) Multiplier*100000 to convert raw ADC peak to peak range 0..1023 to RMS current in Amps. Value of 100000 corresponds to 1
|
||||
#define ANALOG_CT_MULTIPLIER 2146 // (uint32_t) Multiplier*100000 to convert raw ADC peak to peak range 0..ANALOG_RANGE to RMS current in Amps. Value of 100000 corresponds to 1
|
||||
#define ANALOG_CT_VOLTAGE 2300 // (int) Convert current in Amps to apparrent power in Watts using voltage in Volts*10. Value of 2200 corresponds to 220V
|
||||
|
||||
#define CT_FLAG_ENERGY_RESET (1 << 0) // Reset energy total
|
||||
|
||||
uint8_t adc_present = 0;
|
||||
struct {
|
||||
uint8_t present = 0;
|
||||
uint8_t type = 0;
|
||||
} Adcs;
|
||||
|
||||
struct {
|
||||
float temperature = 0;
|
||||
float current = 0;
|
||||
float energy = 0;
|
||||
uint32_t param1 = 0;
|
||||
uint32_t param2 = 0;
|
||||
int param3 = 0;
|
||||
int param4 = 0;
|
||||
uint32_t previous_millis = 0;
|
||||
uint16_t last_value = 0;
|
||||
uint8_t type = 0;
|
||||
uint8_t pin = 0;
|
||||
} Adc[MAX_ADCS];
|
||||
|
||||
void AdcInitParams(void) {
|
||||
my_adc0 = Adc[0].type;
|
||||
void AdcSaveSettings(uint32_t idx) {
|
||||
char parameters[32];
|
||||
snprintf_P(parameters, sizeof(parameters), PSTR("%d,%d,%d,%d,%d"),
|
||||
Adc[idx].type, Adc[idx].param1, Adc[idx].param2, Adc[idx].param3, Adc[idx].param4);
|
||||
SettingsUpdateText(SET_ADC_PARAM1 + idx, parameters);
|
||||
}
|
||||
|
||||
if ((Settings.adc_param_type != my_adc0) || (Settings.adc_param1 > 1000000)) {
|
||||
if (ADC_TEMP == my_adc0) {
|
||||
void AdcGetSettings(uint32_t idx) {
|
||||
char parameters[32];
|
||||
Adcs.type = 0;
|
||||
Adc[idx].param1 = 0;
|
||||
Adc[idx].param2 = 0;
|
||||
Adc[idx].param3 = 0;
|
||||
Adc[idx].param4 = 0;
|
||||
if (strstr(SettingsText(SET_ADC_PARAM1 + idx), ",") != nullptr) {
|
||||
Adcs.type = atoi(subStr(parameters, SettingsText(SET_ADC_PARAM1 + idx), ",", 1));
|
||||
Adc[idx].param1 = atoi(subStr(parameters, SettingsText(SET_ADC_PARAM1 + idx), ",", 2));
|
||||
Adc[idx].param2 = atoi(subStr(parameters, SettingsText(SET_ADC_PARAM1 + idx), ",", 3));
|
||||
Adc[idx].param3 = atoi(subStr(parameters, SettingsText(SET_ADC_PARAM1 + idx), ",", 4));
|
||||
Adc[idx].param4 = atoi(subStr(parameters, SettingsText(SET_ADC_PARAM1 + idx), ",", 5));
|
||||
}
|
||||
}
|
||||
|
||||
void AdcInitParams(uint8_t idx) {
|
||||
if ((Adcs.type != Adc[idx].type) || (Adc[idx].param1 > 1000000)) {
|
||||
if (ADC_TEMP == Adc[idx].type) {
|
||||
// Default Shelly 2.5 and 1PM parameters
|
||||
Settings.adc_param_type = ADC_TEMP;
|
||||
Settings.adc_param1 = ANALOG_NTC_BRIDGE_RESISTANCE;
|
||||
Settings.adc_param2 = ANALOG_NTC_RESISTANCE;
|
||||
Settings.adc_param3 = ANALOG_NTC_B_COEFFICIENT * 10000;
|
||||
Adc[idx].param1 = ANALOG_NTC_BRIDGE_RESISTANCE;
|
||||
Adc[idx].param2 = ANALOG_NTC_RESISTANCE;
|
||||
Adc[idx].param3 = ANALOG_NTC_B_COEFFICIENT * 10000;
|
||||
}
|
||||
else if (ADC_LIGHT == my_adc0) {
|
||||
Settings.adc_param_type = ADC_LIGHT;
|
||||
Settings.adc_param1 = ANALOG_LDR_BRIDGE_RESISTANCE;
|
||||
Settings.adc_param2 = ANALOG_LDR_LUX_CALC_SCALAR;
|
||||
Settings.adc_param3 = ANALOG_LDR_LUX_CALC_EXPONENT * 10000;
|
||||
else if (ADC_LIGHT == Adc[idx].type) {
|
||||
Adc[idx].param1 = ANALOG_LDR_BRIDGE_RESISTANCE;
|
||||
Adc[idx].param2 = ANALOG_LDR_LUX_CALC_SCALAR;
|
||||
Adc[idx].param3 = ANALOG_LDR_LUX_CALC_EXPONENT * 10000;
|
||||
}
|
||||
else if (ADC_RANGE == my_adc0) {
|
||||
Settings.adc_param_type = ADC_RANGE;
|
||||
Settings.adc_param1 = 0;
|
||||
Settings.adc_param2 = 1023;
|
||||
Settings.adc_param3 = 0;
|
||||
Settings.adc_param4 = 100;
|
||||
else if (ADC_RANGE == Adc[idx].type) {
|
||||
Adc[idx].param1 = 0;
|
||||
Adc[idx].param2 = ANALOG_RANGE;
|
||||
Adc[idx].param3 = 0;
|
||||
Adc[idx].param4 = 100;
|
||||
}
|
||||
else if (ADC_CT_POWER == my_adc0) {
|
||||
Settings.adc_param_type = ADC_CT_POWER;
|
||||
Settings.adc_param1 = ANALOG_CT_FLAGS; //(uint32_t) 0
|
||||
Settings.adc_param2 = ANALOG_CT_MULTIPLIER; //(uint32_t) 100000
|
||||
Settings.adc_param3 = ANALOG_CT_VOLTAGE; //(int) 10
|
||||
else if (ADC_CT_POWER == Adc[idx].type) {
|
||||
Adc[idx].param1 = ANALOG_CT_FLAGS; //(uint32_t) 0
|
||||
Adc[idx].param2 = ANALOG_CT_MULTIPLIER; //(uint32_t) 100000
|
||||
Adc[idx].param3 = ANALOG_CT_VOLTAGE; //(int) 10
|
||||
}
|
||||
else if (ADC_JOY == Adc[idx].type) {
|
||||
Adc[idx].param1 = (ANALOG_RANGE / 2) -128;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AdcAttach(uint8_t pin, uint8_t type) {
|
||||
Adc[Adcs.present].pin = pin;
|
||||
if (adcAttachPin(Adc[Adcs.present].pin)) {
|
||||
Adc[Adcs.present].type = type;
|
||||
// analogSetPinAttenuation(Adc[Adcs.present].pin, ADC_11db); // Default
|
||||
Adcs.present++;
|
||||
}
|
||||
}
|
||||
|
||||
void AdcInit(void) {
|
||||
adc_present = 0;
|
||||
Adcs.present = 0;
|
||||
for (uint32_t i = 0; i < MAX_ADCS; i++) {
|
||||
if (PinUsed(GPIO_ADC_INPUT, i)) {
|
||||
Adc[adc_present].pin = Pin(GPIO_ADC_INPUT, i);
|
||||
if (adcAttachPin(Adc[adc_present].pin)) {
|
||||
Adc[adc_present].type = ADC_INPUT;
|
||||
// analogSetPinAttenuation(Adc[adc_present].pin, ADC_11db); // Default
|
||||
adc_present++;
|
||||
}
|
||||
AdcAttach(Pin(GPIO_ADC_INPUT, i), ADC_INPUT);
|
||||
}
|
||||
if (PinUsed(GPIO_ADC_TEMP, i)) {
|
||||
Adc[adc_present].pin = Pin(GPIO_ADC_TEMP, i);
|
||||
if (adcAttachPin(Adc[adc_present].pin)) {
|
||||
Adc[adc_present].type = ADC_TEMP;
|
||||
// analogSetPinAttenuation(Adc[adc_present].pin, ADC_11db); // Default
|
||||
adc_present++;
|
||||
}
|
||||
AdcAttach(Pin(GPIO_ADC_TEMP, i), ADC_TEMP);
|
||||
}
|
||||
if (PinUsed(GPIO_ADC_LIGHT, i)) {
|
||||
Adc[adc_present].pin = Pin(GPIO_ADC_LIGHT, i);
|
||||
if (adcAttachPin(Adc[adc_present].pin)) {
|
||||
Adc[adc_present].type = ADC_LIGHT;
|
||||
// analogSetPinAttenuation(Adc[adc_present].pin, ADC_11db); // Default
|
||||
adc_present++;
|
||||
}
|
||||
AdcAttach(Pin(GPIO_ADC_LIGHT, i), ADC_LIGHT);
|
||||
}
|
||||
if (PinUsed(GPIO_ADC_BUTTON, i)) {
|
||||
Adc[adc_present].pin = Pin(GPIO_ADC_BUTTON, i);
|
||||
if (adcAttachPin(Adc[adc_present].pin)) {
|
||||
Adc[adc_present].type = ADC_BUTTON;
|
||||
// analogSetPinAttenuation(Adc[adc_present].pin, ADC_11db); // Default
|
||||
adc_present++;
|
||||
}
|
||||
AdcAttach(Pin(GPIO_ADC_BUTTON, i), ADC_BUTTON);
|
||||
}
|
||||
if (PinUsed(ADC_BUTTON_INV, i)) {
|
||||
Adc[adc_present].pin = Pin(ADC_BUTTON_INV, i);
|
||||
if (adcAttachPin(Adc[adc_present].pin)) {
|
||||
Adc[adc_present].type = ADC_BUTTON_INV;
|
||||
// analogSetPinAttenuation(Adc[adc_present].pin, ADC_11db); // Default
|
||||
adc_present++;
|
||||
}
|
||||
if (PinUsed(GPIO_ADC_BUTTON_INV, i)) {
|
||||
AdcAttach(Pin(GPIO_ADC_BUTTON_INV, i), ADC_BUTTON_INV);
|
||||
}
|
||||
if (PinUsed(GPIO_ADC_RANGE, i)) {
|
||||
Adc[adc_present].pin = Pin(GPIO_ADC_RANGE, i);
|
||||
if (adcAttachPin(Adc[adc_present].pin)) {
|
||||
Adc[adc_present].type = ADC_RANGE;
|
||||
// analogSetPinAttenuation(Adc[adc_present].pin, ADC_11db); // Default
|
||||
adc_present++;
|
||||
}
|
||||
AdcAttach(Pin(GPIO_ADC_RANGE, i), ADC_RANGE);
|
||||
}
|
||||
if (PinUsed(GPIO_ADC_CT_POWER, i)) {
|
||||
Adc[adc_present].pin = Pin(GPIO_ADC_CT_POWER, i);
|
||||
if (adcAttachPin(Adc[adc_present].pin)) {
|
||||
Adc[adc_present].type = ADC_CT_POWER;
|
||||
// analogSetPinAttenuation(Adc[adc_present].pin, ADC_11db); // Default
|
||||
adc_present++;
|
||||
}
|
||||
AdcAttach(Pin(GPIO_ADC_CT_POWER, i), ADC_CT_POWER);
|
||||
}
|
||||
if (PinUsed(GPIO_ADC_JOY, i)) {
|
||||
AdcAttach(Pin(GPIO_ADC_JOY, i), ADC_JOY);
|
||||
}
|
||||
}
|
||||
if (adc_present) {
|
||||
analogSetClockDiv(1); // Default 1
|
||||
analogSetWidth(12); // Default 12 bits (0 - 4095)
|
||||
analogSetAttenuation(ADC_11db); // Default 11db
|
||||
if (Adcs.present) {
|
||||
analogSetClockDiv(1); // Default 1
|
||||
analogSetWidth(ANALOG_RESOLUTION); // Default 12 bits (0 - 4095)
|
||||
analogSetAttenuation(ADC_11db); // Default 11db
|
||||
for (uint32_t idx = 0; idx < Adcs.present; idx++) {
|
||||
AdcGetSettings(idx);
|
||||
AdcInitParams(idx);
|
||||
AdcSaveSettings(idx);
|
||||
}
|
||||
}
|
||||
AdcInitParams();
|
||||
}
|
||||
|
||||
uint16_t AdcRead(uint8_t pin, uint8_t factor) {
|
||||
uint16_t AdcRead(uint32_t pin, uint32_t factor) {
|
||||
// factor 1 = 2 samples
|
||||
// factor 2 = 4 samples
|
||||
// factor 3 = 8 samples
|
||||
// factor 4 = 16 samples
|
||||
// factor 5 = 32 samples
|
||||
uint8_t samples = 1 << factor;
|
||||
uint16_t analog = 0;
|
||||
uint32_t samples = 1 << factor;
|
||||
uint32_t analog = 0;
|
||||
for (uint32_t i = 0; i < samples; i++) {
|
||||
analog += analogRead(pin);
|
||||
delay(1);
|
||||
|
@ -193,7 +204,7 @@ uint16_t AdcRead(uint8_t pin, uint8_t factor) {
|
|||
|
||||
#ifdef USE_RULES
|
||||
void AdcEvery250ms(void) {
|
||||
for (uint32_t idx = 0; idx < adc_present; idx++) {
|
||||
for (uint32_t idx = 0; idx < Adcs.present; idx++) {
|
||||
if (ADC_INPUT == Adc[idx].type) {
|
||||
uint16_t new_value = AdcRead(Adc[idx].pin, 5);
|
||||
if ((new_value < Adc[idx].last_value -10) || (new_value > Adc[idx].last_value +10)) {
|
||||
|
@ -203,27 +214,38 @@ void AdcEvery250ms(void) {
|
|||
XdrvRulesProcess();
|
||||
}
|
||||
}
|
||||
else if (ADC_JOY == Adc[idx].type) {
|
||||
uint16_t new_value = AdcRead(Adc[idx].pin, 1);
|
||||
if (new_value && (new_value != Adc[idx].last_value)) {
|
||||
Adc[idx].last_value = new_value;
|
||||
uint16_t value = new_value / Adc[idx].param1;
|
||||
Response_P(PSTR("{\"ANALOG\":{\"JOY%d\":%d}}"), idx, value);
|
||||
XdrvRulesProcess();
|
||||
} else {
|
||||
Adc[idx].last_value = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif // USE_RULES
|
||||
|
||||
uint16_t AdcGetLux(uint8_t pin) {
|
||||
int adc = AdcRead(pin, 2);
|
||||
uint16_t AdcGetLux(uint32_t idx) {
|
||||
int adc = AdcRead(Adc[idx].pin, 2);
|
||||
// Source: https://www.allaboutcircuits.com/projects/design-a-luxmeter-using-a-light-dependent-resistor/
|
||||
double resistorVoltage = ((double)adc / 1023) * ANALOG_V33;
|
||||
double resistorVoltage = ((double)adc / ANALOG_RANGE) * ANALOG_V33;
|
||||
double ldrVoltage = ANALOG_V33 - resistorVoltage;
|
||||
double ldrResistance = ldrVoltage / resistorVoltage * (double)Settings.adc_param1;
|
||||
double ldrLux = (double)Settings.adc_param2 * FastPrecisePow(ldrResistance, (double)Settings.adc_param3 / 10000);
|
||||
double ldrResistance = ldrVoltage / resistorVoltage * (double)Adc[idx].param1;
|
||||
double ldrLux = (double)Adc[idx].param2 * FastPrecisePow(ldrResistance, (double)Adc[idx].param3 / 10000);
|
||||
|
||||
return (uint16_t)ldrLux;
|
||||
}
|
||||
|
||||
uint16_t AdcGetRange(uint8_t pin) {
|
||||
uint16_t AdcGetRange(uint32_t idx) {
|
||||
// formula for calibration: value, fromLow, fromHigh, toLow, toHigh
|
||||
// Example: 514, 632, 236, 0, 100
|
||||
// int( ((<param2> - <analog-value>) / (<param2> - <param1>) ) * (<param3> - <param4>) ) + <param4> )
|
||||
int adc = AdcRead(pin, 2);
|
||||
double adcrange = ( ((double)Settings.adc_param2 - (double)adc) / ( ((double)Settings.adc_param2 - (double)Settings.adc_param1)) * ((double)Settings.adc_param3 - (double)Settings.adc_param4) + (double)Settings.adc_param4 );
|
||||
int adc = AdcRead(Adc[idx].pin, 2);
|
||||
double adcrange = ( ((double)Adc[idx].param2 - (double)adc) / ( ((double)Adc[idx].param2 - (double)Adc[idx].param1)) * ((double)Adc[idx].param3 - (double)Adc[idx].param4) + (double)Adc[idx].param4 );
|
||||
return (uint16_t)adcrange;
|
||||
}
|
||||
|
||||
|
@ -235,10 +257,10 @@ void AdcGetCurrentPower(uint8_t idx, uint8_t factor) {
|
|||
// factor 5 = 32 samples
|
||||
uint8_t samples = 1 << factor;
|
||||
uint16_t analog = 0;
|
||||
uint16_t analog_min = 1023;
|
||||
uint16_t analog_min = ANALOG_RANGE;
|
||||
uint16_t analog_max = 0;
|
||||
|
||||
if (0 == Settings.adc_param1) {
|
||||
if (0 == Adc[idx].param1) {
|
||||
for (uint32_t i = 0; i < samples; i++) {
|
||||
analog = analogRead(Adc[idx].pin);
|
||||
if (analog < analog_min) {
|
||||
|
@ -249,32 +271,32 @@ void AdcGetCurrentPower(uint8_t idx, uint8_t factor) {
|
|||
}
|
||||
delay(1);
|
||||
}
|
||||
Adc[idx].current = (float)(analog_max-analog_min) * ((float)(Settings.adc_param2) / 100000);
|
||||
Adc[idx].current = (float)(analog_max-analog_min) * ((float)(Adc[idx].param2) / 100000);
|
||||
}
|
||||
else {
|
||||
analog = AdcRead(Adc[idx].pin, 5);
|
||||
if (analog > Settings.adc_param1) {
|
||||
Adc[idx].current = ((float)(analog) - (float)Settings.adc_param1) * ((float)(Settings.adc_param2) / 100000);
|
||||
if (analog > Adc[idx].param1) {
|
||||
Adc[idx].current = ((float)(analog) - (float)Adc[idx].param1) * ((float)(Adc[idx].param2) / 100000);
|
||||
}
|
||||
else {
|
||||
Adc[idx].current = 0;
|
||||
}
|
||||
}
|
||||
|
||||
float power = Adc[idx].current * (float)(Settings.adc_param3) / 10;
|
||||
float power = Adc[idx].current * (float)(Adc[idx].param3) / 10;
|
||||
uint32_t current_millis = millis();
|
||||
Adc[idx].energy = Adc[idx].energy + ((power * (current_millis - Adc[idx].previous_millis)) / 3600000000);
|
||||
Adc[idx].previous_millis = current_millis;
|
||||
}
|
||||
|
||||
void AdcEverySecond(void) {
|
||||
for (uint32_t idx = 0; idx < adc_present; idx++) {
|
||||
for (uint32_t idx = 0; idx < Adcs.present; idx++) {
|
||||
if (ADC_TEMP == Adc[idx].type) {
|
||||
int adc = AdcRead(Adc[idx].pin, 2);
|
||||
// Steinhart-Hart equation for thermistor as temperature sensor
|
||||
double Rt = (adc * Settings.adc_param1) / (1024.0 * ANALOG_V33 - (double)adc);
|
||||
double BC = (double)Settings.adc_param3 / 10000;
|
||||
double T = BC / (BC / ANALOG_T0 + TaylorLog(Rt / (double)Settings.adc_param2));
|
||||
double Rt = (adc * Adc[idx].param1) / (1024.0 * ANALOG_V33 - (double)adc);
|
||||
double BC = (double)Adc[idx].param3 / 10000;
|
||||
double T = BC / (BC / ANALOG_T0 + TaylorLog(Rt / (double)Adc[idx].param2));
|
||||
Adc[idx].temperature = ConvertTemp(TO_CELSIUS(T));
|
||||
}
|
||||
else if (ADC_CT_POWER == Adc[idx].type) {
|
||||
|
@ -286,7 +308,7 @@ void AdcEverySecond(void) {
|
|||
void AdcShow(bool json) {
|
||||
bool domo_flag[ADC_END] = { false };
|
||||
char adc_name[10]; // ANALOG12
|
||||
for (uint32_t idx = 0; idx < adc_present; idx++) {
|
||||
for (uint32_t idx = 0; idx < Adcs.present; idx++) {
|
||||
snprintf_P(adc_name, sizeof(adc_name), PSTR("ANALOG%d"), idx);
|
||||
|
||||
switch (Adc[idx].type) {
|
||||
|
@ -325,7 +347,7 @@ void AdcShow(bool json) {
|
|||
break;
|
||||
}
|
||||
case ADC_LIGHT: {
|
||||
uint16_t adc_light = AdcGetLux(Adc[idx].pin);
|
||||
uint16_t adc_light = AdcGetLux(idx);
|
||||
|
||||
if (json) {
|
||||
ResponseAppend_P(JSON_SNS_ILLUMINANCE, adc_name, adc_light);
|
||||
|
@ -343,7 +365,7 @@ void AdcShow(bool json) {
|
|||
break;
|
||||
}
|
||||
case ADC_RANGE: {
|
||||
uint16_t adc_range = AdcGetRange(Adc[idx].pin);
|
||||
uint16_t adc_range = AdcGetRange(idx);
|
||||
|
||||
if (json) {
|
||||
ResponseAppend_P(JSON_SNS_RANGE, adc_name, adc_range);
|
||||
|
@ -357,7 +379,7 @@ void AdcShow(bool json) {
|
|||
case ADC_CT_POWER: {
|
||||
AdcGetCurrentPower(idx, 5);
|
||||
|
||||
float voltage = (float)(Settings.adc_param3) / 10;
|
||||
float voltage = (float)(Adc[idx].param3) / 10;
|
||||
char voltage_chr[FLOATSZ];
|
||||
dtostrfd(voltage, Settings.flag2.voltage_resolution, voltage_chr);
|
||||
char current_chr[FLOATSZ];
|
||||
|
@ -403,60 +425,70 @@ void (* const AdcCommand[])(void) PROGMEM = {
|
|||
&CmndAdcParam };
|
||||
|
||||
void CmndAdcParam(void) {
|
||||
if (XdrvMailbox.data_len) {
|
||||
if ((ADC_TEMP == XdrvMailbox.payload) ||
|
||||
(ADC_LIGHT == XdrvMailbox.payload) ||
|
||||
(ADC_RANGE == XdrvMailbox.payload) ||
|
||||
(ADC_CT_POWER == XdrvMailbox.payload)) {
|
||||
if (strstr(XdrvMailbox.data, ",") != nullptr) { // Process parameter entry
|
||||
char sub_string[XdrvMailbox.data_len +1];
|
||||
// AdcParam 2, 32000, 10000, 3350
|
||||
// AdcParam 3, 10000, 12518931, -1.405
|
||||
// AdcParam 6, 0, 1023, 0, 100
|
||||
Settings.adc_param_type = XdrvMailbox.payload;
|
||||
Settings.adc_param1 = strtol(subStr(sub_string, XdrvMailbox.data, ",", 2), nullptr, 10);
|
||||
Settings.adc_param2 = strtol(subStr(sub_string, XdrvMailbox.data, ",", 3), nullptr, 10);
|
||||
if (ADC_RANGE == XdrvMailbox.payload) {
|
||||
Settings.adc_param3 = abs(strtol(subStr(sub_string, XdrvMailbox.data, ",", 4), nullptr, 10));
|
||||
Settings.adc_param4 = abs(strtol(subStr(sub_string, XdrvMailbox.data, ",", 5), nullptr, 10));
|
||||
} else {
|
||||
Settings.adc_param3 = (int)(CharToFloat(subStr(sub_string, XdrvMailbox.data, ",", 4)) * 10000);
|
||||
}
|
||||
if (ADC_CT_POWER == XdrvMailbox.payload) {
|
||||
if (((1 == Settings.adc_param1) & CT_FLAG_ENERGY_RESET) > 0) {
|
||||
for (uint32_t idx = 0; idx < MAX_ADCS; idx++) {
|
||||
Adc[idx].energy = 0;
|
||||
}
|
||||
Settings.adc_param1 ^= CT_FLAG_ENERGY_RESET; // Cancel energy reset flag
|
||||
if ((XdrvMailbox.index > 0) && (XdrvMailbox.index <= MAX_ADCS)) {
|
||||
uint8_t idx = XdrvMailbox.index -1;
|
||||
if (XdrvMailbox.data_len) {
|
||||
if ((ADC_TEMP == XdrvMailbox.payload) ||
|
||||
(ADC_LIGHT == XdrvMailbox.payload) ||
|
||||
(ADC_RANGE == XdrvMailbox.payload) ||
|
||||
(ADC_CT_POWER == XdrvMailbox.payload) ||
|
||||
(ADC_JOY == XdrvMailbox.payload)) {
|
||||
AdcGetSettings(idx);
|
||||
if (ChrCount(XdrvMailbox.data, ",") > 2) { // Process parameter entry
|
||||
char sub_string[XdrvMailbox.data_len +1];
|
||||
// AdcParam 2, 32000, 10000, 3350
|
||||
// AdcParam 3, 10000, 12518931, -1.405
|
||||
// AdcParam 6, 0, ANALOG_RANGE, 0, 100
|
||||
// AdcParam 7, 0, 2146, 0.23
|
||||
// AdcParam 8, 1000, 0, 0
|
||||
Adc[idx].type = XdrvMailbox.payload;
|
||||
Adc[idx].param1 = strtol(subStr(sub_string, XdrvMailbox.data, ",", 2), nullptr, 10);
|
||||
Adc[idx].param2 = strtol(subStr(sub_string, XdrvMailbox.data, ",", 3), nullptr, 10);
|
||||
if (ADC_RANGE == XdrvMailbox.payload) {
|
||||
Adc[idx].param3 = abs(strtol(subStr(sub_string, XdrvMailbox.data, ",", 4), nullptr, 10));
|
||||
Adc[idx].param4 = abs(strtol(subStr(sub_string, XdrvMailbox.data, ",", 5), nullptr, 10));
|
||||
} else {
|
||||
Adc[idx].param3 = (int)(CharToFloat(subStr(sub_string, XdrvMailbox.data, ",", 4)) * 10000);
|
||||
}
|
||||
if (ADC_CT_POWER == XdrvMailbox.payload) {
|
||||
if (((1 == Adc[idx].param1) & CT_FLAG_ENERGY_RESET) > 0) {
|
||||
for (uint32_t idx = 0; idx < MAX_ADCS; idx++) {
|
||||
Adc[idx].energy = 0;
|
||||
}
|
||||
Adc[idx].param1 ^= CT_FLAG_ENERGY_RESET; // Cancel energy reset flag
|
||||
}
|
||||
}
|
||||
} else { // Set default values based on current adc type
|
||||
// AdcParam 2
|
||||
// AdcParam 3
|
||||
// AdcParam 6
|
||||
// AdcParam 7
|
||||
// AdcParam 8
|
||||
Adcs.type = 0;
|
||||
AdcInitParams(idx);
|
||||
}
|
||||
} else { // Set default values based on current adc type
|
||||
// AdcParam 2
|
||||
// AdcParam 3
|
||||
// AdcParam 6
|
||||
// AdcParam 7
|
||||
Settings.adc_param_type = 0;
|
||||
AdcInitParams();
|
||||
AdcSaveSettings(idx);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// AdcParam
|
||||
Response_P(PSTR("{\"" D_CMND_ADCPARAM "\":[%d,%d,%d"), Settings.adc_param_type, Settings.adc_param1, Settings.adc_param2);
|
||||
if (ADC_RANGE == my_adc0) {
|
||||
ResponseAppend_P(PSTR(",%d,%d"), Settings.adc_param3, Settings.adc_param4);
|
||||
} else {
|
||||
int value = Settings.adc_param3;
|
||||
uint8_t precision;
|
||||
for (precision = 4; precision > 0; precision--) {
|
||||
if (value % 10) { break; }
|
||||
value /= 10;
|
||||
// AdcParam
|
||||
AdcGetSettings(idx);
|
||||
Response_P(PSTR("{\"" D_CMND_ADCPARAM "%d\":[%d,%d,%d"), idx +1, Adcs.type, Adc[idx].param1, Adc[idx].param2);
|
||||
if (ADC_RANGE == my_adc0) {
|
||||
ResponseAppend_P(PSTR(",%d,%d"), Adc[idx].param3, Adc[idx].param4);
|
||||
} else {
|
||||
int value = Adc[idx].param3;
|
||||
uint8_t precision;
|
||||
for (precision = 4; precision > 0; precision--) {
|
||||
if (value % 10) { break; }
|
||||
value /= 10;
|
||||
}
|
||||
char param3[33];
|
||||
dtostrfd(((double)Adc[idx].param3)/10000, precision, param3);
|
||||
ResponseAppend_P(PSTR(",%s"), param3);
|
||||
}
|
||||
char param3[33];
|
||||
dtostrfd(((double)Settings.adc_param3)/10000, precision, param3);
|
||||
ResponseAppend_P(PSTR(",%s"), param3);
|
||||
ResponseAppend_P(PSTR("]}"));
|
||||
}
|
||||
ResponseAppend_P(PSTR("]}"));
|
||||
}
|
||||
|
||||
/*********************************************************************************************\
|
||||
|
@ -474,7 +506,7 @@ bool Xsns02(uint8_t function) {
|
|||
AdcInit();
|
||||
break;
|
||||
default:
|
||||
if (adc_present) {
|
||||
if (Adcs.present) {
|
||||
switch (function) {
|
||||
#ifdef USE_RULES
|
||||
case FUNC_EVERY_250_MSECOND:
|
||||
|
|
Loading…
Reference in New Issue