XIAOMI LYWSD03MMC - odczyt przez ESP32

martinok
Posts: 126
Joined: Sat Dec 17, 2016 10:12 am
Location: Poznań

Post

Wgrałem na takie urządzenie bo na identycznym mam Tasmote która odczytuje z kilku termometrów.
Ale to chyba zwykłe ESP32 i tu pewnie jest problem.
Czy możecie podać link jakie dokładnie powinno to być ESP?
You do not have the required permissions to view the files attached to this post.
"Wiedza bez Praktyki jest Bezużyteczna , praktyka bez wiedzy Niebezpieczna"...
User avatar
veeroos
Posts: 1080
Joined: Sun Mar 20, 2022 9:30 am
Location: Głogów
Has thanked: 1 time
Been thanked: 9 times

Post

Ja kupiłem z tej aukcji, ale dlatego tylko że na szybko potrzebowałem, normalnie to na Ali bym kupił https://allegro.pl/oferta/esp32-esp32-s ... 3170814019
Zamel Mew-01, Zamel PEW-01, Zamel SBW-01, Zamel THW-01, Zamel SRW-01, Zamel mSLW-02, Auraton BOX + Indor Sensor, Airly Gate By Veeroos, Zigbee to Supla Gateway + sensors, Zamel SGW-01 and more

https://github.com/v33r005
User avatar
klew
Posts: 13906
Joined: Thu Jun 27, 2019 12:16 pm
Location: Wrocław
Has thanked: 134 times
Been thanked: 137 times

Post

martinok wrote: Thu Feb 16, 2023 11:45 am Wgrałem na takie urządzenie bo na identycznym mam Tasmote która odczytuje z kilku termometrów.
Ale to chyba zwykłe ESP32 i tu pewnie jest problem.
Czy możecie podać link jakie dokładnie powinno to być ESP?
Każdy ESP32 wspierający bluetooth i Wi-Fi będzie ok. Podeślij proszę rzeczy, o które prosiłem wcześniej, to coś pomożemy.
Najlepsze suple dla Twojego domu :mrgreen:
User avatar
klew
Posts: 13906
Joined: Thu Jun 27, 2019 12:16 pm
Location: Wrocław
Has thanked: 134 times
Been thanked: 137 times

Post

martinok wrote: Thu Feb 16, 2023 11:45 am Wgrałem na takie urządzenie bo na identycznym mam Tasmote która odczytuje z kilku termometrów.
Ale to chyba zwykłe ESP32 i tu pewnie jest problem.
Czy możecie podać link jakie dokładnie powinno to być ESP?
Znalazłem u siebie podobny układ do Twojego i po wgraniu tego programu mam takie same objawy z problemem z połączeniem.
Na pierwszy rzut oka wygląda na problem z ilością wolnej pamięci RAM.

Dam znać jak znajdę przyczynę i rozwiązanie.
Najlepsze suple dla Twojego domu :mrgreen:
User avatar
klew
Posts: 13906
Joined: Thu Jun 27, 2019 12:16 pm
Location: Wrocław
Has thanked: 134 times
Been thanked: 137 times

Post

Wygląda na to, że inicjalizacja Bluetooth zjada bardzo dużo RAM-u. Inicjalizacja Wi-Fi zjada kolejną dużą porcję i na nawiązanie szyfrowanego połączcenia już brakuje pamięci.

Tak na szybko tutaj nic sensownego nie wymyślę.

W sieci znalazłem alternatywną bibliotekę do bluetooth, która podobno jest zoptymalizowana pod kątem zużycia pamięci, można spróbować z nią:
https://github.com/h2zero/NimBLE-Arduino

Druga rzecz, można wyłączyć szyfrowane połączenie w Supli:

Code: Select all

wifi.setSSLEnabled(false);
Najlepsze suple dla Twojego domu :mrgreen:
martinok
Posts: 126
Joined: Sat Dec 17, 2016 10:12 am
Location: Poznań

