├── .gitignore ├── LoF.ino ├── README.md ├── fsinfo └── version.h /.gitignore: -------------------------------------------------------------------------------- 1 | *.bin 2 | backup/*.* 3 | -------------------------------------------------------------------------------- /LoF.ino: -------------------------------------------------------------------------------- 1 | /* Life of Flowers. 2 | * Based on: ESP8266, AM2302 and Blynk. 3 | * Created in Arduino IDE. 4 | * For more details please visit http://openwind.ru 5 | * Contact us: hello@openwind.ru 6 | */ 7 | 8 | #include 9 | //#include 10 | #include "version.h" 11 | #include 12 | 13 | #define BLYNK_PRINT Serial 14 | //blynk 15 | #include 16 | #include 17 | 18 | //RTC Time 19 | #include 20 | #include 21 | 22 | //WiFiManager 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | //LED status 29 | #include 30 | 31 | #include 32 | 33 | #define DHTPIN 12 34 | #define DHTTYPE DHT22 // DHT 22 (AM2302), AM2321 35 | DHT dht(DHTPIN, DHTTYPE); 36 | 37 | #define BLYNK_GREEN "#23C48E" 38 | #define BLYNK_BLUE "#04C0F8" 39 | #define BLYNK_YELLOW "#ED9D00" 40 | #define BLYNK_RED "#D3435C" 41 | #define BLYNK_DARK_BLUE "#5F7CD8" 42 | 43 | WidgetLED led1(V10); 44 | WidgetLED led2(V11); 45 | Ticker ticker; 46 | 47 | WidgetRTC rtc; 48 | 49 | int ADCPin = A0; 50 | int PowerADCPin = 4; 51 | int PWMPin = 15; 52 | int BPin = 14; 53 | int C_DHTPin = 13; 54 | int buzPin = 5; 55 | int ledPin = 15; 56 | int buttonPin = 0; 57 | int buttonState = 1; 58 | 59 | float adclight; 60 | float adcwater; 61 | float adcbattery; 62 | float h; 63 | float t; 64 | float f; 65 | 66 | int adcwater_int; 67 | int adclight_int; 68 | int adcbattery_int; 69 | int h_int; 70 | int t_int; 71 | 72 | 73 | // to del? 74 | float old_h = 0; 75 | float old_t = 0; 76 | float old_f = 0; 77 | 78 | bool DHTreadOK; //false if not read 79 | 80 | char blynk_token[34]; 81 | 82 | //add EEPROM read + blynk widget 83 | double sleep_time = 3600; // 60 min 84 | 85 | bool shouldSaveConfig = false; //flag for saving data 86 | 87 | int hour_i; 88 | int minute_i; 89 | int second_i; 90 | int day_i; 91 | int month_i; 92 | 93 | String hour_s; 94 | String minute_s; 95 | String second_s; 96 | String day_s; 97 | String month_s; 98 | 99 | String currentTime; 100 | String currentDate; 101 | 102 | //int address = 0; 103 | 104 | // Check flash size 105 | String realSize = String(ESP.getFlashChipRealSize()); 106 | String ideSize = String(ESP.getFlashChipSize()); 107 | bool flashCorrectlyConfigured = realSize.equals(ideSize); 108 | 109 | //if(flashCorrectlyConfigured){ 110 | // Serial.print("\r\nflash correctly configured, SPIFFS starts, IDE size: " + ideSize + ", match real size: " + realSize); 111 | //} 112 | //else{ 113 | // Serial.print("\r\nflash incorrectly configured, SPIFFS cannot start, IDE size: " + ideSize + ", real size: " + realSize); 114 | //} 115 | 116 | 117 | // NVM Data 118 | #define RTCMemOffset 10 // arbitrary location 119 | #define MAGIC_NUMBER 56 // used to know if the memory is good and been written to 120 | 121 | typedef struct{ 122 | int wakeCount; 123 | bool bFirstTime; 124 | bool bShouldRepeat; 125 | int magicNumber; 126 | } nvmData; 127 | 128 | nvmData sleepMemory; 129 | 130 | bool bDoneSleeping; 131 | 132 | BLYNK_CONNECTED(){ 133 | rtc.begin(); 134 | setSyncInterval(1); // interval of RTC sync 135 | Blynk.syncAll(); 136 | // rtc.begin(); 137 | // setSyncInterval(1); // interval of RTC sync 138 | // Blynk.syncAll(); 139 | } 140 | 141 | WidgetTerminal terminal(V6); 142 | 143 | void tick(){ 144 | //toggle state 145 | int state = digitalRead(ledPin); 146 | digitalWrite(ledPin, !state); 147 | } 148 | 149 | void configModeCallback (WiFiManager *myWiFiManager){ 150 | //gets called when WiFiManager enters configuration mode 151 | Serial.println("Entered config mode"); 152 | Serial.println(WiFi.softAPIP()); 153 | //if you used auto generated SSID, print it 154 | Serial.println(myWiFiManager->getConfigPortalSSID()); 155 | //entered config mode, make led toggle faster 156 | ticker.attach(0.2, tick); 157 | } 158 | 159 | void saveConfigCallback(){ //callback notifying us of the need to save config 160 | Serial.println("Should save config"); 161 | shouldSaveConfig = true; 162 | ticker.attach(0.2, tick); // led toggle faster 163 | 164 | } 165 | 166 | 167 | //int n; 168 | float adcRead[3]; 169 | void quickSort(float *s_arr, int first, int last){ 170 | if (first < last){ 171 | int left = first, right = last, middle = s_arr[(left + right) / 2]; 172 | do{ 173 | while (s_arr[left] < middle) left++; 174 | while (s_arr[right] > middle) right--; 175 | if (left <= right){ 176 | int tmp = s_arr[left]; 177 | s_arr[left] = s_arr[right]; 178 | s_arr[right] = tmp; 179 | left++; 180 | right--; 181 | } 182 | } 183 | while (left <= right); 184 | quickSort(s_arr, first, right); 185 | quickSort(s_arr, left, last); 186 | } 187 | } 188 | 189 | void analogReadMedian(){ 190 | //add for 191 | adcRead[0] = analogRead(ADCPin); 192 | delay(10); 193 | adcRead[1] = analogRead(ADCPin); 194 | delay(10); 195 | adcRead[2] = analogRead(ADCPin); 196 | } 197 | 198 | void readADC_median2(int input){ 199 | switch(input){ 200 | case 1 : 201 | digitalWrite(BPin, HIGH); 202 | digitalWrite(C_DHTPin, LOW); 203 | delay(50); 204 | analogReadMedian(); 205 | quickSort(adcRead, 0, 2); 206 | adcbattery = adcRead[1] * 43 / 10; 207 | digitalWrite(BPin, LOW); 208 | break; 209 | case 2 : 210 | digitalWrite(BPin, LOW); 211 | digitalWrite(C_DHTPin, LOW); 212 | analogWrite(PWMPin, 412); 213 | delay(50); 214 | analogReadMedian(); 215 | quickSort(adcRead, 0, 2); 216 | adcwater = adcRead[1]; 217 | analogWrite(PWMPin, 0); 218 | break; 219 | case 3 : 220 | digitalWrite(BPin, LOW); 221 | digitalWrite(C_DHTPin, HIGH); 222 | delay(50); 223 | analogReadMedian(); 224 | quickSort(adcRead, 0, 2); 225 | adclight = adcRead[1]; 226 | break; 227 | default : 228 | delay(1); 229 | } 230 | } 231 | 232 | void readDHT22(){ 233 | 234 | DHTreadOK = false; 235 | int i = 0; 236 | Serial.print("\n\rReading DHT22 sensor:"); 237 | while (i < 5 && !DHTreadOK){ 238 | delay(i*75); 239 | h = dht.readHumidity(); 240 | t = dht.readTemperature(); 241 | f = dht.readTemperature(true); // Read temperature as Fahrenheit (isFahrenheit = true) 242 | 243 | if (isnan(h) || isnan(t) || isnan(f)){ 244 | Serial.print("."); 245 | i++; 246 | } 247 | else{ 248 | DHTreadOK = true; 249 | if (!isnan(h)) old_h = h; 250 | if (!isnan(t)) old_t = t; 251 | if (!isnan(f)) old_f = f; 252 | } 253 | if (DHTreadOK){ 254 | Serial.print(" ok"); 255 | } 256 | else{ 257 | Serial.print(" failed"); 258 | } 259 | } 260 | } 261 | 262 | void tones(uint8_t _pin, unsigned int frequency, unsigned long duration){ 263 | pinMode (_pin, OUTPUT); 264 | analogWriteFreq(frequency); 265 | analogWrite(_pin,500); 266 | delay(duration); 267 | analogWrite(_pin,0); 268 | } 269 | 270 | void setup(){ 271 | 272 | WiFi.mode(WIFI_OFF); 273 | WiFi.forceSleepBegin(); 274 | delay(1); 275 | dht.begin(); 276 | Serial.begin(9600); 277 | 278 | /* Woke up and entered setup */ 279 | bDoneSleeping = false; 280 | 281 | if(ESP.rtcUserMemoryRead((uint32_t)RTCMemOffset, (uint32_t*) &sleepMemory, sizeof(sleepMemory))){ 282 | if(sleepMemory.magicNumber != MAGIC_NUMBER) // memory got corrupt or this is the first time 283 | { 284 | sleepMemory.bFirstTime = true; 285 | sleepMemory.bShouldRepeat = false; 286 | sleepMemory.magicNumber = MAGIC_NUMBER; 287 | sleepMemory.wakeCount = 4; 288 | } 289 | else 290 | { 291 | sleepMemory.wakeCount += 1; // incrememnt the sleep counter 292 | sleepMemory.bFirstTime = false; 293 | } 294 | 295 | if(sleepMemory.wakeCount >= 4 || sleepMemory.bShouldRepeat) // reset the counter and do whatever else you need to do since 4 hours have passed 296 | { 297 | sleepMemory.wakeCount = 0; 298 | sleepMemory.bShouldRepeat = false; 299 | bDoneSleeping = true; 300 | } 301 | 302 | ESP.rtcUserMemoryWrite((uint32_t)RTCMemOffset, (uint32_t*) &sleepMemory, sizeof(sleepMemory)); // write the new values to memory 303 | } 304 | 305 | if(!bDoneSleeping){ 306 | Serial.print("\r\nsleepMemory.wakeCount: "); 307 | Serial.print(sleepMemory.wakeCount); 308 | Serial.print("\r\nGo to SLEEP"); 309 | sleep_time = sleep_time * 1000000; 310 | ESP.deepSleep(sleep_time, WAKE_RF_DISABLED); 311 | } 312 | else{ 313 | Serial.print("\r\nsleepMemory.wakeCount: "); 314 | Serial.print(sleepMemory.wakeCount); 315 | Serial.print("\r\nGo to WORK"); 316 | } 317 | 318 | 319 | pinMode(PowerADCPin, OUTPUT); 320 | pinMode(PWMPin, OUTPUT); 321 | 322 | pinMode(BPin, OUTPUT); 323 | pinMode(C_DHTPin, OUTPUT); 324 | 325 | digitalWrite(BPin, LOW); 326 | digitalWrite(C_DHTPin, LOW); 327 | digitalWrite(PowerADCPin, LOW); 328 | analogWrite(PWMPin, 0); 329 | 330 | //pinMode(ledPin, OUTPUT); 331 | pinMode(buzPin, OUTPUT); 332 | 333 | pinMode(buttonPin, INPUT); 334 | pinMode(ADCPin, INPUT); 335 | 336 | //ESP.wdtDisable(); 337 | //SPIFFS.format(); 338 | //read configuration from FS json 339 | Serial.print("\n\rmounting FS..."); 340 | if (SPIFFS.begin()){ 341 | Serial.println("mounted file system"); 342 | if (SPIFFS.exists("/config.json")) { 343 | //file exists, reading and loading 344 | Serial.println("reading config file"); 345 | File configFile = SPIFFS.open("/config.json", "r"); 346 | if (configFile){ 347 | Serial.println("opened config file"); 348 | size_t size = configFile.size(); 349 | // Allocate a buffer to store contents of the file. 350 | std::unique_ptr buf(new char[size]); 351 | 352 | configFile.readBytes(buf.get(), size); 353 | DynamicJsonBuffer jsonBuffer; 354 | JsonObject& json = jsonBuffer.parseObject(buf.get()); 355 | json.printTo(Serial); 356 | if (json.success()) { 357 | Serial.println("\nparsed json"); 358 | strcpy(blynk_token, json["blynk_token"]); 359 | } 360 | else{ 361 | Serial.println("Failed to load json config"); 362 | } 363 | } 364 | } 365 | } 366 | else{ 367 | Serial.println("Failed to mount FS"); 368 | } 369 | 370 | tones(5,1000,300); 371 | //analogWrite(PWMPin, 1000); 372 | delay(500); 373 | //analogWrite(PWMPin, 0); 374 | // digitalWrite(ledPin, HIGH); 375 | // digitalWrite(ledPin, LOW); 376 | 377 | buttonState = digitalRead(buttonPin); 378 | 379 | //buttonState = 1; 380 | if (buttonState == 0){ 381 | //SPIFFS.format(); 382 | 383 | //WiFi.disconnect(true); 384 | 385 | Serial.println("Enter WiFi config mode"); 386 | ticker.attach(0.6, tick); 387 | 388 | WiFiManagerParameter custom_blynk_token("blynk", "blynk token", blynk_token, 33); // was 32 length ??? 389 | WiFiManager wifiManager; 390 | 391 | 392 | 393 | //set minimu quality of signal so it ignores AP's under that quality 394 | //defaults to 8% 395 | //wifiManager.setMinimumSignalQuality(); 396 | 397 | //set callback that gets called when connecting to previous WiFi fails, and enters Access Point mode 398 | wifiManager.setAPCallback(configModeCallback); 399 | 400 | //set config save notify callback 401 | wifiManager.setSaveConfigCallback(saveConfigCallback); 402 | 403 | wifiManager.addParameter(&custom_blynk_token); //add all your parameters here 404 | 405 | //sets timeout until configuration portal gets turned off 406 | //useful to make it all retry or go to sleep, in seconds 407 | wifiManager.setTimeout(300); // 5 minutes to enter data and then ESP resets to try again. 408 | 409 | //fetches ssid and pass and tries to connect 410 | //if it does not connect it starts an access point with the specified name 411 | 412 | //wifiManager.resetSettings(); 413 | 414 | if (!wifiManager.autoConnect("LoF - tap to config")){ 415 | ESP.restart(); 416 | } 417 | ticker.detach(); 418 | strcpy(blynk_token, custom_blynk_token.getValue()); //read updated parameters 419 | if (shouldSaveConfig){ //save the custom parameters to FS 420 | Serial.println("saving config"); 421 | DynamicJsonBuffer jsonBuffer; 422 | JsonObject& json = jsonBuffer.createObject(); 423 | json["blynk_token"] = blynk_token; 424 | 425 | File configFile = SPIFFS.open("/config.json", "w"); 426 | if (!configFile) { 427 | Serial.println("Failed to open config file for writing"); 428 | } 429 | json.printTo(Serial); 430 | json.printTo(configFile); 431 | configFile.close(); 432 | //end save 433 | 434 | delay(1000); 435 | Serial.println("Restart ESP to apply new WiFi settings.."); 436 | ESP.restart(); 437 | } 438 | 439 | } 440 | 441 | Serial.print("\n\rLet's start!"); 442 | Serial.print("\n\rblynk token: " + String(blynk_token)); 443 | Serial.print("\n\rSoftware version: " + String(SW_VERSION)); 444 | 445 | analogWriteFreq(75000); 446 | 447 | } 448 | void loop(){ 449 | 450 | Serial.print("\n\rWiFi status: "); 451 | Serial.print(WiFi.SSID()); 452 | Serial.print(" "); 453 | Serial.print(WiFi.status()); 454 | 455 | if(!flashCorrectlyConfigured){ 456 | Serial.print("\r\nflash incorrectly configured, SPIFFS cannot start, IDE size: " + ideSize + ", real size: " + realSize); 457 | } 458 | Serial.print("\r\nDo work"); 459 | 460 | 461 | digitalWrite(PowerADCPin, HIGH); 462 | for (int i = 1; i < 4; i++){ 463 | readADC_median2(i); 464 | } 465 | 466 | // todo smth 467 | delay(4000); 468 | //digitalWrite(ledPin, HIGH); 469 | analogWrite(ledPin, 1000); 470 | delay(1000); 471 | readDHT22(); 472 | digitalWrite(C_DHTPin, LOW); 473 | digitalWrite(PowerADCPin, LOW); 474 | analogWrite(ledPin, 0); 475 | 476 | adcwater_int = adcwater; 477 | adclight_int = adclight; 478 | adcbattery_int = adcbattery; 479 | h_int = h; 480 | t_int = t; 481 | 482 | if (adcwater_int > 880) adcwater_int = 880; 483 | if (adcwater_int < 680) adcwater_int = 680; 484 | 485 | adcwater_int = (adcwater_int - 680) / 2; 486 | 487 | Serial.print("\r\nResults (W L T H B): "); 488 | Serial.print(adcwater_int); 489 | Serial.print(" "); 490 | Serial.print(adclight_int); 491 | Serial.print(" "); 492 | Serial.print(t); 493 | Serial.print(" "); 494 | Serial.print(h); 495 | Serial.print(" "); 496 | Serial.print(adcbattery_int); 497 | Serial.print(" adcwater: "); 498 | Serial.print(adcwater); 499 | 500 | Serial.print("\r\nWake up modem:"); 501 | WiFi.forceSleepWake(); 502 | WiFi.mode(WIFI_STA); 503 | delay(100); 504 | 505 | if (WiFi.SSID()){ 506 | WiFi.begin(); 507 | } 508 | 509 | // Serial.print("\n\rWiFi network: "); 510 | // Serial.print(WiFi.SSID()); 511 | // Serial.print("\n\rWiFi status: "); 512 | // Serial.print(WiFi.status()); 513 | // Serial.print("\r\nRSSI: "); 514 | // Serial.print(WiFi.RSSI()); 515 | // Serial.print("\n\rIP: "); 516 | // Serial.print(WiFi.localIP()); 517 | 518 | buttonState = digitalRead(buttonPin); 519 | 520 | if (buttonState == 0){ 521 | Serial.print("\n\rReset WiFi settings"); 522 | WiFiManager wifiManager; 523 | wifiManager.resetSettings(); 524 | } 525 | digitalWrite(ledPin, LOW); 526 | int t_w; 527 | int t_b; 528 | 529 | int i = 100; 530 | while(WiFi.status() != 3 && i){ 531 | Serial.print("-"); 532 | delay(200); 533 | i--; 534 | } 535 | 536 | t_w = (100-i)/5; 537 | 538 | if (WiFi.status() == 3){ 539 | if (blynk_token[0] != '\0'){ 540 | //Blynk.config(blynk_token); 541 | //Blynk.config(blynk_token, "blynk-cloud.com", 8442); 542 | //Blynk.config(blynk_token, "h.100010001.xyz", 8442); 543 | //Blynk.config(blynk_token, IPAddress(192,168,0,250), 8080); 544 | Blynk.config(blynk_token, "b.openwind.ru", 8080); 545 | Blynk.connect(); 546 | } 547 | Serial.print("\r\nConnecting blynk:"); 548 | 549 | i = 100; 550 | while(!Blynk.connected() && i){ 551 | Serial.print("."); 552 | delay(200); 553 | i--; 554 | } 555 | t_b = (100-i)/5; 556 | 557 | if (Blynk.connected()){ 558 | 559 | hour_i = hour(); 560 | minute_i = minute(); 561 | second_i = second(); 562 | day_i = day(); 563 | month_i = month(); 564 | 565 | hour_s = String(hour_i); 566 | minute_s = String(minute_i); 567 | second_s = String(second_i); 568 | day_s = String(day_i); 569 | month_s = String(month_i); 570 | 571 | if (hour_i < 10) hour_s = "0" + hour_s; 572 | if (minute_i < 10) minute_s = "0" + minute_s; 573 | if (second_i < 10) second_s = "0" + second_s; 574 | if (day_i < 10) day_s = "0" + day_s; 575 | if (month_i < 10) month_s = "0" + month_s; 576 | 577 | currentTime = hour_s + ":" + minute_s + ":" + second_s; 578 | currentDate = day_s + "/" + month_s + "/" + String(year()); 579 | 580 | Blynk.virtualWrite(V1, adclight_int); 581 | Blynk.virtualWrite(V2, adcwater); 582 | 583 | if(DHTreadOK){ 584 | Blynk.virtualWrite(V3, t_int); 585 | Blynk.virtualWrite(V4, h_int); 586 | led2.on(); 587 | led2.setColor(BLYNK_GREEN); 588 | } 589 | else{ 590 | led2.on(); 591 | led2.setColor(BLYNK_RED); 592 | } 593 | Blynk.virtualWrite(V5, adcbattery_int); 594 | Blynk.virtualWrite(V7, t_w); 595 | Blynk.virtualWrite(V8, t_b); 596 | 597 | terminal.print("\r\nLast sync: " + currentDate + " " + currentTime); 598 | terminal.print("\r\nwifi blynk timeout (v7-8): " + String(t_w) + " " + String(t_b)); 599 | terminal.print("\r\nIDE size: " + ideSize + ", real size: " + realSize); 600 | terminal.flush(); 601 | 602 | Serial.print("\r\nLast sync:" + currentDate + " " + currentTime); 603 | Serial.print("\r\nSync blynk!"); 604 | } 605 | else{ 606 | Serial.print("\r\nblynk not connected."); 607 | sleep_time = 1800; 608 | 609 | sleepMemory.bShouldRepeat = true; 610 | ESP.rtcUserMemoryWrite((uint32_t)RTCMemOffset, (uint32_t*) &sleepMemory, sizeof(sleepMemory)); 611 | } 612 | } 613 | else{ 614 | Serial.print("\r\nWiFi not connected."); 615 | sleep_time = 1800; 616 | sleepMemory.bShouldRepeat = true; 617 | ESP.rtcUserMemoryWrite((uint32_t)RTCMemOffset, (uint32_t*) &sleepMemory, sizeof(sleepMemory)); 618 | 619 | // ADD few retries and then reset WiFi sett. + EEPROM 620 | } 621 | 622 | Serial.print("\n\rWiFi status: "); 623 | Serial.print(WiFi.SSID()); 624 | Serial.print(" "); 625 | Serial.print(WiFi.status()); 626 | 627 | Serial.print("\r\nwifi blynk timeout: "); 628 | Serial.print(t_w); 629 | Serial.print(" "); 630 | Serial.print(t_b); 631 | Serial.print("\r\nDeep sleep for: "); 632 | Serial.print(sleep_time); 633 | Serial.print(" sec"); 634 | sleep_time = sleep_time * 1000000; 635 | 636 | delay(10); 637 | 638 | //WAKE_RF_DISABLED to keep the WiFi radio disabled when we wake up 639 | ESP.deepSleep(sleep_time, WAKE_RF_DISABLED); 640 | 641 | } 642 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Life of Flowers - LoF 2 | Life of Flowers. Sensor for happy flower life. 3 | 4 | Скетч Arduino IDE для датчика влажности почвы, освещенности и температуры\влажновсти воздуха OpenWindAir. 5 | В проекте использованы сторонние библиотеки, все права на которые принадлежат их Авторам. 6 | 7 | Основные возможности датчика: 8 | * Измерение влажности почвы. 9 | * Измерение температуры \ влажности датчиком AM2302. 10 | * Измерение освещенности. 11 | * Светодиодная и звуковая индикация. 12 | * Вывод результатов измерения: Blynk, MQTT (не реализовано, но возможно). 13 | * Обновление по USB. 14 | * Настройка всех параметров через WiFi. 15 | * Питание от двух батареек ААА (работа до года). 16 | 17 | Особенности проекта: 18 | * Автоматический инкремент версии ПО при сборке в Arduino IDE. 19 | * Настройка параметров WiFi и MQTT осуществляется через Сaptive portal. 20 | * Изменение пользовательских настроек осуществляеся через приложение Blynk. 21 | 22 | Демо: 23 | * Скачайте приложение Blynk для iOS https://itunes.apple.com/us/app/blynk-control-arduino-raspberry/id808760481?ls=1&mt=8 24 | * Скачайте приложение Blynk для Android https://play.google.com/store/apps/details?id=cc.blynk 25 | * Просканируйте в приложение QR код http://openwind.ru/OpenWindAir-demo-QR.png (todo поменять QR) 26 | * Перед вами полноценное демо. 27 | 28 | Руководство пользователя: 29 | * 30 | 31 | Вопросы и пожелания отправляйте по адресу hello@openwind.ru 32 | 33 | 34 | -------------------------------------------------------------------------------- /fsinfo: -------------------------------------------------------------------------------- 1 | String sysInfo() 2 | { 3 | FSInfo fs_info; 4 | SPIFFS.info(fs_info); 5 | String t = "--- FS INFO ---\n"; 6 | t += "totalBytes: " + String(fs_info.totalBytes) + "\n"; 7 | t += "usedBytes: " + String(fs_info.usedBytes) + "\n"; 8 | t += "blockSize: " + String(fs_info.blockSize) + "\n"; 9 | t += "pageSize: " + String(fs_info.pageSize) + "\n"; 10 | t += "maxOpenFiles: " + String(fs_info.maxOpenFiles) + "\n"; 11 | t += "maxPathLength: " + String(fs_info.maxPathLength) + "\n"; 12 | t += "\n"; 13 | t += "--- MISC ESP PROPERTIES --- \n"; 14 | t += "getFreeSketchSpace(): " + String(ESP.getFreeSketchSpace()) + "\n"; 15 | t += "getSketchSize(): " + String(ESP.getSketchSize()) + "\n"; 16 | t += "getChipId(): " + String(ESP.getChipId()) + "\n"; 17 | t += "getFlashChipMode(): " + String(ESP.getFlashChipMode()) + "\n"; 18 | t += "getFlashChipId(): " + String(ESP.getFlashChipId()) + "\n"; 19 | t += "getFlashChipRealSize(): " + String(ESP.getFlashChipRealSize()) + "\n"; 20 | t += "getFlashChipSize(): " + String(ESP.getFlashChipSize()) + "\n"; 21 | t += "getFlashChipSizeByChipId(): " + String(ESP.getFlashChipSizeByChipId()) + "\n"; 22 | t += "getFlashChipSpeed(): " + String(ESP.getFlashChipSpeed()) + "\n"; 23 | t += "checkFlashConfig(): " + String(ESP.checkFlashConfig()) + "\n"; 24 | t += "getBootMode(): " + String(ESP.getBootMode()) + "\n"; 25 | t += "getBootVersion(): " + String(ESP.getBootVersion()) + "\n"; 26 | t += "getCoreVersion(): " + String(ESP.getCoreVersion()) + "\n"; 27 | t += "getCpuFreqMHz(): " + String(ESP.getCpuFreqMHz()) + "\n"; 28 | t += "getCycleCount(): " + String(ESP.getCycleCount()) + "\n"; 29 | t += "getResetInfo(): " + String(ESP.getResetInfo()) + "\n"; 30 | t += "getResetReason(): " + String(ESP.getResetReason()) + "\n"; 31 | rst_info *myResetInfo; 32 | myResetInfo = ESP.getResetInfoPtr(); 33 | t += "getResetInfoPtr(): " + String(myResetInfo->reason); 34 | 35 | return t; 36 | } -------------------------------------------------------------------------------- /version.h: -------------------------------------------------------------------------------- 1 | #define SW_VERSION "0.0.452" 2 | --------------------------------------------------------------------------------