Na chwile obecną kod wygląda tak:
Code: Select all
// --- GPIO dla konfiguracji / statusu ---
#define STATUS_LED_GPIO 2 // LED na ESP32 Dev Module
#define BUTTON_CFG_RELAY_GPIO 0 // BOOT
// --- SUPLA ---
#include <SuplaDevice.h>
#include <supla/network/esp_wifi.h>
#include <supla/control/button.h>
#include <supla/device/status_led.h>
#include <supla/storage/littlefs_config.h>
#include <supla/network/esp_web_server.h>
#include <supla/network/html/device_info.h>
#include <supla/network/html/protocol_parameters.h>
#include <supla/network/html/status_led_parameters.h>
#include <supla/network/html/wifi_parameters.h>
#include <supla/events.h>
#include <supla/sensor/DS18B20.h>
#include <supla/sensor/rain.h>
#include <supla/sensor/wind.h>
#include <supla/sensor/pressure.h>
#include <supla/channel_element.h>
#include <supla/clock/clock.h>
// --- pamięć trwała ---
#include <supla/storage/eeprom.h>
Supla::Eeprom eeprom;
// --- WiFi (dla RSSI) ---
#include <WiFi.h>
// --- Czujniki I2C / inne ---
#include <Wire.h>
#include "HDC1080.h"
#include "MS5611Sensor.h"
// --- Twoje czujniki ---
#include "LightSensor.h"
#include "RainSensor.h"
#include "Anemometr.h"
#include "WindDirection.h"
#include "SPS30Sensor.h"
#include "VoltageSensor.h"
Supla::ESPWifi wifi;
Supla::LittleFsConfig configSupla;
Supla::Device::StatusLed statusLed(STATUS_LED_GPIO, true);
Supla::EspWebServer suplaServer;
// --- AUTHKEY ---
char AUTHKEY[SUPLA_AUTHKEY_SIZE] = {
0x3F,0x73,0x85,0x54,0x07,0x83,0x34,0x43,
0x09,0x8C,0x3B,0xE6,0x41,0x5F,0x4C,0x7D
};
// --- obiekty globalne ---
Supla::Clock *suplaClock = nullptr;
Supla::Sensor::RainSensor *rainSensor = nullptr;
bool resetOncePerHour = true;
long lastRead = 0;
void setup() {
Serial.begin(115200);
delay(1000);
Serial.println();
Serial.println(F("Startuje stacja pogodowa SUPLA + CONFIG MODE..."));
// --- I2C ---
Wire.begin();
Wire.setClock(100000);
// --- CZUJNIKI ---
new Supla::Sensor::LightSensor();
Supla::Sensor::SPS30_X *sps30 = new Supla::Sensor::SPS30_X();
new Supla::Sensor::SPS30_PM005(sps30);
new Supla::Sensor::SPS30_PM01(sps30);
new Supla::Sensor::SPS30_PM025(sps30);
new Supla::Sensor::SPS30_PM04(sps30);
new Supla::Sensor::SPS30_PM10(sps30);
uint8_t internalTemp[8] = { 0x28, 0x52, 0x29, 0xB5, 0x63, 0x20, 0x01, 0x9B };
uint8_t externalTemp[8] = { 0x28, 0x1C, 0x7F, 0x57, 0x04, 0xE1, 0x3C, 0x56 };
new Supla::Sensor::DS18B20(4, internalTemp);
new Supla::Sensor::DS18B20(4, externalTemp);
new Supla::Sensor::HDC1080();
new Supla::Sensor::MS5611Sensor(248);
rainSensor = new Supla::Sensor::RainSensor(2, 2.5, 300);
new Supla::Sensor::WindDirectionSensor(18, 15);
new Supla::Sensor::Anemometr(15, 1, 0);
// --- Zegar SUPLA ---
suplaClock = new Supla::Clock();
SuplaDevice.addClock(suplaClock);
// --- HTML WWW + PARAMETRY SUPLI ---
new Supla::Html::DeviceInfo(&SuplaDevice);
new Supla::Html::WifiParameters;
new Supla::Html::ProtocolParameters;
new Supla::Html::StatusLedParameters;
new Supla::Control::Button(BUTTON_CFG_RELAY_GPIO, true, true);
// --- TRYB STARTU: CFG MODE (WIFI AP) ---
SuplaDevice.setInitialMode(Supla::InitialMode::StartInCfgMode);
// (opcjonalnie)
// SuplaDevice.setAuthKey(AUTHKEY);
// --- START SUPLI (Tylko raz!!!) ---
SuplaDevice.begin();
Serial.println(F("SuplaDevice.begin() => Tryb konfiguracyjny wystartował."));
}
void loop() {
SuplaDevice.iterate();
// reset licznika opadów raz na godzinę
if (suplaClock) {
int minute = suplaClock->getMin();
if (minute == 0 && resetOncePerHour) {
if (rainSensor) {
rainSensor->setReset(true);
Serial.println(F("Reset licznika opadów (początek godziny)."));
}
resetOncePerHour = false;
}
if (minute == 1) {
resetOncePerHour = true;
}
}
// RSSI co 10 s
if (millis() - lastRead > 10000) {
Serial.print(F("RSSI: "));
Serial.println(WiFi.RSSI());
lastRead = millis();
}
}
Code: Select all
MS5611 getting pres.
Channel(9) value changed to -123.00
Speed: 0.00
RSSI: 0
ets Jun 8 2016 00:22:57
rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0030,len:1344
load:0x40078000,len:13964
load:0x40080400,len:3600
entry 0x400805f0
Startuje stacja pogodowa SUPLA + CONFIG MODE...
Channel[0] initial caption set to 'Natężenie światła'
GPM[0]: DefaultUnitAfterValue "lx"
Channel[1] initial caption set to 'PM 0.5'
GPM[1]: DefaultUnitAfterValue "μg/m³"
GPM[1]: RefreshIntervalMs 60000 ms
LittleFS: writing file 1_gpm_common
GPM[1]: common config saved successfully
GPM[2]: DefaultUnitAfterValue "μg/m³"
Channel[2] initial caption set to 'PM 1.0'
GPM[2]: RefreshIntervalMs 60000 ms
LittleFS: writing file 2_gpm_common
GPM[2]: common config saved successfully
GPM[3]: DefaultUnitAfterValue "μg/m³"
Channel[3] initial caption set to 'PM 2.5'
GPM[3]: RefreshIntervalMs 60000 ms
LittleFS: writing file 3_gpm_common
GPM[3]: common config saved successfully
GPM[4]: DefaultUnitAfterValue "μg/m³"
Channel[4] initial caption set to 'PM 4.0'
GPM[4]: RefreshIntervalMs 60000 ms
LittleFS: writing file 4_gpm_common
GPM[4]: common config saved successfully
GPM[5]: DefaultUnitAfterValue "μg/m³"
Channel[5] initial caption set to 'PM 10.0'
GPM[5]: RefreshIntervalMs 60000 ms
LittleFS: writing file 5_gpm_common
GPM[5]: common config saved successfully
Creating OneWire bus for pin: 4
Initializing OneWire bus at pin 4
OneWire(pin 4) Parasite power is OFF
OneWire(pin 4) Found 0 devices:
Channel(9) value changed to -1.00
Channel(10) value changed to -1.00
Channel(12) value changed to -1
addClock: DEPRECATED
SD: initial mode: Start in cfg mode (legacy, deprected)
*** Supla - starting initialization (platform 0)
SD: add flag DEVICE_CONFIG_SUPPORTED
SD: add flag CALCFG_RESTART_DEVICE
Storage initialization
readStorage: 8; Read: [53 55 50 4C 41 1 0 1 ]
Storage: Number of sections 1
Reading section: 0
readStorage: 7; Read: [3 0 0 FF FF FF FF ]
Section type: 3; size: 0
storedCRC 65535, CRC calc 65535
LittleFsConfig: init called on non empty database. Aborting
*** Supla - Config initalization
SD: add flag CALCFG_ENTER_CFG_MODE
SD: add flag CALCFG_FACTORY_RESET_SUPPORTED
LittleFsConfig: writing to file "/supla-dev.cfg"
LittleFsConfig: writing to file "/supla-dev.cfg.bak"
Successfully generated GUID and AuthKey
New AuthKey: E485BDADB66AD5269688CE8836B734F4
Automatic firmware update is disabled
Device mode: 0
Config incomplete: missing Wi-Fi SSID
LAST STATE ADDED: Missing Wi-Fi SSID
Config incomplete: missing Wi-Fi password
LAST STATE ADDED: Missing Wi-Fi password
Config incomplete: missing server
Config incomplete: missing email
Security level: Supla CA
*** Supla - Config load for elements
SD: add flag CALCFG_IDENTIFY_DEVICE
RemoteDeviceConfig: Registering field 0x000000001
GPM[0]: config loaded successfully
GPM[0]: RefreshIntervalMs 5000 ms
GPM[1]: config loaded successfully
GPM[1]: RefreshIntervalMs 60000 ms
Channel[1] config changed offline flag is set
GPM[2]: config loaded successfully
GPM[2]: RefreshIntervalMs 60000 ms
Channel[2] config changed offline flag is set
GPM[3]: config loaded successfully
GPM[3]: RefreshIntervalMs 60000 ms
Channel[3] config changed offline flag is set
GPM[4]: config loaded successfully
GPM[4]: RefreshIntervalMs 60000 ms
Channel[4] config changed offline flag is set
GPM[5]: config loaded successfully
GPM[5]: RefreshIntervalMs 60000 ms
Channel[5] config changed offline flag is set
Channel[6] temperature correction 0.00
Channel[6] humidity correction 0.00
Channel[7] temperature correction 0.00
Channel[7] humidity correction 0.00
Channel[8] temperature correction 0.00
Channel[8] humidity correction 0.00
RemoteDeviceConfig: Registering field 0x000000010
Clock: automaticTimeSync: 1
Button[0] enabling IN as config button
*** Supla - Config load for elements done
*** Supla - Load state storage
Validating storage state section with current device configuration
Storage state section validation successful
*** Supla - Load state storage done
*** Supla - Init elements
Turning ON SPS sensor
Channel(1) value changed to 1.96
Channel(3) value changed to 1.96
Channel(5) value changed to 2147483647.47
Channel(6) value changed to -275.00
Channel(7) value changed to -275.00
Channel(8) value changed to temp(-275.00), humi(-1.00)
MS5611 init.
MS5611 getting pres.
Channel(9) value changed to temp(-123.00), humi(-1.00)
Channel(10) value changed to 0.00
Channel(12) value changed to 0.00
Button[0]: Initialized: pin 0, pullUp 1, invertLogic 1, state 1
*** Supla - Init elements done
Config incomplete: deviceMode = CONFIG
LAST STATE ADDED: Missing server address
Current status: [3] Missing server address
LAST STATE ADDED: Missing email address
Current status: [32] Missing email address
GUID: 462C73C59929A5910803AC0CF26BF50F
Device name: SUPLA-ESP32
Device software version: SDK 25.11-dev
*** Supla - Initializing network layer
[Wi-Fi] Network AP/hostname: SUPLA-ESP32-BCDDC2CD9250
Using Supla protocol version 23
Current status: [5] SuplaDevice initialized
Config incomplete: deviceMode = CONFIG
Wi-Fi SSID missing
[Wi-Fi] setConfigMode
WiFi: enter config mode with SSID: "SUPLA-ESP32-BCDDC2CD9250"
Starting local web server
LAST STATE ADDED: Config mode
Current status: [40] Config mode
*** Supla - Initialization done
*** Self-test ***
TEST: ManufacturerID is 0
TEST failed: ProductID is empty
TEST failed: storage init result is false
TEST failed: missing public RSA key
TEST failed: automatic firmware update is disabled
TEST failed: config encryption is disabled
TEST failed: invalid certificates format
TEST failed: security log is disabled
TEST failed: initial mode is set to config mode
*** Self-test done ***
SuplaDevice.begin() => Tryb konfiguracyjny wystartował.
Reset licznika opadów (początek godziny).