Post

klew wrote: Fri Feb 17, 2023 11:30 am
Druga rzecz, można wyłączyć szyfrowane połączenie w Supli:

Code: Select all

wifi.setSSLEnabled(false);
Działa po wyłączeniu tylko co to oznacza? "Druga rzecz, można wyłączyć szyfrowane połączenie w Supli:"
Że ktoś może przechwycić moje temperatury?
"Wiedza bez Praktyki jest Bezużyteczna , praktyka bez wiedzy Niebezpieczna"...
User avatar
klew
Posts: 13906
Joined: Thu Jun 27, 2019 12:16 pm
Location: Wrocław
Has thanked: 134 times
Been thanked: 137 times

Post

martinok wrote: Fri Feb 17, 2023 5:56 pm
klew wrote: Fri Feb 17, 2023 11:30 am
Druga rzecz, można wyłączyć szyfrowane połączenie w Supli:

Code: Select all

wifi.setSSLEnabled(false);
Działa po wyłączeniu tylko co to oznacza? "Druga rzecz, można wyłączyć szyfrowane połączenie w Supli:"
Że ktoś może przechwycić moje temperatury?
To znaczy że dane przesyłane między serwerem a tym urządzeniem są nieszyfrowane. Dane przesyłane mogą być przechwycone (temperatury, mail, i wszystko do czego tego urządzenia używasz).
Jest też ryzyko że ktoś podstawi swój serwer po drodze i urządzenie zamiast połączyć się z serwerem Supli, połączy się z czymś innym.
Ogólnie potencjalne ryzyko przy termometrach jest niewielkie i bardzo dużo osób używa niezidentyfikowanego połączenia, ale trzeba o tym pamiętać i akceptować ryzyko.
Najlepsze suple dla Twojego domu :mrgreen:
User avatar
veeroos
Posts: 1080
Joined: Sun Mar 20, 2022 9:30 am
Location: Głogów
Has thanked: 1 time
Been thanked: 9 times

Post

hmm spróbowałem wgrać tą bibliotekę do arduino, jednakże mam błąd kompilacji

Code: Select all

c:\Users\Robercik\Documents\Arduino\test odczyt xiaomi_copy_20230218192350\test odczyt xiaomi_copy_20230218192350.ino: In function 'void loop()':
C:\Users\Robercik\Documents\Arduino\test odczyt xiaomi_copy_20230218192350\test odczyt xiaomi_copy_20230218192350.ino:372:76: error: invalid new-expression of abstract class type 'MyAdvertisedDeviceCallbacks'
     pBLEScan->setAdvertisedDeviceCallbacks(new MyAdvertisedDeviceCallbacks());
                                                                            ^
