SCD41 na SuplaDevice przez KPOP - jak wyciągac dane

Marian1544
Posts: 64
Joined: Sat Aug 28, 2021 4:45 pm

Post

Cześć.

Testuję właśnie najnowsze SuplaDevice z obsługą SCD41.
Clauda udało się odpalić, ale mam problem z pobraniem danych np. do LCD.

Code: Select all

#include <SuplaDevice.h>
#include <supla/network/esp_wifi.h>
#include <supla/sensor/SCD4x.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/wifi_parameters.h>
#include <supla/network/html/i2cscanner.h>
#include <supla/network/html/button_update.h>
#include <supla/device/status_led.h>
#include <supla/control/button.h>
//#include <supla/sensor/DS18B20.h>

#include <LiquidCrystal_I2C.h>

#define DEV_NAME "SCD4x test"

#define BUTTON_CFG_GPIO 0
#define STATUS_LED_GPIO 2

//#define DS18B20_GPIO D3

#define SDA_PIN    D2
#define SCL_PIN    D1

Supla::ESPWifi wifi;
Supla::LittleFsConfig configSupla;
Supla::Device::StatusLed statusLed(STATUS_LED_GPIO, true); // inverted state
Supla::EspWebServer suplaServer;

Supla::Sensor::SCD4x *scd4x = nullptr;

/* Kanały SUPLA */
double temperature;
int chTemp, chHum, chCO2;
unsigned long lastRead = 0;

auto buttonCfg = new Supla::Control::Button(BUTTON_CFG_GPIO, true, true);

LiquidCrystal_I2C lcd(0x27,16,2);
float myFloat = 13.22769;

void setup() {
  Serial.begin(115200);

  // WevInterface with Update
  new Supla::Html::DeviceInfo(&SuplaDevice);
  new Supla::Html::WifiParameters;
  new Supla::Html::ProtocolParameters;
  // new Supla::Html::StatusLedParameters;
  new Supla::Html::ButtonUpdate(&suplaServer);

  buttonCfg->configureAsConfigButton(&SuplaDevice);

  // I2C start & scan
  Wire.begin(SDA_PIN, SCL_PIN);
  new Supla::Html::I2Cscanner();
  
  lcd.init();                      // initialize the lcd 
  // Print a message to the LCD.
  lcd.backlight();
  lcd.setCursor(3,0);
  lcd.print("Hello, world!");
  lcd.setCursor(0,1);
  lcd.print(myFloat, DEC);
  

  auto scd4x = new Supla::Sensor::SCD4x();
  // new Supla::Sensor::DS18B20(DS18B20_GPIO);

  SuplaDevice.setName(DEV_NAME);
  SuplaDevice.setInitialMode(Supla::InitialMode::StartInCfgMode);
  SuplaDevice.begin();
}

void loop() {
  SuplaDevice.iterate();

  if (millis() - lastRead > 5000) {
    lastRead = millis();
    lcd.clear();
    lcd.setCursor(3,1);
    lcd.print(scd4x->getChannel()->getValueDouble(), DEC);

  }
}
Tego typu odczyt resetuje ESP:

Code: Select all

lcd.print(scd4x->getChannel()->getValueDouble(), DEC);
Jak sensownie pobierać odebrane dane z KPOP na potrzeby lokalne?
Po czym poznać które metody są dostępne ( getChannel()->getValueDoubleFirst())?
Jak zgodnie ze sztuką powinno się w Supli obsługiwać lokalnie LCD?
Przydałby się przykład jak LCD podpina np. GuiGeneric.
Last edited by Marian1544 on Fri Jan 23, 2026 1:35 pm, edited 2 times in total.
User avatar
vajera
Posts: 7285
Joined: Wed Oct 31, 2018 7:58 am
Location: Biedrusko
Has thanked: 289 times
Been thanked: 161 times

Post

Marian1544 wrote: Fri Jan 23, 2026 1:16 pm

Code: Select all

lcd.print(scd4x->getChannel()->getValueDouble(), DEC);

Code: Select all

lcd.print(scd4x->getValue(), DEC);
Bramka Zigbee <=> SUPLA
Więcej informacji tutaj:
https://forum.supla.org/viewforum.php?f=127
FAQ https://forum.supla.org/viewtopic.php?t=17277
Marian1544
Posts: 64
Joined: Sat Aug 28, 2021 4:45 pm

Post

Niestety błąd kompilacji:

Code: Select all

SuplaDevice\SCD41_test2\SCD41_test2.ino:84:22: error: 'class Supla::Sensor::SCD4x' has no member named 'getValue'
   84 |     lcd.print(scd4x->getValue(), DEC);
Z scd4x->getTemp() się kompiluje, ale resetuje.
User avatar
vajera
Posts: 7285
Joined: Wed Oct 31, 2018 7:58 am
Location: Biedrusko
Has thanked: 289 times
Been thanked: 161 times

Post

Marian1544 wrote: Fri Jan 23, 2026 1:32 pm Niestety błąd kompilacji:

Code: Select all

