add gateway E32V3, autodetect by gpio39 core voltage

This commit is contained in:
MichaelDvP
2025-07-23 18:47:33 +02:00
parent bee703eb1f
commit c537d0ab8b
10 changed files with 66 additions and 14 deletions

View File

@@ -259,6 +259,7 @@ export const BOARD_PROFILES: BoardProfiles = {
S32S3: 'BBQKees Gateway S3', S32S3: 'BBQKees Gateway S3',
E32: 'BBQKees Gateway E32', E32: 'BBQKees Gateway E32',
E32V2: 'BBQKees Gateway E32 V2', E32V2: 'BBQKees Gateway E32 V2',
E32V3: 'BBQKees Gateway E32 V3',
NODEMCU: 'NodeMCU 32S', NODEMCU: 'NodeMCU 32S',
'MH-ET': 'MH-ET Live D1 Mini', 'MH-ET': 'MH-ET Live D1 Mini',
LOLIN: 'Lolin D32', LOLIN: 'Lolin D32',

View File

@@ -23,7 +23,25 @@ namespace emsesp {
uuid::log::Logger AnalogSensor::logger_{F_(analogsensor), uuid::log::Facility::DAEMON}; uuid::log::Logger AnalogSensor::logger_{F_(analogsensor), uuid::log::Facility::DAEMON};
void AnalogSensor::start() { void AnalogSensor::start(const bool factory_settings) {
// if (factory_settings && EMSESP::nvs_.getString("boot").equals("E32V3") && EMSESP::nvs_.getString("hwrevision").equals("3.0")) {
if (factory_settings && analogReadMilliVolts(35) > 800) { // core voltage > 3V
EMSESP::webCustomizationService.update([&](WebCustomization & settings) {
auto newSensor = AnalogCustomization();
newSensor.gpio = 39;
newSensor.name = "core_voltage";
newSensor.offset = 0;
newSensor.factor = 0.00377136; // Divider 24k - 8,66k
newSensor.uom = DeviceValueUOM::VOLTS;
newSensor.type = AnalogType::ADC;
settings.analogCustomizations.push_back(newSensor);
newSensor.gpio = 36;
newSensor.name = "supply_voltage";
newSensor.factor = 0.017; // Divider 24k - 1,5k
settings.analogCustomizations.push_back(newSensor);
return StateUpdateResult::CHANGED; // persist the change
});
}
reload(true); // fetch the list of sensors from our customization service reload(true); // fetch the list of sensors from our customization service
if (!analog_enabled_) { if (!analog_enabled_) {

View File

@@ -127,7 +127,7 @@ class AnalogSensor {
RGB = 11 RGB = 11
}; };
void start(); void start(const bool factory_settings = false);
void loop(); void loop();
void publish_sensor(const Sensor & sensor) const; void publish_sensor(const Sensor & sensor) const;
void publish_values(const bool force); void publish_values(const bool force);

View File

@@ -302,7 +302,7 @@ static void setup_commands(std::shared_ptr<Commands> const & commands) {
std::vector<int8_t> data; // led, dallas, rx, tx, button, phy_type, eth_power, eth_phy_addr, eth_clock_mode std::vector<int8_t> data; // led, dallas, rx, tx, button, phy_type, eth_power, eth_phy_addr, eth_clock_mode
std::string board_profile = Helpers::toUpper(arguments.front()); std::string board_profile = Helpers::toUpper(arguments.front());
if (!EMSESP::system_.load_board_profile(data, board_profile)) { if (!EMSESP::system_.load_board_profile(data, board_profile)) {
shell.println("Invalid board profile (S32, E32, E32V2, MH-ET, NODEMCU, LOLIN, OLIMEX, OLIMEXPOE, C3MINI, S2MINI, S3MINI, S32S3, CUSTOM)"); shell.println("Invalid board profile (S32, E32, E32V2, E32V3, MH-ET, NODEMCU, LOLIN, OLIMEX, OLIMEXPOE, C3MINI, S2MINI, S3MINI, S32S3, CUSTOM)");
return; return;
} }

View File

@@ -1711,8 +1711,8 @@ void EMSESP::start() {
mqtt_.start(); // mqtt init mqtt_.start(); // mqtt init
system_.start(); // starts commands, led, adc, button, network (sets hostname), syslog & uart system_.start(); // starts commands, led, adc, button, network (sets hostname), syslog & uart
shower_.start(); // initialize shower timer and shower alert shower_.start(); // initialize shower timer and shower alert
temperaturesensor_.start(); // Temperature external sensors temperaturesensor_.start(factory_settings); // Temperature external sensors
analogsensor_.start(); // Analog external sensors analogsensor_.start(factory_settings); // Analog external sensors
// start web services // start web services
webLogService.start(); // apply settings to weblog service webLogService.start(); // apply settings to weblog service

View File

@@ -1877,6 +1877,8 @@ bool System::load_board_profile(std::vector<int8_t> & data, const std::string &
data = {2, 4, 5, 17, 33, PHY_type::PHY_TYPE_LAN8720, 16, 1, 0, 0}; // BBQKees Gateway E32 data = {2, 4, 5, 17, 33, PHY_type::PHY_TYPE_LAN8720, 16, 1, 0, 0}; // BBQKees Gateway E32
} else if (board_profile == "E32V2") { } else if (board_profile == "E32V2") {
data = {2, 14, 4, 5, 34, PHY_type::PHY_TYPE_LAN8720, 15, 0, 1, 0}; // BBQKees Gateway E32 V2 data = {2, 14, 4, 5, 34, PHY_type::PHY_TYPE_LAN8720, 15, 0, 1, 0}; // BBQKees Gateway E32 V2
} else if (board_profile == "E32V3") {
data = {32, 14, 4, 5, 34, PHY_type::PHY_TYPE_LAN8720, 15, 0, 1, 1}; // BBQKees Gateway E32 V3
} else if (board_profile == "MH-ET") { } else if (board_profile == "MH-ET") {
data = {2, 18, 23, 5, 0, PHY_type::PHY_TYPE_NONE, 0, 0, 0, 0}; // MH-ET Live D1 Mini data = {2, 18, 23, 5, 0, PHY_type::PHY_TYPE_NONE, 0, 0, 0, 0}; // MH-ET Live D1 Mini
} else if (board_profile == "NODEMCU") { } else if (board_profile == "NODEMCU") {

View File

@@ -32,7 +32,9 @@ namespace emsesp {
uuid::log::Logger TemperatureSensor::logger_{F_(temperaturesensor), uuid::log::Facility::DAEMON}; uuid::log::Logger TemperatureSensor::logger_{F_(temperaturesensor), uuid::log::Facility::DAEMON};
// start the 1-wire // start the 1-wire
void TemperatureSensor::start() { void TemperatureSensor::start(const bool factory_settings) {
// set_internal_ = factory_settings && EMSESP::nvs_.getString("boot").equals("E32V3") && EMSESP::nvs_.getString("hwrevision").equals("3.0");
set_internal_ = factory_settings && analogReadMilliVolts(35) > 800; // core voltage > 3V
reload(); reload();
if (!dallas_gpio_) { if (!dallas_gpio_) {
@@ -199,6 +201,29 @@ void TemperatureSensor::loop() {
scancnt_ = 0; scancnt_ = 0;
} else if (scancnt_ == SCAN_START + 1) { // startup } else if (scancnt_ == SCAN_START + 1) { // startup
firstscan_ = sensors_.size(); firstscan_ = sensors_.size();
if (firstscan_ > 0 && set_internal_) {
set_internal_ = false;
Sensor * s = &sensors_[0];
if (firstscan_ > 1) {
for (auto s1 : sensors_) {
if (EMSESP::nvs_.getString("intTemp").equals(s1.id().c_str())) {
s = &s1;
}
}
}
s->set_name("gateway_temperature");
if (!EMSESP::nvs_.isKey("intTemp")) {
EMSESP::nvs_.putString("intTemp", s->id().c_str());
}
EMSESP::webCustomizationService.update([&](WebCustomization & settings) {
auto newSensor = SensorCustomization();
newSensor.id = s->id();
newSensor.name = s->name();
newSensor.offset = 0;
settings.sensorCustomizations.push_back(newSensor);
return StateUpdateResult::CHANGED;
});
}
// LOG_DEBUG("Adding %d sensor(s) from first scan", firstscan_); // LOG_DEBUG("Adding %d sensor(s) from first scan", firstscan_);
} else if ((scancnt_ <= 0) && (firstscan_ != sensors_.size())) { // check 2 times for no change of sensor # } else if ((scancnt_ <= 0) && (firstscan_ != sensors_.size())) { // check 2 times for no change of sensor #
scancnt_ = SCAN_START; scancnt_ = SCAN_START;

View File

@@ -77,7 +77,7 @@ class TemperatureSensor {
TemperatureSensor() = default; TemperatureSensor() = default;
~TemperatureSensor() = default; ~TemperatureSensor() = default;
void start(); void start(const bool factory_settings = false);
void loop(); void loop();
void publish_sensor(const Sensor & sensor); void publish_sensor(const Sensor & sensor);
void publish_values(const bool force); void publish_values(const bool force);
@@ -165,11 +165,12 @@ class TemperatureSensor {
int8_t scanretry_ = 0; int8_t scanretry_ = 0;
#endif #endif
uint8_t dallas_gpio_ = 0; uint8_t dallas_gpio_ = 0;
bool parasite_ = false; bool parasite_ = false;
bool changed_ = false; bool changed_ = false;
uint32_t sensorfails_ = 0; uint32_t sensorfails_ = 0;
uint32_t sensorreads_ = 0; uint32_t sensorreads_ = 0;
bool set_internal_ = false;
}; };
} // namespace emsesp } // namespace emsesp

View File

@@ -1 +1 @@
#define EMSESP_APP_VERSION "3.7.3-dev.14" #define EMSESP_APP_VERSION "3.7.3-dev.15"

View File

@@ -179,7 +179,12 @@ StateUpdateResult WebSettings::update(JsonObject root, WebSettings & settings) {
#else #else
if (ETH.begin(ETH_PHY_LAN8720, 0, 23, 18, 15, ETH_CLOCK_GPIO0_OUT)) { if (ETH.begin(ETH_PHY_LAN8720, 0, 23, 18, 15, ETH_CLOCK_GPIO0_OUT)) {
#endif #endif
settings.board_profile = "E32V2"; // Ethernet and PSRAM
if (analogReadMilliVolts(39) > 800) { // core voltage > 3V
settings.board_profile = "E32V3"; // Ethernet, PSRAM, internal sensors
} else {
settings.board_profile = "E32V2"; // Ethernet and PSRAM
}
} else { } else {
settings.board_profile = "S32"; // ESP32 standard WiFi with PSRAM settings.board_profile = "S32"; // ESP32 standard WiFi with PSRAM
} }