C:\Users\Robercik\Documents\Arduino\test odczyt xiaomi_copy_20230218192350\test odczyt xiaomi_copy_20230218192350.ino:118:7: note:   because the following virtual functions are pure within 'MyAdvertisedDeviceCallbacks':
 class MyAdvertisedDeviceCallbacks : public BLEAdvertisedDeviceCallbacks {
       ^~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from c:\Users\Robercik\Documents\Arduino\libraries\NimBLE-Arduino-release-1.4\src/NimBLEScan.h:20,
                 from c:\Users\Robercik\Documents\Arduino\libraries\NimBLE-Arduino-release-1.4\src/NimBLEDevice.h:22,
                 from C:\Users\Robercik\Documents\Arduino\test odczyt xiaomi_copy_20230218192350\test odczyt xiaomi_copy_20230218192350.ino:27:
c:\Users\Robercik\Documents\Arduino\libraries\NimBLE-Arduino-release-1.4\src/NimBLEAdvertisedDevice.h:194:18: note: 	'virtual void NimBLEAdvertisedDeviceCallbacks::onResult(NimBLEAdvertisedDevice*)'
     virtual void onResult(NimBLEAdvertisedDevice* advertisedDevice) = 0;
                  ^~~~~~~~
C:\Users\Robercik\Documents\Arduino\test odczyt xiaomi_copy_20230218192350\test odczyt xiaomi_copy_20230218192350.ino: In function 'void initBluetooth()':
C:\Users\Robercik\Documents\Arduino\test odczyt xiaomi_copy_20230218192350\test odczyt xiaomi_copy_20230218192350.ino:393:76: error: invalid new-expression of abstract class type 'MyAdvertisedDeviceCallbacks'
     pBLEScan->setAdvertisedDeviceCallbacks(new MyAdvertisedDeviceCallbacks());
                                                                            ^

exit status 1

Compilation error: invalid new-expression of abstract class type 'MyAdvertisedDeviceCallbacks'
Zgłasza błąd wywołania klasy.

Na chwilę obecną działa mi to wszystko na ESP32 S3 dorobiłem tylko odczyt baterii i jeśli przez 5 skanowań nie wykryje któregoś czujnika, to wyświetlane wartości wyłączają się (do temperatury i baterii przepisywane są wartości -275, a wilgotność -1).
Zamel Mew-01, Zamel PEW-01, Zamel SBW-01, Zamel THW-01, Zamel SRW-01, Zamel mSLW-02, Auraton BOX + Indor Sensor, Airly Gate By Veeroos, Zigbee to Supla Gateway + sensors, Zamel SGW-01 and more

https://github.com/v33r005
t0mek
Posts: 92
Joined: Sat Dec 02, 2017 11:24 am
Location: Legnica

Post

@veeroos dobra robota!
potwierdzam działanie na S3 Dev :D . Faktycznie wywala połączenie (od 15 do 30 min) ale odrazu się łączy. Niezauważalne - nawet na wykresach tego nie widać - pewnie mija się z odczytem z czujników.
@veeroos zapodasz kod z odczytem baterii?
Można się pobawić i rozbudować tryb konfiguracji, żeby dodawać nowe czujniki lub edytować aktualne - nie trzeba by było kompilować nowego softu przy rozbudowie.
ps ale co włosów wyrwałem, żeby dopasować wszystko w arduino :roll: ... tak to jest jak raz na pół roku wchodzisz w temat...
Pozdrawiam
Tomek
User avatar
veeroos
Posts: 1080
Joined: Sun Mar 20, 2022 9:30 am
Location: Głogów
Has thanked: 1 time
Been thanked: 9 times

Post

t0mek wrote: Sun Feb 19, 2023 6:52 am @veeroos dobra robota!
potwierdzam działanie na S3 Dev :D . Faktycznie wywala połączenie (od 15 do 30 min) ale odrazu się łączy. Niezauważalne - nawet na wykresach tego nie widać - pewnie mija się z odczytem z czujników.
@veeroos zapodasz kod z odczytem baterii?
Można się pobawić i rozbudować tryb konfiguracji, żeby dodawać nowe czujniki lub edytować aktualne - nie trzeba by było kompilować nowego softu przy rozbudowie.
ps ale co włosów wyrwałem, żeby dopasować wszystko w arduino :roll: ... tak to jest jak raz na pół roku wchodzisz w temat...
Oj tam największą robotę zrobił kolega @Duch__, ja tylko napisałem kawałek kodu który wrzuca dane do Supli ;-).
Aktualnie kod wygląda tak:

Code: Select all

/*
  Copyright (C) AC SOFTWARE SP. Z O.O.

  This program is free software; you can redistribute it and/or
  modify it under the terms of the GNU General Public License
  as published by the Free Software Foundation; either version 2
  of the License, or (at your option) any later version.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program; if not, write to the Free Software
  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
*/

#define STATUS_LED_GPIO 2
#define BUTTON_CFG_RELAY_GPIO 0
#include <sstream>
#include <BLEDevice.h>
#include <BLEScan.h>
#include <BLEAdvertisedDevice.h>