SuplaDevice\SCD41_test2\SCD41_test2.ino:84:22: error: 'class Supla::Sensor::SCD4x' has no member named 'getValue'
   84 |     lcd.print(scd4x->getValue(), DEC);
Z scd4x->getTemp() się kompiluje, ale resetuje.
Przepraszam, nie zauważyłem, że ten czujnik ma takie combo:

Code: Select all

 lcd.print(scd4x->getTemp(), DEC);
  lcd.print(scd4x->getHumi(), DEC);
 lcd.print(scd4x->getCO2(), DEC);
 
Reset w trakcie getTemp() może być związany z metodą pobierania danych - spróbuj w tej swojej pętli wydłużyć odstęp - daj np. 15000 zamiast 5000?
Bramka Zigbee <=> SUPLA
Więcej informacji tutaj:
https://forum.supla.org/viewforum.php?f=127
FAQ https://forum.supla.org/viewtopic.php?t=17277
Marian1544
Posts: 64
Joined: Sat Aug 28, 2021 4:45 pm

Post

Przy 15000 zdąży się połączyć i coś tam wyśle do chmury, ale po tym czasie znowu reset.
User avatar
vajera
Posts: 7285
Joined: Wed Oct 31, 2018 7:58 am
Location: Biedrusko
Has thanked: 289 times
Been thanked: 161 times

Post

Marian1544 wrote: Fri Jan 23, 2026 2:04 pm Przy 15000 zdąży się połączyć i coś tam wyśle do chmury, ale po tym czasie znowu reset.
To spróbuj jeszcze 30000.
Bramka Zigbee <=> SUPLA
Więcej informacji tutaj:
https://forum.supla.org/viewforum.php?f=127
FAQ https://forum.supla.org/viewtopic.php?t=17277
Marian1544
Posts: 64
Joined: Sat Aug 28, 2021 4:45 pm

Post

Ten sam efekt.
User avatar
klew
Posts: 13905
Joined: Thu Jun 27, 2019 12:16 pm
Location: Wrocław
Has thanked: 134 times
Been thanked: 137 times

Post

Marian1544 wrote: Fri Jan 23, 2026 2:17 pm Ten sam efekt.
Wrzuć logi w których widać crash
Najlepsze suple dla Twojego domu :mrgreen:
Marian1544
Posts: 64
Joined: Sat Aug 28, 2021 4:45 pm

Post

Tutaj z czasem 15000

Code: Select all

GPM[1]: DefaultUnitAfterValue "ppm"
Channel[1] initial caption set to 'CO₂'
GPM[1]: DefaultValuePrecision 1
SD: initial mode: Start in cfg mode (legacy, deprected)
 *** Supla - starting initialization (platform 0)
Clock not configured, using default clock
SD: add flag DEVICE_CONFIG_SUPPORTED
SD: add flag CALCFG_RESTART_DEVICE
Main storage not configured
LittleFsConfig: file "/supla-dev.cfg" size 569
LittleFsConfig: initializing storage from file...
LittleFsConfig: init result success
 *** Supla - Config initalization
SD: add flag CALCFG_ENTER_CFG_MODE
SD: add flag CALCFG_FACTORY_RESET_SUPPORTED
Automatic firmware update is disabled
Device mode: 0
Security level: Supla CA
 *** Supla - Config load for elements
SD: add flag CALCFG_IDENTIFY_DEVICE
RemoteDeviceConfig: Registering field 0x000000001
Button[0] don't load config
Channel[0] temperature correction 0.00
Channel[0] humidity correction 0.00
GPM[1]: config loaded successfully
GPM[1]: RefreshIntervalMs 5000 ms
RemoteDeviceConfig: Registering field 0x000000010
Clock: automaticTimeSync: 1
 *** Supla - Config load for elements done
 *** Supla - Init elements
Button[0]: Initialized: pin 0, pullUp 1, invertLogic 1, state 1
SCD4x Sensor detected.
Channel(1) value changed to NaN
 *** Supla - Init elements done
GUID: C:******************-
Device name: SCD4x test
Device software version: SDK 25.11-dev
 *** Supla - Initializing network layer
[Wi-Fi] Network AP/hostname: SCD4X-:******************-
Using Supla protocol version 23
Current status: [5] SuplaDevice initialized
Enter normal mode
[Wi-Fi] setNormalMode
 *** Supla - Initialization done
 *** Self-test ***
