Update esp32 arduino and platform versions (#3564)

This commit is contained in:
Jesse Hills 2022-11-21 11:49:30 +13:00 committed by GitHub
parent d874626662
commit c2e198311c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
24 changed files with 256 additions and 327 deletions

View File

@ -85,9 +85,7 @@ bool HOT IRAM_ATTR ESPOneWire::read_bit() {
// whereas on esp-idf it already happens during the pin_mode(OUTPUT)
// manually correct for this with these constants.
#ifdef USE_ESP32_FRAMEWORK_ARDUINO
uint32_t timing_constant = 14;
#elif defined(USE_ESP32_FRAMEWORK_ESP_IDF)
#ifdef USE_ESP32
uint32_t timing_constant = 12;
#else
uint32_t timing_constant = 14;

View File

@ -129,11 +129,11 @@ def _format_framework_espidf_version(ver: cv.Version) -> str:
# The default/recommended arduino framework version
# - https://github.com/espressif/arduino-esp32/releases
# - https://api.registry.platformio.org/v3/packages/platformio/tool/framework-arduinoespressif32
RECOMMENDED_ARDUINO_FRAMEWORK_VERSION = cv.Version(1, 0, 6)
RECOMMENDED_ARDUINO_FRAMEWORK_VERSION = cv.Version(2, 0, 5)
# The platformio/espressif32 version to use for arduino frameworks
# - https://github.com/platformio/platform-espressif32/releases
# - https://api.registry.platformio.org/v3/packages/platformio/platform/espressif32
ARDUINO_PLATFORM_VERSION = cv.Version(3, 5, 0)
ARDUINO_PLATFORM_VERSION = cv.Version(5, 2, 0)
# The default/recommended esp-idf framework version
# - https://github.com/espressif/esp-idf/releases
@ -148,8 +148,8 @@ ESP_IDF_PLATFORM_VERSION = cv.Version(3, 5, 0)
def _arduino_check_versions(value):
value = value.copy()
lookups = {
"dev": (cv.Version(2, 0, 0), "https://github.com/espressif/arduino-esp32.git"),
"latest": (cv.Version(1, 0, 6), None),
"dev": (cv.Version(2, 0, 5), "https://github.com/espressif/arduino-esp32.git"),
"latest": (cv.Version(2, 0, 5), None),
"recommended": (RECOMMENDED_ARDUINO_FRAMEWORK_VERSION, None),
}

View File

@ -1,4 +1,4 @@
from .const import VARIANT_ESP32, VARIANT_ESP32S2, VARIANT_ESP32C3
from .const import VARIANT_ESP32, VARIANT_ESP32S2, VARIANT_ESP32C3, VARIANT_ESP32S3
ESP32_BASE_PINS = {
"TX": 1,
@ -1000,12 +1000,30 @@ done | sort
"""
BOARD_TO_VARIANT = {
"adafruit_feather_esp32s2_tft": VARIANT_ESP32S2,
"adafruit_feather_esp32s3": VARIANT_ESP32S3,
"adafruit_feather_esp32_v2": VARIANT_ESP32,
"adafruit_funhouse_esp32s2": VARIANT_ESP32S2,
"adafruit_magtag29_esp32s2": VARIANT_ESP32S2,
"adafruit_metro_esp32s2": VARIANT_ESP32S2,
"adafruit_qtpy_esp32c3": VARIANT_ESP32C3,
"adafruit_qtpy_esp32s2": VARIANT_ESP32S2,
"adafruit_qtpy_esp32s3": VARIANT_ESP32S3,
"adafruit_qtpy_esp32": VARIANT_ESP32,
"airm2m_core_esp32c3": VARIANT_ESP32C3,
"alksesp32": VARIANT_ESP32,
"atmegazero_esp32s2": VARIANT_ESP32S2,
"az-delivery-devkit-v4": VARIANT_ESP32,
"bpi-bit": VARIANT_ESP32,
"briki_abc_esp32": VARIANT_ESP32,
"briki_mbc-wb_esp32": VARIANT_ESP32,
"d-duino-32": VARIANT_ESP32,
"deneyapkart1A": VARIANT_ESP32,
"deneyapkart": VARIANT_ESP32,
"deneyapmini": VARIANT_ESP32S2,
"denky32": VARIANT_ESP32,
"denky_d4": VARIANT_ESP32,
"dpu_esp32": VARIANT_ESP32,
"esp320": VARIANT_ESP32,
"esp32-c3-devkitm-1": VARIANT_ESP32C3,
"esp32cam": VARIANT_ESP32,
@ -1018,8 +1036,12 @@ BOARD_TO_VARIANT = {
"esp32-poe-iso": VARIANT_ESP32,
"esp32-poe": VARIANT_ESP32,
"esp32-pro": VARIANT_ESP32,
"esp32-s2-franzininho": VARIANT_ESP32S2,
"esp32-s2-kaluga-1": VARIANT_ESP32S2,
"esp32-s2-saola-1": VARIANT_ESP32S2,
"esp32s3box": VARIANT_ESP32S3,
"esp32s3camlcd": VARIANT_ESP32S3,
"esp32-s3-devkitc-1": VARIANT_ESP32S3,
"esp32thing_plus": VARIANT_ESP32,
"esp32thing": VARIANT_ESP32,
"esp32vn-iot-uno": VARIANT_ESP32,
@ -1032,6 +1054,8 @@ BOARD_TO_VARIANT = {
"featheresp32": VARIANT_ESP32,
"firebeetle32": VARIANT_ESP32,
"fm-devkit": VARIANT_ESP32,
"franzininho_wifi_esp32s2": VARIANT_ESP32S2,
"franzininho_wifi_msc_esp32s2": VARIANT_ESP32S2,
"frogboard": VARIANT_ESP32,
"healthypi4": VARIANT_ESP32,
"heltec_wifi_kit_32_v2": VARIANT_ESP32,
@ -1049,13 +1073,17 @@ BOARD_TO_VARIANT = {
"iotaap_magnolia": VARIANT_ESP32,
"iotbusio": VARIANT_ESP32,
"iotbusproteus": VARIANT_ESP32,
"kb32-ft": VARIANT_ESP32,
"kits-edu": VARIANT_ESP32,
"labplus_mpython": VARIANT_ESP32,
"lionbit": VARIANT_ESP32,
"lolin32_lite": VARIANT_ESP32,
"lolin32": VARIANT_ESP32,
"lolin_c3_mini": VARIANT_ESP32C3,
"lolin_d32_pro": VARIANT_ESP32,
"lolin_d32": VARIANT_ESP32,
"lolin_s2_mini": VARIANT_ESP32S2,
"lolin_s2_pico": VARIANT_ESP32S2,
"lopy4": VARIANT_ESP32,
"lopy": VARIANT_ESP32,
"m5stack-atom": VARIANT_ESP32,
@ -1072,6 +1100,7 @@ BOARD_TO_VARIANT = {
"mhetesp32devkit": VARIANT_ESP32,
"mhetesp32minikit": VARIANT_ESP32,
"microduino-core-esp32": VARIANT_ESP32,
"micros2": VARIANT_ESP32S2,
"nano32": VARIANT_ESP32,
"nina_w10": VARIANT_ESP32,
"node32s": VARIANT_ESP32,
@ -1089,8 +1118,13 @@ BOARD_TO_VARIANT = {
"sensesiot_weizen": VARIANT_ESP32,
"sg-o_airMon": VARIANT_ESP32,
"s_odi_ultra": VARIANT_ESP32,
"sparkfun_esp32micromod": VARIANT_ESP32,
"sparkfun_esp32s2_thing_plus": VARIANT_ESP32S2,
"sparkfun_lora_gateway_1-channel": VARIANT_ESP32,
"tinypico": VARIANT_ESP32,
"trueverit-iot-driver-mk2": VARIANT_ESP32,
"trueverit-iot-driver-mk3": VARIANT_ESP32,
"trueverit-iot-driver": VARIANT_ESP32,
"ttgo-lora32-v1": VARIANT_ESP32,
"ttgo-lora32-v21": VARIANT_ESP32,
"ttgo-lora32-v2": VARIANT_ESP32,
@ -1098,13 +1132,26 @@ BOARD_TO_VARIANT = {
"ttgo-t7-v13-mini32": VARIANT_ESP32,
"ttgo-t7-v14-mini32": VARIANT_ESP32,
"ttgo-t-beam": VARIANT_ESP32,
"ttgo-t-oi-plus": VARIANT_ESP32C3,
"ttgo-t-watch": VARIANT_ESP32,
"turta_iot_node": VARIANT_ESP32,
"um_feathers2_neo": VARIANT_ESP32S2,
"um_feathers2": VARIANT_ESP32S2,
"um_feathers3": VARIANT_ESP32S3,
"um_pros3": VARIANT_ESP32S3,
"um_rmp": VARIANT_ESP32S2,
"um_tinys2": VARIANT_ESP32S2,
"um_tinys3": VARIANT_ESP32S3,
"upesy_wroom": VARIANT_ESP32,
"upesy_wrover": VARIANT_ESP32,
"vintlabs-devkit-v1": VARIANT_ESP32,
"watchy": VARIANT_ESP32,
"wemosbat": VARIANT_ESP32,
"wemos_d1_mini32": VARIANT_ESP32,
"wesp32": VARIANT_ESP32,
"widora-air": VARIANT_ESP32,
"wifiduino32": VARIANT_ESP32,
"wipy3": VARIANT_ESP32,
"wt32-eth01": VARIANT_ESP32,
"xinabox_cw02": VARIANT_ESP32,
}

View File

@ -1,6 +1,6 @@
#ifdef USE_ESP32_FRAMEWORK_ESP_IDF
#ifdef USE_ESP32
#include "gpio_idf.h"
#include "gpio.h"
#include "esphome/core/log.h"
namespace esphome {
@ -8,13 +8,11 @@ namespace esp32 {
static const char *const TAG = "esp32";
bool IDFInternalGPIOPin::isr_service_installed = false; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)
bool ESP32InternalGPIOPin::isr_service_installed = false; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)
static gpio_mode_t IRAM_ATTR flags_to_mode(gpio::Flags flags) {
flags = (gpio::Flags)(flags & ~(gpio::FLAG_PULLUP | gpio::FLAG_PULLDOWN));
if (flags == gpio::FLAG_NONE) {
return GPIO_MODE_DISABLE;
} else if (flags == gpio::FLAG_INPUT) {
if (flags == gpio::FLAG_INPUT) {
return GPIO_MODE_INPUT;
} else if (flags == gpio::FLAG_OUTPUT) {
return GPIO_MODE_OUTPUT;
@ -25,7 +23,7 @@ static gpio_mode_t IRAM_ATTR flags_to_mode(gpio::Flags flags) {
} else if (flags == (gpio::FLAG_INPUT | gpio::FLAG_OUTPUT)) {
return GPIO_MODE_INPUT_OUTPUT;
} else {
// unsupported
// unsupported or gpio::FLAG_NONE
return GPIO_MODE_DISABLE;
}
}
@ -35,14 +33,14 @@ struct ISRPinArg {
bool inverted;
};
ISRInternalGPIOPin IDFInternalGPIOPin::to_isr() const {
ISRInternalGPIOPin ESP32InternalGPIOPin::to_isr() const {
auto *arg = new ISRPinArg{}; // NOLINT(cppcoreguidelines-owning-memory)
arg->pin = pin_;
arg->inverted = inverted_;
return ISRInternalGPIOPin((void *) arg);
}
void IDFInternalGPIOPin::attach_interrupt(void (*func)(void *), void *arg, gpio::InterruptType type) const {
void ESP32InternalGPIOPin::attach_interrupt(void (*func)(void *), void *arg, gpio::InterruptType type) const {
gpio_int_type_t idf_type = GPIO_INTR_ANYEDGE;
switch (type) {
case gpio::INTERRUPT_RISING_EDGE:
@ -74,13 +72,13 @@ void IDFInternalGPIOPin::attach_interrupt(void (*func)(void *), void *arg, gpio:
gpio_isr_handler_add(pin_, func, arg);
}
std::string IDFInternalGPIOPin::dump_summary() const {
std::string ESP32InternalGPIOPin::dump_summary() const {
char buffer[32];
snprintf(buffer, sizeof(buffer), "GPIO%u", static_cast<uint32_t>(pin_));
return buffer;
}
void IDFInternalGPIOPin::setup() {
void ESP32InternalGPIOPin::setup() {
gpio_config_t conf{};
conf.pin_bit_mask = 1ULL << static_cast<uint32_t>(pin_);
conf.mode = flags_to_mode(flags_);
@ -91,7 +89,7 @@ void IDFInternalGPIOPin::setup() {
gpio_set_drive_capability(pin_, drive_strength_);
}
void IDFInternalGPIOPin::pin_mode(gpio::Flags flags) {
void ESP32InternalGPIOPin::pin_mode(gpio::Flags flags) {
// can't call gpio_config here because that logs in esp-idf which may cause issues
gpio_set_direction(pin_, flags_to_mode(flags));
gpio_pull_mode_t pull_mode = GPIO_FLOATING;
@ -105,9 +103,9 @@ void IDFInternalGPIOPin::pin_mode(gpio::Flags flags) {
gpio_set_pull_mode(pin_, pull_mode);
}
bool IDFInternalGPIOPin::digital_read() { return bool(gpio_get_level(pin_)) != inverted_; }
void IDFInternalGPIOPin::digital_write(bool value) { gpio_set_level(pin_, value != inverted_ ? 1 : 0); }
void IDFInternalGPIOPin::detach_interrupt() const { gpio_intr_disable(pin_); }
bool ESP32InternalGPIOPin::digital_read() { return bool(gpio_get_level(pin_)) != inverted_; }
void ESP32InternalGPIOPin::digital_write(bool value) { gpio_set_level(pin_, value != inverted_ ? 1 : 0); }
void ESP32InternalGPIOPin::detach_interrupt() const { gpio_intr_disable(pin_); }
} // namespace esp32
@ -140,4 +138,4 @@ void IRAM_ATTR ISRInternalGPIOPin::pin_mode(gpio::Flags flags) {
} // namespace esphome
#endif // USE_ESP32_FRAMEWORK_ESP_IDF
#endif // USE_ESP32

View File

@ -1,13 +1,13 @@
#pragma once
#ifdef USE_ESP32_FRAMEWORK_ESP_IDF
#ifdef USE_ESP32
#include "esphome/core/hal.h"
#include <driver/gpio.h>
namespace esphome {
namespace esp32 {
class IDFInternalGPIOPin : public InternalGPIOPin {
class ESP32InternalGPIOPin : public InternalGPIOPin {
public:
void set_pin(gpio_num_t pin) { pin_ = pin; }
void set_inverted(bool inverted) { inverted_ = inverted; }
@ -37,4 +37,4 @@ class IDFInternalGPIOPin : public InternalGPIOPin {
} // namespace esp32
} // namespace esphome
#endif // USE_ESP32_FRAMEWORK_ESP_IDF
#endif // USE_ESP32

View File

@ -38,8 +38,7 @@ from .gpio_esp32_s3 import esp32_s3_validate_gpio_pin, esp32_s3_validate_support
from .gpio_esp32_h2 import esp32_h2_validate_gpio_pin, esp32_h2_validate_supports
IDFInternalGPIOPin = esp32_ns.class_("IDFInternalGPIOPin", cg.InternalGPIOPin)
ArduinoInternalGPIOPin = esp32_ns.class_("ArduinoInternalGPIOPin", cg.InternalGPIOPin)
ESP32InternalGPIOPin = esp32_ns.class_("ESP32InternalGPIOPin", cg.InternalGPIOPin)
def _lookup_pin(value):
@ -169,18 +168,10 @@ DRIVE_STRENGTHS = {
gpio_num_t = cg.global_ns.enum("gpio_num_t")
def _choose_pin_declaration(value):
if CORE.using_esp_idf:
return cv.declare_id(IDFInternalGPIOPin)(value)
if CORE.using_arduino:
return cv.declare_id(ArduinoInternalGPIOPin)(value)
raise NotImplementedError
CONF_DRIVE_STRENGTH = "drive_strength"
ESP32_PIN_SCHEMA = cv.All(
{
cv.GenerateID(): _choose_pin_declaration,
cv.GenerateID(): cv.declare_id(ESP32InternalGPIOPin),
cv.Required(CONF_NUMBER): validate_gpio_pin,
cv.Optional(CONF_MODE, default={}): cv.Schema(
{
@ -192,8 +183,7 @@ ESP32_PIN_SCHEMA = cv.All(
}
),
cv.Optional(CONF_INVERTED, default=False): cv.boolean,
cv.SplitDefault(CONF_DRIVE_STRENGTH, esp32_idf="20mA"): cv.All(
cv.only_with_esp_idf,
cv.Optional(CONF_DRIVE_STRENGTH, default="20mA"): cv.All(
cv.float_with_unit("current", "mA", optional_unit=True),
cv.enum(DRIVE_STRENGTHS),
),
@ -206,10 +196,7 @@ ESP32_PIN_SCHEMA = cv.All(
async def esp32_pin_to_code(config):
var = cg.new_Pvariable(config[CONF_ID])
num = config[CONF_NUMBER]
if CORE.using_esp_idf:
cg.add(var.set_pin(getattr(gpio_num_t, f"GPIO_NUM_{num}")))
else:
cg.add(var.set_pin(num))
cg.add(var.set_pin(getattr(gpio_num_t, f"GPIO_NUM_{num}")))
cg.add(var.set_inverted(config[CONF_INVERTED]))
if CONF_DRIVE_STRENGTH in config:
cg.add(var.set_drive_strength(config[CONF_DRIVE_STRENGTH]))

View File

@ -1,114 +0,0 @@
#ifdef USE_ESP32_FRAMEWORK_ARDUINO
#include "gpio_arduino.h"
#include "esphome/core/log.h"
#include <esp32-hal-gpio.h>
namespace esphome {
namespace esp32 {
static const char *const TAG = "esp32";
static int IRAM_ATTR flags_to_mode(gpio::Flags flags) {
if (flags == gpio::FLAG_INPUT) {
return INPUT;
} else if (flags == gpio::FLAG_OUTPUT) {
return OUTPUT;
} else if (flags == (gpio::FLAG_INPUT | gpio::FLAG_PULLUP)) {
return INPUT_PULLUP;
} else if (flags == (gpio::FLAG_INPUT | gpio::FLAG_PULLDOWN)) {
return INPUT_PULLDOWN;
} else if (flags == (gpio::FLAG_OUTPUT | gpio::FLAG_OPEN_DRAIN)) {
return OUTPUT_OPEN_DRAIN;
} else {
return 0;
}
}
struct ISRPinArg {
uint8_t pin;
bool inverted;
};
ISRInternalGPIOPin ArduinoInternalGPIOPin::to_isr() const {
auto *arg = new ISRPinArg{}; // NOLINT(cppcoreguidelines-owning-memory)
arg->pin = pin_;
arg->inverted = inverted_;
return ISRInternalGPIOPin((void *) arg);
}
void ArduinoInternalGPIOPin::attach_interrupt(void (*func)(void *), void *arg, gpio::InterruptType type) const {
uint8_t arduino_mode = DISABLED;
switch (type) {
case gpio::INTERRUPT_RISING_EDGE:
arduino_mode = inverted_ ? FALLING : RISING;
break;
case gpio::INTERRUPT_FALLING_EDGE:
arduino_mode = inverted_ ? RISING : FALLING;
break;
case gpio::INTERRUPT_ANY_EDGE:
arduino_mode = CHANGE;
break;
case gpio::INTERRUPT_LOW_LEVEL:
arduino_mode = inverted_ ? ONHIGH : ONLOW;
break;
case gpio::INTERRUPT_HIGH_LEVEL:
arduino_mode = inverted_ ? ONLOW : ONHIGH;
break;
}
attachInterruptArg(pin_, func, arg, arduino_mode);
}
void ArduinoInternalGPIOPin::pin_mode(gpio::Flags flags) {
pinMode(pin_, flags_to_mode(flags)); // NOLINT
}
std::string ArduinoInternalGPIOPin::dump_summary() const {
char buffer[32];
snprintf(buffer, sizeof(buffer), "GPIO%u", pin_);
return buffer;
}
bool ArduinoInternalGPIOPin::digital_read() {
return bool(digitalRead(pin_)) != inverted_; // NOLINT
}
void ArduinoInternalGPIOPin::digital_write(bool value) {
digitalWrite(pin_, value != inverted_ ? 1 : 0); // NOLINT
}
void ArduinoInternalGPIOPin::detach_interrupt() const {
detachInterrupt(pin_); // NOLINT
}
} // namespace esp32
using namespace esp32;
bool IRAM_ATTR ISRInternalGPIOPin::digital_read() {
auto *arg = reinterpret_cast<ISRPinArg *>(arg_);
return bool(digitalRead(arg->pin)) != arg->inverted; // NOLINT
}
void IRAM_ATTR ISRInternalGPIOPin::digital_write(bool value) {
auto *arg = reinterpret_cast<ISRPinArg *>(arg_);
digitalWrite(arg->pin, value != arg->inverted ? 1 : 0); // NOLINT
}
void IRAM_ATTR ISRInternalGPIOPin::clear_interrupt() {
auto *arg = reinterpret_cast<ISRPinArg *>(arg_);
#ifdef CONFIG_IDF_TARGET_ESP32C3
GPIO.status_w1tc.val = 1UL << arg->pin;
#else
if (arg->pin < 32) {
GPIO.status_w1tc = 1UL << arg->pin;
} else {
GPIO.status1_w1tc.intr_st = 1UL << (arg->pin - 32);
}
#endif
}
void IRAM_ATTR ISRInternalGPIOPin::pin_mode(gpio::Flags flags) {
auto *arg = reinterpret_cast<ISRPinArg *>(arg_);
pinMode(arg->pin, flags_to_mode(flags)); // NOLINT
}
} // namespace esphome
#endif // USE_ESP32_FRAMEWORK_ARDUINO

View File

@ -1,36 +0,0 @@
#pragma once
#ifdef USE_ESP32_FRAMEWORK_ARDUINO
#include "esphome/core/hal.h"
namespace esphome {
namespace esp32 {
class ArduinoInternalGPIOPin : public InternalGPIOPin {
public:
void set_pin(uint8_t pin) { pin_ = pin; }
void set_inverted(bool inverted) { inverted_ = inverted; }
void set_flags(gpio::Flags flags) { flags_ = flags; }
void setup() override { pin_mode(flags_); }
void pin_mode(gpio::Flags flags) override;
bool digital_read() override;
void digital_write(bool value) override;
std::string dump_summary() const override;
void detach_interrupt() const override;
ISRInternalGPIOPin to_isr() const override;
uint8_t get_pin() const override { return pin_; }
bool is_inverted() const override { return inverted_; }
protected:
void attach_interrupt(void (*func)(void *), void *arg, gpio::InterruptType type) const override;
uint8_t pin_;
bool inverted_;
gpio::Flags flags_;
};
} // namespace esp32
} // namespace esphome
#endif // USE_ESP32_FRAMEWORK_ARDUINO

View File

@ -54,7 +54,7 @@ void ESP32Camera::dump_config() {
ESP_LOGCONFIG(TAG, " HREF Pin: %d", conf.pin_href);
ESP_LOGCONFIG(TAG, " Pixel Clock Pin: %d", conf.pin_pclk);
ESP_LOGCONFIG(TAG, " External Clock: Pin:%d Frequency:%u", conf.pin_xclk, conf.xclk_freq_hz);
ESP_LOGCONFIG(TAG, " I2C Pins: SDA:%d SCL:%d", conf.pin_sscb_sda, conf.pin_sscb_scl);
ESP_LOGCONFIG(TAG, " I2C Pins: SDA:%d SCL:%d", conf.pin_sccb_sda, conf.pin_sccb_scl);
ESP_LOGCONFIG(TAG, " Reset Pin: %d", conf.pin_reset);
switch (this->config_.frame_size) {
case FRAMESIZE_QQVGA:
@ -209,8 +209,8 @@ void ESP32Camera::set_external_clock(uint8_t pin, uint32_t frequency) {
this->config_.xclk_freq_hz = frequency;
}
void ESP32Camera::set_i2c_pins(uint8_t sda, uint8_t scl) {
this->config_.pin_sscb_sda = sda;
this->config_.pin_sscb_scl = scl;
this->config_.pin_sccb_sda = sda;
this->config_.pin_sccb_scl = scl;
}
void ESP32Camera::set_reset_pin(uint8_t pin) { this->config_.pin_reset = pin; }
void ESP32Camera::set_power_down_pin(uint8_t pin) { this->config_.pin_pwdn = pin; }

View File

@ -30,16 +30,17 @@ CONF_POWER_PIN = "power_pin"
EthernetType = ethernet_ns.enum("EthernetType")
ETHERNET_TYPES = {
"LAN8720": EthernetType.ETHERNET_TYPE_LAN8720,
"TLK110": EthernetType.ETHERNET_TYPE_TLK110,
"RTL8201": EthernetType.ETHERNET_TYPE_RTL8201,
"DP83848": EthernetType.ETHERNET_TYPE_DP83848,
"IP101": EthernetType.ETHERNET_TYPE_IP101,
}
eth_clock_mode_t = cg.global_ns.enum("eth_clock_mode_t")
emac_rmii_clock_gpio_t = cg.global_ns.enum("emac_rmii_clock_gpio_t")
CLK_MODES = {
"GPIO0_IN": eth_clock_mode_t.ETH_CLOCK_GPIO0_IN,
"GPIO0_OUT": eth_clock_mode_t.ETH_CLOCK_GPIO0_OUT,
"GPIO16_OUT": eth_clock_mode_t.ETH_CLOCK_GPIO16_OUT,
"GPIO17_OUT": eth_clock_mode_t.ETH_CLOCK_GPIO17_OUT,
"GPIO0_IN": emac_rmii_clock_gpio_t.EMAC_CLK_IN_GPIO,
"GPIO0_OUT": emac_rmii_clock_gpio_t.EMAC_APPL_CLK_OUT_GPIO,
"GPIO16_OUT": emac_rmii_clock_gpio_t.EMAC_CLK_OUT_GPIO,
"GPIO17_OUT": emac_rmii_clock_gpio_t.EMAC_CLK_OUT_180_GPIO,
}
@ -125,5 +126,5 @@ async def to_code(config):
cg.add_define("USE_ETHERNET")
if CORE.is_esp32:
if CORE.using_arduino:
cg.add_library("WiFi", None)

View File

@ -5,19 +5,8 @@
#ifdef USE_ESP32_FRAMEWORK_ARDUINO
#include <eth_phy/phy_lan8720.h>
#include <eth_phy/phy_ip101.h>
#include <eth_phy/phy_tlk110.h>
#include <lwip/dns.h>
/// Macro for IDF version comparison
#ifndef ESP_IDF_VERSION_VAL
#define ESP_IDF_VERSION_VAL(major, minor, patch) (((major) << 16) | ((minor) << 8) | (patch))
#endif
// Defined in WiFiGeneric.cpp, sets global initialized flag, starts network event task queue and calls
// tcpip_adapter_init()
extern void tcpipInit(); // NOLINT(readability-identifier-naming)
#include "esp_event.h"
namespace esphome {
namespace ethernet {
@ -37,25 +26,51 @@ EthernetComponent::EthernetComponent() { global_eth_component = this; }
void EthernetComponent::setup() {
ESP_LOGCONFIG(TAG, "Setting up Ethernet...");
auto f = std::bind(&EthernetComponent::on_wifi_event_, this, std::placeholders::_1, std::placeholders::_2);
WiFi.onEvent(f);
// Delay here to allow power to stabilise before Ethernet is initialised.
delay(300); // NOLINT
if (this->power_pin_ != nullptr) {
this->power_pin_->setup();
}
esp_err_t err;
err = esp_netif_init();
ESPHL_ERROR_CHECK(err, "ETH netif init error");
err = esp_event_loop_create_default();
ESPHL_ERROR_CHECK(err, "ETH event loop error");
esp_netif_config_t cfg = ESP_NETIF_DEFAULT_ETH();
this->eth_netif_ = esp_netif_new(&cfg);
// Init MAC and PHY configs to default
eth_mac_config_t mac_config = ETH_MAC_DEFAULT_CONFIG();
eth_phy_config_t phy_config = ETH_PHY_DEFAULT_CONFIG();
phy_config.phy_addr = this->phy_addr_;
mac_config.smi_mdc_gpio_num = this->mdc_pin_;
mac_config.smi_mdio_gpio_num = this->mdio_pin_;
mac_config.clock_config.rmii.clock_mode = this->clk_mode_ == EMAC_CLK_IN_GPIO ? EMAC_CLK_EXT_IN : EMAC_CLK_OUT;
mac_config.clock_config.rmii.clock_gpio = this->clk_mode_;
esp_eth_mac_t *mac = esp_eth_mac_new_esp32(&mac_config);
esp_eth_phy_t *phy;
switch (this->type_) {
case ETHERNET_TYPE_LAN8720: {
memcpy(&this->eth_config_, &phy_lan8720_default_ethernet_config, sizeof(eth_config_t));
phy = esp_eth_phy_new_lan87xx(&phy_config);
break;
}
case ETHERNET_TYPE_TLK110: {
memcpy(&this->eth_config_, &phy_tlk110_default_ethernet_config, sizeof(eth_config_t));
case ETHERNET_TYPE_RTL8201: {
phy = esp_eth_phy_new_rtl8201(&phy_config);
break;
}
case ETHERNET_TYPE_DP83848: {
phy = esp_eth_phy_new_dp83848(&phy_config);
break;
}
case ETHERNET_TYPE_IP101: {
memcpy(&this->eth_config_, &phy_ip101_default_ethernet_config, sizeof(eth_config_t));
phy = esp_eth_phy_new_ip101(&phy_config);
break;
}
default: {
@ -64,23 +79,28 @@ void EthernetComponent::setup() {
}
}
this->eth_config_.phy_addr = static_cast<eth_phy_base_t>(this->phy_addr_);
this->eth_config_.clock_mode = this->clk_mode_;
this->eth_config_.gpio_config = EthernetComponent::eth_phy_config_gpio;
this->eth_config_.tcpip_input = tcpip_adapter_eth_input;
esp_eth_config_t eth_config = ETH_DEFAULT_CONFIG(mac, phy);
this->eth_handle_ = nullptr;
err = esp_eth_driver_install(&eth_config, &this->eth_handle_);
ESPHL_ERROR_CHECK(err, "ETH driver install error");
/* attach Ethernet driver to TCP/IP stack */
err = esp_netif_attach(this->eth_netif_, esp_eth_new_netif_glue(this->eth_handle_));
ESPHL_ERROR_CHECK(err, "ETH netif attach error");
// Register user defined event handers
err = esp_event_handler_register(ETH_EVENT, ESP_EVENT_ANY_ID, &EthernetComponent::eth_event_handler, nullptr);
ESPHL_ERROR_CHECK(err, "ETH event handler register error");
err = esp_event_handler_register(IP_EVENT, IP_EVENT_ETH_GOT_IP, &EthernetComponent::got_ip_event_handler, nullptr);
ESPHL_ERROR_CHECK(err, "GOT IP event handler register error");
/* start Ethernet driver state machine */
err = esp_eth_start(this->eth_handle_);
ESPHL_ERROR_CHECK(err, "ETH start error");
if (this->power_pin_ != nullptr) {
this->orig_power_enable_fun_ = this->eth_config_.phy_power_enable;
this->eth_config_.phy_power_enable = EthernetComponent::eth_phy_power_enable;
this->orig_power_control_fun_ = phy->pwrctl;
phy->pwrctl = EthernetComponent::eth_phy_power_control;
}
tcpipInit();
esp_err_t err;
err = esp_eth_init(&this->eth_config_);
ESPHL_ERROR_CHECK(err, "ETH init error");
err = esp_eth_enable();
ESPHL_ERROR_CHECK(err, "ETH enable error");
}
void EthernetComponent::loop() {
@ -130,8 +150,12 @@ void EthernetComponent::dump_config() {
eth_type = "LAN8720";
break;
case ETHERNET_TYPE_TLK110:
eth_type = "TLK110";
case ETHERNET_TYPE_RTL8201:
eth_type = "RTL8201";
break;
case ETHERNET_TYPE_DP83848:
eth_type = "DP83848";
break;
case ETHERNET_TYPE_IP101:
@ -156,34 +180,30 @@ float EthernetComponent::get_setup_priority() const { return setup_priority::WIF
bool EthernetComponent::can_proceed() { return this->is_connected(); }
network::IPAddress EthernetComponent::get_ip_address() {
tcpip_adapter_ip_info_t ip;
tcpip_adapter_get_ip_info(TCPIP_ADAPTER_IF_ETH, &ip);
esp_netif_ip_info_t ip;
esp_netif_get_ip_info(this->eth_netif_, &ip);
return {ip.ip.addr};
}
void EthernetComponent::on_wifi_event_(system_event_id_t event, system_event_info_t info) {
void EthernetComponent::eth_event_handler(void *arg, esp_event_base_t event_base, int32_t event, void *event_data) {
const char *event_name;
switch (event) {
case SYSTEM_EVENT_ETH_START:
case ETHERNET_EVENT_START:
event_name = "ETH started";
this->started_ = true;
global_eth_component->started_ = true;
break;
case SYSTEM_EVENT_ETH_STOP:
case ETHERNET_EVENT_STOP:
event_name = "ETH stopped";
this->started_ = false;
this->connected_ = false;
global_eth_component->started_ = false;
global_eth_component->connected_ = false;
break;
case SYSTEM_EVENT_ETH_CONNECTED:
case ETHERNET_EVENT_CONNECTED:
event_name = "ETH connected";
break;
case SYSTEM_EVENT_ETH_DISCONNECTED:
case ETHERNET_EVENT_DISCONNECTED:
event_name = "ETH disconnected";
this->connected_ = false;
break;
case SYSTEM_EVENT_ETH_GOT_IP:
event_name = "ETH Got IP";
this->connected_ = true;
global_eth_component->connected_ = false;
break;
default:
return;
@ -192,17 +212,23 @@ void EthernetComponent::on_wifi_event_(system_event_id_t event, system_event_inf
ESP_LOGV(TAG, "[Ethernet event] %s (num=%d)", event_name, event);
}
void EthernetComponent::got_ip_event_handler(void *arg, esp_event_base_t event_base, int32_t event_id,
void *event_data) {
global_eth_component->connected_ = true;
ESP_LOGV(TAG, "[Ethernet event] ETH Got IP (num=%d)", event_id);
}
void EthernetComponent::start_connect_() {
this->connect_begin_ = millis();
this->status_set_warning();
esp_err_t err;
err = tcpip_adapter_set_hostname(TCPIP_ADAPTER_IF_ETH, App.get_name().c_str());
err = esp_netif_set_hostname(this->eth_netif_, App.get_name().c_str());
if (err != ERR_OK) {
ESP_LOGW(TAG, "tcpip_adapter_set_hostname failed: %s", esp_err_to_name(err));
ESP_LOGW(TAG, "esp_netif_set_hostname failed: %s", esp_err_to_name(err));
}
tcpip_adapter_ip_info_t info;
esp_netif_ip_info_t info;
if (this->manual_ip_.has_value()) {
info.ip.addr = static_cast<uint32_t>(this->manual_ip_->static_ip);
info.gw.addr = static_cast<uint32_t>(this->manual_ip_->gateway);
@ -213,11 +239,19 @@ void EthernetComponent::start_connect_() {
info.netmask.addr = 0;
}
err = tcpip_adapter_dhcpc_stop(TCPIP_ADAPTER_IF_ETH);
if (err != ESP_ERR_TCPIP_ADAPTER_DHCP_ALREADY_STOPPED) {
esp_netif_dhcp_status_t status = ESP_NETIF_DHCP_INIT;
err = esp_netif_dhcpc_get_status(this->eth_netif_, &status);
ESPHL_ERROR_CHECK(err, "DHCPC Get Status Failed!");
ESP_LOGV(TAG, "DHCP Client Status: %d", status);
err = esp_netif_dhcpc_stop(this->eth_netif_);
if (err != ESP_ERR_ESP_NETIF_DHCP_ALREADY_STOPPED) {
ESPHL_ERROR_CHECK(err, "DHCPC stop error");
}
err = tcpip_adapter_set_ip_info(TCPIP_ADAPTER_IF_ETH, &info);
err = esp_netif_set_ip_info(this->eth_netif_, &info);
ESPHL_ERROR_CHECK(err, "DHCPC set IP info error");
if (this->manual_ip_.has_value()) {
@ -234,8 +268,8 @@ void EthernetComponent::start_connect_() {
dns_setserver(1, &d);
}
} else {
err = tcpip_adapter_dhcpc_start(TCPIP_ADAPTER_IF_ETH);
if (err != ESP_ERR_TCPIP_ADAPTER_DHCP_ALREADY_STARTED) {
err = esp_netif_dhcpc_start(this->eth_netif_);
if (err != ESP_ERR_ESP_NETIF_DHCP_ALREADY_STARTED) {
ESPHL_ERROR_CHECK(err, "DHCPC start error");
}
}
@ -243,46 +277,45 @@ void EthernetComponent::start_connect_() {
this->connect_begin_ = millis();
this->status_set_warning();
}
void EthernetComponent::eth_phy_config_gpio() {
phy_rmii_configure_data_interface_pins();
phy_rmii_smi_configure_pins(global_eth_component->mdc_pin_, global_eth_component->mdio_pin_);
}
void EthernetComponent::eth_phy_power_enable(bool enable) {
esp_err_t EthernetComponent::eth_phy_power_control(esp_eth_phy_t *phy, bool enable) {
global_eth_component->power_pin_->digital_write(enable);
// power up takes some time, datasheet says max 300µs
delay(1);
global_eth_component->orig_power_enable_fun_(enable);
return global_eth_component->orig_power_control_fun_(phy, enable);
}
bool EthernetComponent::is_connected() { return this->state_ == EthernetComponentState::CONNECTED; }
void EthernetComponent::dump_connect_params_() {
tcpip_adapter_ip_info_t ip;
tcpip_adapter_get_ip_info(TCPIP_ADAPTER_IF_ETH, &ip);
esp_netif_ip_info_t ip;
esp_netif_get_ip_info(this->eth_netif_, &ip);
ESP_LOGCONFIG(TAG, " IP Address: %s", network::IPAddress(ip.ip.addr).str().c_str());
ESP_LOGCONFIG(TAG, " Hostname: '%s'", App.get_name().c_str());
ESP_LOGCONFIG(TAG, " Subnet: %s", network::IPAddress(ip.netmask.addr).str().c_str());
ESP_LOGCONFIG(TAG, " Gateway: %s", network::IPAddress(ip.gw.addr).str().c_str());
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(3, 3, 4)
const ip_addr_t *dns_ip1 = dns_getserver(0);
const ip_addr_t *dns_ip2 = dns_getserver(1);
#else
ip_addr_t tmp_ip1 = dns_getserver(0);
const ip_addr_t *dns_ip1 = &tmp_ip1;
ip_addr_t tmp_ip2 = dns_getserver(1);
const ip_addr_t *dns_ip2 = &tmp_ip2;
#endif
ESP_LOGCONFIG(TAG, " DNS1: %s", network::IPAddress(dns_ip1->u_addr.ip4.addr).str().c_str());
ESP_LOGCONFIG(TAG, " DNS2: %s", network::IPAddress(dns_ip2->u_addr.ip4.addr).str().c_str());
esp_err_t err;
uint8_t mac[6];
esp_eth_get_mac(mac);
err = esp_eth_ioctl(this->eth_handle_, ETH_CMD_G_MAC_ADDR, &mac);
ESPHL_ERROR_CHECK(err, "ETH_CMD_G_MAC error");
ESP_LOGCONFIG(TAG, " MAC Address: %02X:%02X:%02X:%02X:%02X:%02X", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
ESP_LOGCONFIG(TAG, " Is Full Duplex: %s", YESNO(this->eth_config_.phy_get_duplex_mode()));
ESP_LOGCONFIG(TAG, " Link Up: %s", YESNO(this->eth_config_.phy_check_link()));
ESP_LOGCONFIG(TAG, " Link Speed: %u", this->eth_config_.phy_get_speed_mode() ? 100 : 10);
eth_duplex_t duplex_mode;
err = esp_eth_ioctl(this->eth_handle_, ETH_CMD_G_DUPLEX_MODE, &duplex_mode);
ESPHL_ERROR_CHECK(err, "ETH_CMD_G_DUPLEX_MODE error");
ESP_LOGCONFIG(TAG, " Is Full Duplex: %s", YESNO(duplex_mode == ETH_DUPLEX_FULL));
eth_speed_t speed;
err = esp_eth_ioctl(this->eth_handle_, ETH_CMD_G_SPEED, &speed);
ESPHL_ERROR_CHECK(err, "ETH_CMD_G_SPEED error");
ESP_LOGCONFIG(TAG, " Link Speed: %u", speed == ETH_SPEED_100M ? 100 : 10);
}
void EthernetComponent::set_phy_addr(uint8_t phy_addr) { this->phy_addr_ = phy_addr; }
@ -290,7 +323,7 @@ void EthernetComponent::set_power_pin(GPIOPin *power_pin) { this->power_pin_ = p
void EthernetComponent::set_mdc_pin(uint8_t mdc_pin) { this->mdc_pin_ = mdc_pin; }
void EthernetComponent::set_mdio_pin(uint8_t mdio_pin) { this->mdio_pin_ = mdio_pin; }
void EthernetComponent::set_type(EthernetType type) { this->type_ = type; }
void EthernetComponent::set_clk_mode(eth_clock_mode_t clk_mode) { this->clk_mode_ = clk_mode; }
void EthernetComponent::set_clk_mode(emac_rmii_clock_gpio_t clk_mode) { this->clk_mode_ = clk_mode; }
void EthernetComponent::set_manual_ip(const ManualIP &manual_ip) { this->manual_ip_ = manual_ip; }
std::string EthernetComponent::get_use_address() const {

View File

@ -1,22 +1,22 @@
#pragma once
#ifdef USE_ESP32_FRAMEWORK_ARDUINO
#include "esphome/core/component.h"
#include "esphome/core/hal.h"
#include "esphome/components/network/ip_address.h"
#ifdef USE_ESP32_FRAMEWORK_ARDUINO
#include "esp_eth.h"
#include <esp_wifi.h>
#include <WiFiType.h>
#include <WiFi.h>
#include "esp_eth_mac.h"
#include "esp_netif.h"
namespace esphome {
namespace ethernet {
enum EthernetType {
ETHERNET_TYPE_LAN8720 = 0,
ETHERNET_TYPE_TLK110,
ETHERNET_TYPE_RTL8201,
ETHERNET_TYPE_DP83848,
ETHERNET_TYPE_IP101,
};
@ -49,7 +49,7 @@ class EthernetComponent : public Component {
void set_mdc_pin(uint8_t mdc_pin);
void set_mdio_pin(uint8_t mdio_pin);
void set_type(EthernetType type);
void set_clk_mode(eth_clock_mode_t clk_mode);
void set_clk_mode(emac_rmii_clock_gpio_t clk_mode);
void set_manual_ip(const ManualIP &manual_ip);
network::IPAddress get_ip_address();
@ -57,12 +57,13 @@ class EthernetComponent : public Component {
void set_use_address(const std::string &use_address);
protected:
void on_wifi_event_(system_event_id_t event, system_event_info_t info);
static void eth_event_handler(void *arg, esp_event_base_t event_base, int32_t event_id, void *event_data);
static void got_ip_event_handler(void *arg, esp_event_base_t event_base, int32_t event_id, void *event_data);
void start_connect_();
void dump_connect_params_();
static void eth_phy_config_gpio();
static void eth_phy_power_enable(bool enable);
static esp_err_t eth_phy_power_control(esp_eth_phy_t *phy, bool enable);
std::string use_address_;
uint8_t phy_addr_{0};
@ -70,15 +71,17 @@ class EthernetComponent : public Component {
uint8_t mdc_pin_{23};
uint8_t mdio_pin_{18};
EthernetType type_{ETHERNET_TYPE_LAN8720};
eth_clock_mode_t clk_mode_{ETH_CLOCK_GPIO0_IN};
emac_rmii_clock_gpio_t clk_mode_{EMAC_CLK_IN_GPIO};
optional<ManualIP> manual_ip_{};
bool started_{false};
bool connected_{false};
EthernetComponentState state_{EthernetComponentState::STOPPED};
uint32_t connect_begin_;
eth_config_t eth_config_;
eth_phy_power_enable_func orig_power_enable_fun_;
esp_netif_t *eth_netif_{nullptr};
esp_eth_handle_t eth_handle_;
std::function<esp_err_t(esp_eth_phy_t *, bool)> orig_power_control_fun_;
};
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)

View File

@ -12,9 +12,7 @@ namespace ethernet_info {
class IPAddressEthernetInfo : public PollingComponent, public text_sensor::TextSensor {
public:
void update() override {
tcpip_adapter_ip_info_t tcpip;
tcpip_adapter_get_ip_info(TCPIP_ADAPTER_IF_ETH, &tcpip);
auto ip = tcpip.ip.addr;
auto ip = ethernet::global_eth_component->get_ip_address();
if (ip != this->last_ip_) {
this->last_ip_ = ip;
this->publish_state(network::IPAddress(ip).str());

View File

@ -155,4 +155,5 @@ constexpr stm32_dev_t DEVICES[] = {
} // namespace shelly_dimmer
} // namespace esphome
#endif
#endif // USE_SHD_FIRMWARE_DATA

View File

@ -26,7 +26,7 @@ from esphome.const import (
from esphome.core import HexInt, CORE
DOMAIN = "shelly_dimmer"
DEPENDENCIES = ["sensor", "uart"]
DEPENDENCIES = ["sensor", "uart", "esp8266"]
shelly_dimmer_ns = cg.esphome_ns.namespace("shelly_dimmer")
ShellyDimmer = shelly_dimmer_ns.class_(

View File

@ -1,6 +1,8 @@
#include "esphome/core/defines.h"
#include "esphome/core/helpers.h"
#ifdef USE_ESP8266
#include "shelly_dimmer.h"
#ifdef USE_SHD_FIRMWARE_DATA
#include "stm32flash.h"
@ -521,3 +523,5 @@ void ShellyDimmer::reset_dfu_boot_() {
} // namespace shelly_dimmer
} // namespace esphome
#endif // USE_ESP8266

View File

@ -1,5 +1,7 @@
#pragma once
#ifdef USE_ESP8266
#include "esphome/core/component.h"
#include "esphome/core/log.h"
#include "esphome/components/light/light_output.h"
@ -115,3 +117,5 @@ class ShellyDimmer : public PollingComponent, public light::LightOutput, public
} // namespace shelly_dimmer
} // namespace esphome
#endif // USE_ESP8266

View File

@ -1061,4 +1061,5 @@ stm32_err_t stm32_crc_wrapper(const stm32_unique_ptr &stm, uint32_t address, uin
} // namespace shelly_dimmer
} // namespace esphome
#endif
#endif // USE_SHD_FIRMWARE_DATA

View File

@ -266,8 +266,7 @@ bool WiFiComponent::wifi_sta_connect_(const WiFiAP &ap) {
ESP_LOGV(TAG, "esp_wifi_sta_wpa2_ent_set_password failed! %d", err);
}
}
esp_wpa2_config_t wpa2_config = WPA2_CONFIG_INIT_DEFAULT();
err = esp_wifi_sta_wpa2_ent_enable(&wpa2_config);
err = esp_wifi_sta_wpa2_ent_enable();
if (err != ESP_OK) {
ESP_LOGV(TAG, "esp_wifi_sta_wpa2_ent_enable failed! %d", err);
}

View File

@ -68,19 +68,19 @@
#define USE_ESP32_BLE_CLIENT
#define USE_ESP32_BLE_SERVER
#define USE_ESP32_CAMERA
#define USE_ESP32_IGNORE_EFUSE_MAC_CRC
#define USE_IMPROV
#define USE_SOCKET_IMPL_BSD_SOCKETS
#define USE_WIFI_11KV_SUPPORT
#define USE_BLUETOOTH_PROXY
#ifdef USE_ARDUINO
#define USE_ARDUINO_VERSION_CODE VERSION_CODE(1, 0, 6)
#define USE_ARDUINO_VERSION_CODE VERSION_CODE(2, 0, 5)
#define USE_ETHERNET
#endif
#ifdef USE_ESP_IDF
#define USE_ARDUINO_VERSION_CODE VERSION_CODE(4, 3, 0)
#define USE_ESP32_IGNORE_EFUSE_MAC_CRC
#endif
#endif
@ -91,15 +91,16 @@
#define USE_ESP8266_PREFERENCES_FLASH
#define USE_HTTP_REQUEST_ESP8266_HTTPS
#define USE_SOCKET_IMPL_LWIP_TCP
#endif
// Disabled feature flags
//#define USE_BSEC // Requires a library with proprietary license.
#define USE_DASHBOARD_IMPORT
// Dummy firmware payload for shelly_dimmer
#define USE_SHD_FIRMWARE_MAJOR_VERSION 56
#define USE_SHD_FIRMWARE_MINOR_VERSION 5
#define USE_SHD_FIRMWARE_DATA \
{}
#endif
// Disabled feature flags
//#define USE_BSEC // Requires a library with proprietary license.
#define USE_DASHBOARD_IMPORT

View File

@ -103,9 +103,9 @@ extra_scripts = post:esphome/components/esp8266/post_build.py.script
; This are common settings for the ESP32 (all variants) using Arduino.
[common:esp32-arduino]
extends = common:arduino
platform = platformio/espressif32 @ 3.5.0
platform = platformio/espressif32 @ 5.2.0
platform_packages =
platformio/framework-arduinoespressif32 @ ~3.10006.0
platformio/framework-arduinoespressif32 @ ~3.20005.0
framework = arduino
board = nodemcu-32s

View File

@ -82,6 +82,7 @@ def clang_options(idedata):
"-mtext-section-literals",
"-mfix-esp32-psram-cache-issue",
"-mfix-esp32-psram-cache-strategy=memw",
"-fno-tree-switch-conversion",
)
)

View File

@ -1823,18 +1823,6 @@ light:
to: 25
- single_light_id: ${roomname}_lights
- platform: shelly_dimmer
name: Shelly Dimmer Light
power:
name: Shelly Dimmer Power
voltage:
name: Shelly Dimmer Voltage
current:
name: Shelly Dimmer Current
max_brightness: 500
firmware: "51.6"
uart_id: uart0
remote_transmitter:
- pin: 32
carrier_duty_percent: 100%

View File

@ -279,6 +279,10 @@ uart:
tx_pin: GPIO4
rx_pin: GPIO5
baud_rate: 9600
- id: uart11
tx_pin: GPIO4
rx_pin: GPIO5
baud_rate: 9600
modbus:
uart_id: uart1
@ -1358,6 +1362,17 @@ light:
name: Sonoff D1 Dimmer
id: d1_light
restore_mode: RESTORE_DEFAULT_OFF
- platform: shelly_dimmer
name: "Shelly Dimmer Light"
power:
name: "Shelly Dimmer Power"
voltage:
name: "Shelly Dimmer Voltage"
current:
name: "Shelly Dimmer Current"
max_brightness: 500
firmware: "51.6"
uart_id: uart11
servo:
id: my_servo