#include <SuplaDevice.h>
#include <supla/network/esp_wifi.h>
#include <supla/control/button.h>
#include <supla/control/action_trigger.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/device/supla_ca_cert.h>
#include <supla/sensor/therm_hygro_meter.h>
#include <supla/sensor/thermometer.h>

#define SCAN_TIME  5 // seconds

int od1 = 0;
int od2 = 0;
int od3 = 0;
int wilg1 = -1;
float temp1 = -275;
int wilg2 = -1;
float temp2 = -275;
int wilg3 = -1;
float temp3 = -275;
float bat1 = -275;
float bat2 = -275;
float bat3 = -275;
unsigned long czas_pomiedzy_skanowaniem;
unsigned long wifimilis;
boolean METRIC = true; //Set true for metric system; false for imperial

String text01;
String text02;
String text03;
String text04;
String text05;
String text06;
String text07;
String text08;
String text09;
String text10;
String text11;
String text12;
String text13;
String text14;
String text15;
String zmienna;
String MAC_ADR;
byte BLE_DEVICE;
bool wyswietl = 0;

#define XIAOMI_BLE_DEVICE_1_MAC "A4:C1:38:0D:AE:08"
#define XIAOMI_BLE_DEVICE_2_MAC "A4:C1:38:10:3D:44"
#define XIAOMI_BLE_DEVICE_3_MAC "A4:C1:38:43:6A:FE"

#include <supla/storage/eeprom.h>
Supla::Eeprom eeprom;

Supla::ESPWifi wifi;
Supla::LittleFsConfig configSupla;

Supla::Device::StatusLed statusLed(STATUS_LED_GPIO, true); // inverted state
Supla::EspWebServer suplaServer;
//wifi.setSSLEnabled(false);
Supla::Html::DeviceInfo htmlDeviceInfo(&SuplaDevice);
Supla::Html::WifiParameters htmlWifi;
Supla::Html::ProtocolParameters htmlProto;
Supla::Html::StatusLedParameters htmlStatusLed;

int current_humidity;
int current_batt;

word val;

BLEScan *pBLEScan;

void IRAM_ATTR resetModule(){
    ets_printf("reboot\n");
    esp_restart();
}

float current_temperature;