TEST: ManufacturerID is 0
TEST failed: ProductID is empty
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 ***
WiFi: establishing connection with SSID: "iii"
WiFi station disconnected
Channel(0) value changed to temp(23.30), humi(34.11)
Channel(1) value changed to 1375.00
Warning: network is not ready (10 s)
Connected BSSID: A:******************-
local IP: 192.:******************-
subnetMask: 255.255.255.0
gatewayIP: 192.168.1.1
Signal strength (RSSI): -52 dBm
Establishing encrypted connection with: svr:******************-org (port: 2016)
Waiting for NTP time sync
Connected via IP 192.:******************-
Connected to Supla Server
Initializing SRPC (proto: 23)
LAST STATE ADDED: Register in progress (13)
Current status: [10] Register in progress
Send: [53 55 50 4C 41 17 01 00 00 00 4B 00 00 00 8E 02 00 00 74 65 73 74 5F 70 6C 61 79 39 39 40 67 6F 32 2E 70 6C 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 17 AC 3E B6 18 46 19 91 BA 02 04 27 8F 75 C9 98 CD 6B 35 04 F2 FB 8C 8D 33 60 FC 91 8D FF AC 03 53 43 44 34 78 20 74 65 73 74 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ]
CH[0], type: 3038, FuncList: 0x0, function: 45, flags: 0x008010000, online, validityTimeSec: 0, icon: 0, value: [ff 5a 00 00 40 85 00 00]
Send: [00 DE 0B 00 00 00 00 00 00 2D 00 00 00 00 00 01 08 00 00 00 00 00 00 00 00 00 FF 5A 00 00 40 85 00 00 00 ]
CH[1], type: 9000, FuncList: 0x0, function: 520, flags: 0x008010000, online, validityTimeSec: 0, icon: 8, value: [00 00 00 00 00 7c 95 40]
Send: [01 28 23 00 00 00 00 00 00 08 02 00 00 00 00 01 08 00 00 00 00 00 00 00 00 00 00 00 00 00 00 7C 95 40 08 ]
Send: [53 55 50 4C 41 ]

--------------- CUT HERE FOR EXCEPTION DECODER ---------------

Exception (28):
epc1=0x402062c9 epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000000 depc=0x00000000

>>>stack>>>

ctx: cont
sp: 3ffffe60 end: 3fffffd0 offset: 0150
3fffffb0:  00000000 00000000 3fff337c 40227264  
3fffffc0:  feefeffe feefeffe 3fffdab0 40101159  
<<<stack<<<

--------------- CUT HERE FOR EXCEPTION DECODER ---------------

 ets Jan  8 2013,rst cause:2, boot mode:(3,6)

load 0x4010f000, len 3424, room 16 
tail 0
chksum 0x2e
load 0x3fff20b8, len 40, room 8 
tail 0
chksum 0x2b
csum 0x2b
v00095300
~ld
����n쒜p��o|�l�l`b��|r�l�o��o�□$`�œn�l�d�□�Button[0]::configureAsConfigButton
Button[0] setHoldTime: 5000
Button[0] setMulticlickTime: 300
GPM[1]: DefaultUnitAfterValue "ppm"
Channel[1] initial caption set to 'CO₂'
GPM[1]: DefaultValuePrecision 1
SD: initial mode: Start in cfg mode (legacy, deprected)
 *** Supla - starting initialization (platform 0)
Clock not configured, using default clock
SD: add flag DEVICE_CONFIG_SUPPORTED
SD: add flag CALCFG_RESTART_DEVICE
Main storage not configured
LittleFsConfig: file "/supla-dev.cfg" size 569
LittleFsConfig: initializing storage from file...
LittleFsConfig: init result success
 *** Supla - Config initalization
SD: add flag CALCFG_ENTER_CFG_MODE
SD: add flag CALCFG_FACTORY_RESET_SUPPORTED
Automatic firmware update is disabled
Device mode: 0
Security level: Supla CA
 *** Supla - Config load for elements
SD: add flag CALCFG_IDENTIFY_DEVICE
RemoteDeviceConfig: Registering field 0x000000001
Button[0] don't load config
Channel[0] temperature correction 0.00
Channel[0] humidity correction 0.00
GPM[1]: config loaded successfully
GPM[1]: RefreshIntervalMs 5000 ms
RemoteDeviceConfig: Registering field 0x000000010
Clock: automaticTimeSync: 1
 *** Supla - Config load for elements done
 *** Supla - Init elements
Button[0]: Initialized: pin 0, pullUp 1, invertLogic 1, state 1
SCD4x Sensor detected.
Channel(1) value changed to NaN
 *** Supla - Init elements done
GUID: CD:******************-
Device name: SCD4x test
Device software version: SDK 25.11-dev
 *** Supla - Initializing network layer
[Wi-Fi] Network AP/hostname: SCD4X-:******************-
Using Supla protocol version 23
Current status: [5] SuplaDevice initialized
Enter normal mode
[Wi-Fi] setNormalMode
 *** Supla - Initialization done
 *** Self-test ***
TEST: ManufacturerID is 0
TEST failed: ProductID is empty
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 ***
WiFi: establishing connection with SSID: "iii"

Last edited by Marian1544 on Sat Jan 24, 2026 10:43 am, edited 1 time in total.
User avatar
klew
Posts: 13905
Joined: Thu Jun 27, 2019 12:16 pm
Location: Wrocław
Has thanked: 134 times
Been thanked: 137 times

Post

Crash wygląda jakby leciał przy rejestacji do serwera i jakby nie miał związku z tymi lcd.print.

Ja bym tego "if" w loop rozbił na framgenty i wstawił wszędzie logi debugowe. Dodatkowo najpierw pobierz do double odczyt, a w osobnej linii daj print (w logami pomiędzy).

Alternatywnie zdekoduj callstack - może będzie coś widać, choć na oko wygląda ubogo.
Najlepsze suple dla Twojego domu :mrgreen:

Return to “supla-dev”