Do czujnika rozumiem wrzucić ten soft ostatnie wydanie:
https://github.com/atc1441/ATC_MiThermo ... ses/tag/79
Do czujnika rozumiem wrzucić ten soft ostatnie wydanie:
Ustawiasz na przykład Huge App żebyś miał przynajmniej 3MB na program. E-mail możesz wpisać w webserwerze, albo poprostu dodajesz urządzenie poprzez aplikację na smartfona i nie musisz nic wpisywać bo się samo wszystko zrobimarcinl wrote: Wed Jan 17, 2024 1:11 pmAle to ustawiam flash na 16MB, partycje na 16MB i PSRAM załączam (nie widzę tu opcji ustawienia wielkości) ?veeroos wrote: Wed Jan 17, 2024 11:53 am Jest też wersja S3 i prawdopodobnie będziesz ją miał, ona posiada PSRAM 8MB włącz tą pamięć też w ustawieniach Arduino w normalnym module S3 jest to opcja OPI PSRAM przy tej ilości pamięci
I jeszcze może głupie pytanie - gdzie wpisuję swój adres supli ? adres email ?
Takkurus wrote: Wed Jan 17, 2024 1:16 pmDo czujnika rozumiem wrzucić ten soft ostatnie wydanie:
https://github.com/atc1441/ATC_MiThermo ... ses/tag/79
To nie jest żaden bug, jak jest ikona baterii to pokazuje poziom baterii, jak jej nie ma to jest poziom wilgotnościmarcinl wrote: Wed Jan 17, 2024 1:25 pm Też macie taki bug w tym alternatywnym firmwarze że jak pokazuje ikonkę baterii (że słaba) to wilgotność w tym momencie pokazuje dużo większą? Aktualnie 40 i 53 % u mnie...
Ah okveeroos wrote: Wed Jan 17, 2024 1:30 pmTo nie jest żaden bug, jak jest ikona baterii to pokazuje poziom baterii, jak jej nie ma to jest poziom wilgotnościmarcinl wrote: Wed Jan 17, 2024 1:25 pm Też macie taki bug w tym alternatywnym firmwarze że jak pokazuje ikonkę baterii (że słaba) to wilgotność w tym momencie pokazuje dużo większą? Aktualnie 40 i 53 % u mnie...
To tylko jest ikona, cały czas jest taka sama niezależnie czy masz 100% czy 20%. A dlaczego skakał poziom baterii? Nie mam pojęcia, może odczyt analogowy musi się na przykład ustabilizować, zmieniła się temperatura baterii. Ja w sumie nie przyglądałem się temu.marcinl wrote: Wed Jan 17, 2024 1:34 pm Ah okAle to dziwne bo wcześniej było 53% a teraz mam 60%. Rozumiem że ikonka jest taka sama, bez względu na % baterii i wygląda jak pusta bateria ?
Przy kompilacji i próbie wgrania na płytkę dostaję takie błędy:veeroos wrote: Mon Jan 15, 2024 5:57 pm Dzięki kolegom @Adamus10 oraz @MXML, którzy dali bardzo dobre pomysły na uproszczenie kodu, oraz na poprawienie odczytu temperatur ujemnych przerobiłem kod, który teraz wygląda tak:Na początku programu wpisujemy tylko swoje adresy i liczbę czujników.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 <NimBLEDevice.h> #include <NimBLEScan.h> #include <NimBLEAdvertisedDevice.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 2 // seconds const char* xiaomiBleDeviceMacs[] = { //Lista czujników "A4:C1:38:00:00:00", "A4:C1:38:01:01:01", "A4:C1:38:02:02:02", "A4:C1:38:03:03:03", "A4:C1:38:04:04:04", "A4:C1:38:05:05:05", "A4:C1:38:06:06:06", "A4:C1:38:07:07:07", "A4:C1:38:08:08:08", "A4:C1:38:09:09:09" }; const int liczbaElementow = 10; //Liczba czujników byte od[liczbaElementow]={0}; byte bat[liczbaElementow]={0}; int wilg[liczbaElementow]={-1}; float temp[liczbaElementow]={-275}; unsigned long czas_pomiedzy_skanowaniem; unsigned long wifimilis; unsigned long lastReadTime = 0; 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; //#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; byte current_humidity; byte current_batt; word val; NimBLEScan *pBLEScan; void IRAM_ATTR resetModule(){ ets_printf("reboot\n"); esp_restart(); } float current_temperature; class MyAdvertisedDeviceCallbacks : public NimBLEAdvertisedDeviceCallbacks { void onResult(NimBLEAdvertisedDevice* advertisedDevice) { if (advertisedDevice->haveName() && advertisedDevice->haveServiceData()) { 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 Czujnik : public Supla::Sensor::ThermHygroMeter { public: explicit Czujnik(int sensorNumber) : sensorNumber(sensorNumber), temperature(-270), humidity(0) { } double getTemp() { temperature = temp[sensorNumber]; return temperature; } double getHumi() { humidity = wilg[sensorNumber]; return humidity; } private: void iterateAlways() { if (millis() - lastReadTime > 10000) { lastReadTime = millis(); channel.setNewValue(getTemp(), getHumi()); channel.setBatteryLevel(bat[sensorNumber]); } } void onInit() { channel.setNewValue(getTemp(), getHumi()); channel.setBatteryLevel(bat[sensorNumber]); } protected: const int sensorNumber; float temperature; int humidity; }; Czujnik* czujniki[liczbaElementow]; void setup() { Serial.begin(115200); initBluetooth(); // Channels configuration auto buttonCfgRelay = new Supla::Control::Button(BUTTON_CFG_RELAY_GPIO, true, true); buttonCfgRelay->configureAsConfigButton(&SuplaDevice); for (int i = 0; i < liczbaElementow; ++i) { czujniki[i] = new Czujnik(i); czujniki[i]->getChannel()->setFlag(SUPLA_CHANNELSTATE_FIELD_BATTERYPOWERED); czujniki[i]->getChannel()->setFlag(SUPLA_CHANNELSTATE_FIELD_BATTERYLEVEL); } // configure defualt Supla CA certificate SuplaDevice.setSuplaCACert(suplaCACert); SuplaDevice.setSupla3rdPartyCACert(supla3rdCACert); SuplaDevice.setName("Supla Xiaomi"); //SuplaDevice.addFlags(SUPLA_DEVICE_FLAG_SLEEP_MODE_ENABLED); SuplaDevice.begin(); NimBLEDevice::setPower(ESP_PWR_LVL_P9); } void loop() { if (millis() - czas_pomiedzy_skanowaniem > 120000) { Serial.println(F("skanuje bluetooth ")); czas_pomiedzy_skanowaniem = millis(); NimBLEScan* pBLEScan = NimBLEDevice::getScan(); //create new scan pBLEScan->setAdvertisedDeviceCallbacks(new MyAdvertisedDeviceCallbacks()); pBLEScan->setActiveScan(true); //active scan uses more power, but get results faster NimBLEScanResults foundDevices = pBLEScan->start(SCAN_TIME); byte count = foundDevices.getCount(); delay(100); for (int i = 0; i < liczbaElementow; i++) { od[i] = od[i] + 1; } } SuplaDevice.iterate(); if (WiFi.status() != WL_CONNECTED) { if (millis() > wifimilis) { WiFi.begin(); wifimilis = (millis() + 30000) ; } } if (millis() > 86400000){ ESP.restart(); } } void initBluetooth() { NimBLEDevice::init(""); pBLEScan = NimBLEDevice::getScan(); //create new scan pBLEScan->setAdvertisedDeviceCallbacks(new MyAdvertisedDeviceCallbacks()); pBLEScan->setActiveScan(true); //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 = ( t1 == 255 ? -1 : 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; for (int i = 0; i < liczbaElementow; i++) { if (MAC_ADR == xiaomiBleDeviceMacs[i]) { BLE_DEVICE = i ; wyswietl = 1; Wyswietl(); break; // Przerwij pętlę po znalezieniu pasującego adresu MAC } } ///////////////////////////////////////////////////////// } void zerowanie(int index) { if (od[index] > 5) { temp[index] = -275; wilg[index] = -1; bat[index] = 0; od[index] = 0; } } void Wyswietl(){ if(wyswietl == 1){ Serial.print(F("Urządzenie:")); Serial.print(BLE_DEVICE); Serial.print(F(" MAC: ")); Serial.print(MAC_ADR); Serial.print(F(" Temp: ")); Serial.print(current_temperature,1); Serial.print(F("stC. Wilgotnosc: ")); Serial.print(current_humidity); Serial.print(F("%. Bateria: ")); Serial.print(current_batt); Serial.println(F("%.")); temp[BLE_DEVICE] = current_temperature; wilg[BLE_DEVICE] = current_humidity; bat[BLE_DEVICE] = current_batt; od[BLE_DEVICE] = 0; for (int i = 0; i < liczbaElementow; i++) { zerowanie(i); } 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'); }
Code: Select all
Arduino:1.8.19 (Windows Store 1.8.57.0) (Windows 10), Płytka:"ESP32 Dev Module, Disabled, Enabled, Huge APP (3MB No OTA/1MB SPIFFS), 240MHz (WiFi/BT), QIO, 80MHz, 16MB (128Mb), 115200, Core 1, Core 1, None, Disabled"
Szkic używa 1523821 bajtów (48%) pamięci programu. Maksimum to 3145728 bajtów.
Zmienne globalne używają 64608 bajtów (19%) pamięci dynamicznej, pozostawiając 263072 bajtów dla zmiennych lokalnych. Maksimum to 327680 bajtów.
esptool.py v4.5.1
Serial port COM7
Connecting....
Chip is ESP32-D0WDQ6 (revision v1.0)
Features: WiFi, BT, Dual Core, Coding Scheme None
Crystal is 40MHz
MAC: 30:ae:a4:1a:60:8c
Uploading stub...
Running stub...
Stub running...
Configuring flash size...
Flash will be erased from 0x00001000 to 0x00005fff...
Flash will be erased from 0x00008000 to 0x00008fff...
Flash will be erased from 0x0000e000 to 0x0000ffff...
Flash will be erased from 0x00010000 to 0x00185fff...
Compressed 18992 bytes to 13112...
Writing at 0x00001000... (100 %)
Wrote 18992 bytes (13112 compressed) at 0x00001000 in 1.4 seconds (effective 105.2 kbit/s)...
Hash of data verified.
Compressed 3072 bytes to 137...
Writing at 0x00008000... (100 %)
Wrote 3072 bytes (137 compressed) at 0x00008000 in 0.1 seconds (effective 367.8 kbit/s)...
Hash of data verified.
Compressed 8192 bytes to 47...
Writing at 0x0000e000... (100 %)
Wrote 8192 bytes (47 compressed) at 0x0000e000 in 0.1 seconds (effective 602.8 kbit/s)...
Hash of data verified.
Compressed 1529568 bytes to 908181...
Writing at 0x00010000... (1 %)
Writing at 0x00019308... (3 %)
Writing at 0x00025995... (5 %)
Writing at 0x00030fce... (7 %)
Writing at 0x0003a83a... (8 %)
Writing at 0x00050e41... (10 %)
Writing at 0x000601a1... (12 %)
Writing at 0x00066275... (14 %)
Writing at 0x0006bb3a... (16 %)
Writing at 0x000715a6... (17 %)
Writing at 0x0007701d... (19 %)
Writing at 0x0007d2fe... (21 %)
Writing at 0x00083224... (23 %)
Writing at 0x00088fca... (25 %)
Writing at 0x0008ef92... (26 %)
Writing at 0x00094668... (28 %)
Writing at 0x0009a273... (30 %)
Writing at 0x0009f6d1... (32 %)
Writing at 0x000a4c3a... (33 %)
Writing at 0x000a9ec8... (35 %)
Writing at 0x000af37e... (37 %)
Writing at 0x000b467f... (39 %)
Writing at 0x000b9908... (41 %)
Writing at 0x000becae... (42 %)
Writing at 0x000c4b31... (44 %)
Writing at 0x000ca816... (46 %)
Writing at 0x000d0b71... (48 %)
Writing at 0x000d64dd... (50 %)
Writing at 0x000db795... (51 %)
Writing at 0x000e0ac7... (53 %)
Writing at 0x000e5d80... (55 %)
Writing at 0x000ebcf5... (57 %)
Writing at 0x000f1233... (58 %)
Writing at 0x000f6773... (60 %)
Writing at 0x000fbc2f... (62 %)
Writing at 0x00100eea... (64 %)
Writing at 0x001062c8... (66 %)
Writing at 0x0010b72b... (67 %)
Writing at 0x00110cf4... (69 %)
Writing at 0x001164b7... (71 %)
Writing at 0x0011c453... (73 %)
Writing at 0x00121ee9... (75 %)
Writing at 0x0012846c... (76 %)
Writing at 0x00132140... (78 %)
Writing at 0x0013b6d4... (80 %)
Writing at 0x00141be5... (82 %)
Writing at 0x0014961c... (83 %)
Writing at 0x00151ac1... (85 %)
Writing at 0x0015ab16... (87 %)
Writing at 0x0016206b... (89 %)
Writing at 0x001671b9... (91 %)
Writing at 0x0016cb94... (92 %)
Writing at 0x001722de... (94 %)
Writing at 0x00178124... (96 %)
Writing at 0x0017d6cf... (98 %)
Writing at 0x00182fa5... (100 %)
Wrote 1529568 bytes (908181 compressed) at 0x00010000 in 80.0 seconds (effective 152.9 kbit/s)...
Hash of data verified.
Leaving...
Hard resetting via RTS pin...
C:\Users\Marcin\Documents\Arduino\xiaomi_termometr_supla\xiaomi_termometr_supla.ino: In member function 'virtual void MyAdvertisedDeviceCallbacks::onResult(NimBLEAdvertisedDevice*)':
xiaomi_termometr_supla:147:31: error: 'Zamien_litery' was not declared in this scope
zmienna = text01; Zamien_litery(); text01 = zmienna;
^~~~~~~~~~~~~
xiaomi_termometr_supla:166:13: error: 'Konwersja' was not declared in this scope
Konwersja();
^~~~~~~~~
C:\Users\Marcin\Documents\Arduino\xiaomi_termometr_supla\xiaomi_termometr_supla.ino: In function 'void setup()':
xiaomi_termometr_supla:220:3: error: 'initBluetooth' was not declared in this scope
initBluetooth();
^~~~~~~~~~~~~
C:\Users\Marcin\Documents\Arduino\xiaomi_termometr_supla\xiaomi_termometr_supla.ino: In function 'void Konwersja()':
xiaomi_termometr_supla:325:5: error: 'Wyswietl' was not declared in this scope
Wyswietl();
^~~~~~~~
C:\Users\Marcin\Documents\Arduino\xiaomi_termometr_supla\xiaomi_termometr_supla.ino:325:5: note: suggested alternative: 'wyswietl'
Wyswietl();
^~~~~~~~
wyswietl
Znaleziono wiele bibliotek w "WiFi.h"
Wykorzystane: C:\Users\Marcin\Documents\ArduinoData\packages\esp32\hardware\esp32\2.0.10\libraries\WiFi
Niewykorzystane: C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\libraries\WiFi
exit status 1
'Zamien_litery' was not declared in this scope
Ten raport powinien zawierać więcej informacji jeśli w
File -> Preferencje zostanie włączona opcja "Pokaż
szczegółowe informacje podczas kompilacji"
Code: Select all
C:\Users\Marcin\Documents\Arduino\xiaomi_termometr_supla\xiaomi_termometr_supla.ino: In member function 'virtual void MyAdvertisedDeviceCallbacks::onResult(NimBLEAdvertisedDevice*)':
xiaomi_termometr_supla:147:31: error: 'Zamien_litery' was not declared in this scope
zmienna = text01; Zamien_litery(); text01 = zmienna;
^~~~~~~~~~~~~
xiaomi_termometr_supla:166:13: error: 'Konwersja' was not declared in this scope
Code: Select all
15:24:37.984 -> E (512) esp_core_dump_flash: Core dump flash config is corrupted! CRC=0x7bd5c66f instead of 0x0
15:24:37.984 -> Rebooting...
15:24:37.984 -> ets Jun 8 2016 00:22:57
15:24:37.984 ->
15:24:37.984 -> rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
15:24:37.984 -> configsip: 0, SPIWP:0xee
15:24:37.984 -> clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
15:24:37.984 -> mode:DIO, clock div:1
15:24:37.984 -> load:0x3fff0030,len:1344
15:24:37.984 -> load:0x40078000,len:13964
15:24:37.984 -> load:0x40080400,len:3600
15:24:37.984 -> entry 0x400805f0
15:24:38.486 -> E (489) spi_flash: Detected size(4096k) smaller than the size in the binary image header(16384k). Probe failed.
15:24:38.486 ->
15:24:38.486 -> assert failed: do_core_init startup.c:328 (flash_ret == ESP_OK)
15:24:38.486 ->
15:24:38.486 ->
15:24:38.486 -> Backtrace: 0x40083b19:0x3ffe3ab0 0x400961bd:0x3ffe3ad0 0x4009bd5d:0x3ffe3af0 0x401053fe:0x3ffe3c20 0x4008322d:0x3ffe3c50 0x40079316:0x3ffe3c90 |<-CORRUPTED
15:24:38.486 ->