class MyAdvertisedDeviceCallbacks : public BLEAdvertisedDeviceCallbacks {
    void onResult(BLEAdvertisedDevice advertisedDevice)
    {
        if (advertisedDevice.haveName() && advertisedDevice.haveServiceData() /*&& !advertisedDevice.getName().compare("ATC_9C1E8B")*/) {

            int serviceDataCount = advertisedDevice.getServiceDataCount();
            std::string strServiceData = advertisedDevice.getServiceData(0);

            uint8_t cServiceData[100];
            char charServiceData[100];

            strServiceData.copy((char *)cServiceData, strServiceData.length(), 0);

            for (int i=0;i<strServiceData.length();i++) {
                sprintf(&charServiceData[i*2], "%02x", cServiceData[i]);
            }

            std::stringstream ss;
            ss << "fe95" << charServiceData;

            

            text01 = String(charServiceData[0]) + String(charServiceData[1]);      //Serial.print(text1); Serial.print(" ");
            text02 = String(charServiceData[2]) + String(charServiceData[3]);      //Serial.print(text2); Serial.print(" ");
            text03 = String(charServiceData[4]) + String(charServiceData[5]);      //Serial.print(text3); Serial.print(" ");
            text04 = String(charServiceData[6]) + String(charServiceData[7]);      //Serial.print(text4); Serial.print(" ");
            text05 = String(charServiceData[8]) + String(charServiceData[9]);      //Serial.print(text5); Serial.print(" "); 
            text06 = String(charServiceData[10]) + String(charServiceData[11]);    //Serial.print(text6); Serial.print(" "); 
            text07 = String(charServiceData[12]) + String(charServiceData[13]);    //Serial.print(text7); Serial.print(" "); 
            text08 = String(charServiceData[14]) + String(charServiceData[15]);    //Serial.print(text8); Serial.print(" "); 
            text09 = String(charServiceData[16]) + String(charServiceData[17]);    //Serial.print(text9); Serial.print(" "); 
            text10 = String(charServiceData[18]) + String(charServiceData[19]);   //Serial.print(text10); Serial.print(" "); 
            text11 = String(charServiceData[20]) + String(charServiceData[21]);   //Serial.print(text11); Serial.print(" "); 
            text12 = String(charServiceData[22]) + String(charServiceData[23]);   //Serial.print(text12); Serial.print(" "); 
            
            //Serial.println();

            zmienna = text01; Zamien_litery(); text01 = zmienna;
            zmienna = text02; Zamien_litery(); text02 = zmienna;
            zmienna = text03; Zamien_litery(); text03 = zmienna;
            zmienna = text04; Zamien_litery(); text04 = zmienna;
            zmienna = text05; Zamien_litery(); text05 = zmienna;
            zmienna = text06; Zamien_litery(); text06 = zmienna;
            zmienna = text07; Zamien_litery(); text07 = zmienna;
            zmienna = text08; Zamien_litery(); text08 = zmienna;
            zmienna = text09; Zamien_litery(); text09 = zmienna;
            zmienna = text10; Zamien_litery(); text10 = zmienna;
            zmienna = text11; Zamien_litery(); text11 = zmienna;
            zmienna = text12; Zamien_litery(); text12 = zmienna;
            zmienna = text13; Zamien_litery(); text13 = zmienna;
            zmienna = text14; Zamien_litery(); text14 = zmienna;
            zmienna = text15; Zamien_litery(); text15 = zmienna;




            Konwersja();


            
        }
    }
};

class Czujnik1 : public Supla::Sensor::ThermHygroMeter {
 public:
  explicit Czujnik1()
{

  }

  double getTemp() {
    temperature = temp1;
    return temperature;
  }

  double getHumi() {
    humidity = wilg1;
    return humidity;
  }

 private:
  void iterateAlways() {
    if (millis() - lastReadTime > 10000) {
      lastReadTime = millis();
      channel.setNewValue(getTemp(), getHumi());
    }
  }

  void onInit() {
    channel.setNewValue(getTemp(), getHumi());
  }

 protected:
  double temperature = - 270;
  double humidity = 0;

};
class Czujnik2 : public Supla::Sensor::ThermHygroMeter {
 public:
  explicit Czujnik2()
{

  }

  double getTemp() {
    temperature = temp2;
    return temperature;
  }

  double getHumi() {
    humidity = wilg2;
    return humidity;
  }

 private:
  void iterateAlways() {
    if (millis() - lastReadTime > 10000) {
      lastReadTime = millis();
      channel.setNewValue(getTemp(), getHumi());
    }
  }

  void onInit() {
    channel.setNewValue(getTemp(), getHumi());
  }

 protected:
  double temperature = -270;
  double humidity = 0;

};
class Czujnik3 : public Supla::Sensor::ThermHygroMeter {
 public:
  explicit Czujnik3()
{

  }

  double getTemp() {
    temperature = temp3;
    //lastValidTemp = temperature;

    return temperature;
  }

  double getHumi() {
    humidity = wilg3;
    //lastValidHumi = humidity;
    return humidity;
  }

 private:
  void iterateAlways() {
    if (millis() - lastReadTime > 10000) {
      lastReadTime = millis();
      channel.setNewValue(getTemp(), getHumi());
    }
  }

  void onInit() {
    channel.setNewValue(getTemp(), getHumi());
  }

 protected:
  double temperature = - 270;
  double humidity = 0;

};

class Bateria1 : public Supla::Sensor::Thermometer {
  public:
     Bateria1() {
    }

    double getValue() 
    {
     battery = bat1;
      return battery;
    }
    void iterateAlways() {
      channel.setNewValue(getValue());
    }
    void onInit() {
      channel.setNewValue(getValue());
    }
    protected:
    float battery;
};

class Bateria2 : public Supla::Sensor::Thermometer {
  public:
     Bateria2() {
    }

    double getValue() 
    {
     battery = bat2;
      return battery;
    }
    void iterateAlways() {
      channel.setNewValue(getValue());
    }
    void onInit() {
      channel.setNewValue(getValue());
    }
    protected:
    float battery;
};
class Bateria3 : public Supla::Sensor::Thermometer {
  public:
     Bateria3() {
    }

    double getValue() 
    {
     battery = bat3;
      return battery;
    }
    void iterateAlways() {
      channel.setNewValue(getValue());
    }
    void onInit() {
      channel.setNewValue(getValue());
    }
    protected:
    float battery;
};

void setup() {

  Serial.begin(115200);
  initBluetooth();
  //WiFi.begin();
  // Channels configuration
  auto buttonCfgRelay = new Supla::Control::Button(BUTTON_CFG_RELAY_GPIO, true, true);
  buttonCfgRelay->configureAsConfigButton(&SuplaDevice);
  new Czujnik1();
  new Bateria1();
  new Czujnik2();
  new Bateria2();
  new Czujnik3();
  new Bateria3();
  // configure defualt Supla CA certificate
  SuplaDevice.setSuplaCACert(suplaCACert);
  SuplaDevice.setSupla3rdPartyCACert(supla3rdCACert);

  SuplaDevice.begin();
}

void loop() {
  if (millis() - czas_pomiedzy_skanowaniem > 120000) {
    czas_pomiedzy_skanowaniem = millis();
    BLEScan* pBLEScan = BLEDevice::getScan(); //create new scan
    pBLEScan->setAdvertisedDeviceCallbacks(new MyAdvertisedDeviceCallbacks());
    pBLEScan->setActiveScan(true); //active scan uses more power, but get results faster
    BLEScanResults foundDevices = pBLEScan->start(SCAN_TIME);
    int count = foundDevices.getCount();
    delay(100);
    od1 = od1 +1;
    od2 = od2 +1;
    od3 = od3 +1;
    }
  SuplaDevice.iterate();
    if (WiFi.status() != WL_CONNECTED) {    
    if (millis() > wifimilis)  {               
    WiFi.begin(); 
    wifimilis = (millis() + 20000) ;
    }
  }
}
void initBluetooth()
{
    BLEDevice::init("");
    pBLEScan = BLEDevice::getScan(); //create new scan
    pBLEScan->setAdvertisedDeviceCallbacks(new MyAdvertisedDeviceCallbacks());
    pBLEScan->setActiveScan(false); //active scan uses more power, but get results faster
    pBLEScan->setInterval(0x50);
    pBLEScan->setWindow(0x30);
}

void Konwersja()
{
  int number;
  String hexstring;
  int t1;
  int t2;


  hexstring = "#" + text07;
  number = (int) strtol( &hexstring[1], NULL, 16);
  t1 = number & 0xFF;                        

  hexstring = "#" + text08;
  number = (int) strtol( &hexstring[1], NULL, 16);
  t2 = number & 0xFF;

  current_temperature = t1 * 256;
  current_temperature = current_temperature + t2;
  current_temperature = current_temperature / 10;
  // Konwersja z Faranheitów na Celsjusze
                                      
  hexstring = "#" + text09;
  number = (int) strtol( &hexstring[1], NULL, 16);
  current_humidity = number & 0xFF;

  hexstring = "#" + text10;
  number = (int) strtol( &hexstring[1], NULL, 16);
  current_batt = number & 0xFF;
  
  MAC_ADR = "";
  MAC_ADR = MAC_ADR + text01 + ":";
  MAC_ADR = MAC_ADR + text02 + ":";
  MAC_ADR = MAC_ADR + text03 + ":";
  MAC_ADR = MAC_ADR + text04 + ":";
  MAC_ADR = MAC_ADR + text05 + ":";
  MAC_ADR = MAC_ADR + text06;

  BLE_DEVICE = 0;
  if(MAC_ADR == XIAOMI_BLE_DEVICE_1_MAC){BLE_DEVICE = 1; wyswietl = 1; Wyswietl();} 
  if(MAC_ADR == XIAOMI_BLE_DEVICE_2_MAC){BLE_DEVICE = 2; wyswietl = 1; Wyswietl();}
  if(MAC_ADR == XIAOMI_BLE_DEVICE_3_MAC){BLE_DEVICE = 3; wyswietl = 1; Wyswietl();} 
}
void Wyswietl(){
  if(wyswietl == 1){
    Serial.print("Urządzenie:");
    Serial.print(BLE_DEVICE);
    Serial.print(" MAC: "); 
    Serial.print(MAC_ADR);
                                   
    Serial.print(" Temp: ");
    Serial.print(current_temperature,1);
    Serial.print("stC. Wilgotnosc: ");
    Serial.print(current_humidity);
    Serial.print("%. Bateria: ");
    Serial.print(current_batt);
    Serial.println("%.");   
    if (BLE_DEVICE == 1) {
      temp1 = (current_temperature);
      wilg1 = current_humidity;
      bat1 = current_batt;
      od1 = 0;
    }
    if (BLE_DEVICE == 2) {
      temp2 = (current_temperature);
      wilg2 = current_humidity;
      bat2 = current_batt;
      od2 = 0;
    }
    if (BLE_DEVICE == 3) {
      temp3 = (current_temperature);
      wilg3 = (current_humidity);
      bat3 = (current_batt);
      od3 = 0;
    }
    if (od1 > 5){
      temp1 = -275;
      wilg1 = -1;
      bat1 = -275;
      od1 = 0;
    }
    if (od2 > 5){
      temp2 = -275;
      wilg2 = -1;
      bat2 = -275;
      od2 = 0;
    }
    if (od3 > 5){
      temp3 = -275;
      wilg3 = -1;
      bat3 = -275;
      od3 = 0;
    }
    wyswietl = 0; 
  }
}

void Zamien_litery()  //Zamieniamy otrzymywane małe litery na duże
{
  zmienna.replace('a', 'A');
  zmienna.replace('b', 'B');
  zmienna.replace('c', 'C');
  zmienna.replace('d', 'D');
  zmienna.replace('e', 'E');
  zmienna.replace('f', 'F');
}
Może i mieć błędy, ale chodzi. Stan baterii wyświetlany jest procentowo, a jeśli chodzi o wyświetlanie danych na Supli to z tego co pamiętam co 10 minut rejestrowane są dane na serwerze. Czujnik są odpytywane niezależnie od polączenia z serwerem, ich wartości są zapisywane do zmiennych, więc jak nawet połączenie się zerwie to w zmiennych dane pozostają aktualne. Ja dzisiaj w nocy miałem na wykresie koło północy tak z 10 minutową przerwę odczytu danych, a tak to chodzi poprawnie, oczywiście na ESP32 S3 ;-)
Screenshot_2023-02-19-08-57-01-857_org.supla.android.jpg
A tak wygląda to aktualnie 😉
You do not have the required permissions to view the files attached to this post.
Zamel Mew-01, Zamel PEW-01, Zamel SBW-01, Zamel THW-01, Zamel SRW-01, Zamel mSLW-02, Auraton BOX + Indor Sensor, Airly Gate By Veeroos, Zigbee to Supla Gateway + sensors, Zamel SGW-01 and more

https://github.com/v33r005

Return to “Zagadnienia ogólne”