Closed Alaa-Aim closed 2 years ago
Hi @Alaa-Aim it should work out of the box. PSRAM could be used to allocate circular buffers for time series data. So you would be able to increase it's size considerably and collect sampling history for much longer time. This feature is still needs further improvement, like samling daily/hourly/minute stat. I'll implement it once I find some free time slot for this :)
No special settings required, you just need to specify your board name in platformio.ini's env. Once PSRAM is detected pzem-edl will use it to store samples. If build with debuging enabled you could see a message in console log like
"SRAM: heap %d, free %d"
"SPI-RAM: heap %d, free %d\n"
For the platformio.ini you may need something like this, although I do not remember if those keys are still mandatory.
[env:esp32psram]
platform = espressif32
board = esp-wrover-kit
framework = arduino
build_flags =
-DBOARD_HAS_PSRAM
-mfix-esp32-psram-cache-issue
Pls, provide your feedback one tested :) It's much appreciated!
@vortigont , I have ESP32 DevKitC V4 , WROVER with 16MB Memory & 4MB PSRAM, I modified the platformio.ini file as you mentioned in you reply, below what showed up in serial monitor :
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:2 load:0x3fff0018,len:4 load:0x3fff001c,len:1044 load:0x40078000,len:10124 load:0x40080400,len:5828 entry 0x400806a8 Starting EspEM... UI: Config file load OK! UI: Creating system vars UI: Creating application vars UI REGISTER: b_espem UI REGISTER: b_emset UI: Creating webui vars UI REGISTER: settings UI REGISTER: sh_sec UI REGISTER: shname UI REGISTER: set_wifi UI REGISTER: set_wifiAP UI REGISTER: set_mqtt UI REGISTER: set_time UI REGISTER: lang UI REGISTER: reboot UI REGISTER: time UI REGISTER: s_cfgcl UI REGISTER: a_setem UI REGISTER: a_uart UI REGISTER: a_pzopt UI REGISTER: dctl* UI READ KEY: 'm_pref' VAL: '818F14' UI READ KEY: 'm_host' VAL: '' UI READ KEY: 'm_port' VAL: '' UI READ KEY: 'm_user' VAL: '' UI READ KEY: 'm_pass' VAL: '' UI: MQTT host is empty - disabled! UI CONFIG: {"m_host":"","m_port":"","m_user":"","m_pass":"","m_pref":"818F14","m_tupd":"30","dctlupdrt":2,"ems_prd":1,"emplsz":300,"uart":1,"rx":-1,"tx":-1,"eoffset":0}UI READ KEY: 'TZSET' VAL: '' UI WiFi: start in STA mode [E][WiFiSTA.cpp:221] begin(): connect failed! generate autohostname: EmbUI-818F14 UI WiFi: STA reconecting... espem.begin: port: 1, rx_pin: -1, tx_pin:-1 Autopolling enabled SRAM: heap 321732, free 214344 SPI-RAM: heap 4194236, free 4185836 UI WiFi: set AP params to SSID:EmbUI-818F14, pwd: UI mDNS: responder started: EmbUI-818F14.local UI WiFi: Switch to AP/STA mode
After connecting to the WiFI below shows on the serial monitor
[E][vfs_api.cpp:64] open(): /littlefs/index.html does not exist UI: ws[/ws][1] connect MEM: 199812 UI: section begin:'root374234344' [#0] 7983 free UI: section begin:'menu' [#1] 7930 free UI: Frame add obj 79 b, mem:262/8192...OK idx:0 MEM: 191276 UI: Frame add obj 77 b, mem:357/8192...OK idx:1 MEM: 191276 UI: Frame add obj 72 b, mem:438/8192...OK idx:2 MEM: 191276 UI: section end:'menu' [#1] MEM: 191348 UI: json_frame_flush UI: section end:'root374234344' [#0] MEM: 191412 UI: Opening network setup section UI: section begin:'root374261847' [#0] 8080 free UI: section begin:'netwrk' [#1] 7977 free UI: section begin:'shname' [#2] 7871 free UI: section begin:'' [#3] 7801 free
UI: json_frame_flush UI: section end:'root519095368' [#0] MEM: 200816 UI: section begin:'root521095330' [#0] 402 free UI: Frame add obj 47 b, mem:110/512...OK idx:0 MEM: 200796 UI: Frame add obj 45 b, mem:173/512...OK idx:1 MEM: 200796 UI: Frame add obj 43 b, mem:225/512...OK idx:2 MEM: 200796 UI: Frame add obj 43 b, mem:275/512...OK idx:3 MEM: 200796 UI: Frame add obj 43 b, mem:325/512...OK idx:4 MEM: 200796 UI: Frame add obj 43 b, mem:375/512...OK idx:5 MEM: 200796 UI: Frame add obj 44 b, mem:425/512...OK idx:6 MEM: 200796
UI: json_frame_flush UI: section end:'root521095330' [#0] MEM: 200816 UI: section begin:'root521135729' [#0] 916 free UI: Frame add obj 74 b, mem:108/1024...OK idx:0 MEM: 198312 UI: Frame add obj 67 b, mem:192/1024...OK idx:1 MEM: 198312 UI: Frame add obj 70 b, mem:261/1024...OK idx:2 MEM: 198312 UI: json_frame_flush
but due to the limitations of the WROVER UART I had to compile it again without debug to use the pins 1 & 3 for Tx & Rx , it seems like the PZEM not detected , the WebUI shows err, but the Tx & Rx LEDs in the PZEM are blinking like it working. Please advise...
after playing around, I changed the TX & RX pins in the WwbUI, in EPS32 WROOM Rx pin 3 & Tx pin 1, in ESP32 WORVER Rx pin 1 & Tx Pin 3, but the memory still not changed, seems like the PSRAM not utilized as shown in screen shoot below
please advise ....
Hi @Alaa-Aim, the WebUI shows only SRAM memory heap. PSRAM heap is not displayed sine not all boards has PSRAM and I do not want to display confusing zeros there. The actual info could be seen in console log as you've posted above.
Hi @vortigont many thanks for your efforts and replies, so the log seems fine? the PSRAM been utilized ? but the memory seems to be lower than noraml ESP32, i mean lower that the ESP31 without PSRAM!! is it OK? last but not least my platformio.ini file as below :
[platformio] description = Firmware for ESP32 based boards to interface with PeaceFair PZEM PowerMeters src_dir = espem default_envs = espem extraconfigs = user*.ini
[common] board_build.filesystem = littlefs framework = arduino src_build_flags = !python flags.py -std=gnu++14 -DUSE_FTP src_build_unflags = -std=gnu++11 lib_deps = https://github.com/charno/FTPClientServer https://github.com/vortigont/EmbUI.git#v2.6 monitor_speed = 115200 ;extra_scripts = .pio/strip-floats.py
; debug flags [debug] espem_serial = -DESPEM_DEBUG=Serial app_serial = ${debug.espem_serial} -DEMBUI_DEBUG -DEMBUI_DEBUG_PORT=Serial all_serial = ${debug.app_serial} -DDEBUG_ESP_PORT=Serial espem_serial1 = -DESPEM_DEBUG=Serial1 app_serial1 = ${debug.espem_serial1} -DEMBUI_DEBUG -DEMBUI_DEBUG_PORT=Serial1 all_serial1 = ${debug.espem_serial1} -DDEBUG_ESP_PORT=Serial1
[esp32_base] extends = common platform = espressif32 board = esp-wrover-kit upload_speed = 460800 monitor_filters = esp32_exception_decoder build_flags = -DUSE_LittleFS -DCONFIG_LITTLEFS_FOR_IDF_3_2 ; -DTZONE="MSK-3" ; -DCOUNTRY="ru" extra_scripts = replace_fs.py
[PZEM004T] lib_deps_8266 = ${esp8266_base.lib_deps} PZEM004T lib_deps_esp32 = ${esp32_base.lib_deps} PZEM004T
[PZEM004Tv30] lib_deps_8266 = ${esp8266_base.lib_deps} https://github.com/vortigont/PZEM-004T-v30#vortigont lib_deps_esp32 = ${esp32_base.lib_deps} https://github.com/vortigont/LinkedList ;https://github.com/vortigont/PZEM-004T-v30#vortigont ;https://github.com/vortigont/pzem-edl
; ===== Build ENVs ====== [env] extends = common ;build_flags = ; -DCOUNTRY="ru" // Country double-letter code, used for NTP pool selection ; -DNO_GLOBAL_SERIAL ; -DNO_GLOBAL_SERIAL1
; ESP32 with PZEM004Tv30 [env:espem] extends = esp32_base lib_deps = ${esp32_base.lib_deps} https://github.com/vortigont/pzem-edl ; vortigont/pzem-edl @ ~1.0.0 build_flags = ${esp32_base.build_flags} -DCOUNTRY="ru" -DBOARD_HAS_PSRAM -mfix-esp32-psram-cache-issue
;src_build_flags = ; ${common.src_build_flags} ;src_build_unflags = ; ${common.src_build_unflags}
; ESP32 with PZEM004Tv30, debug enabled [env:espem_debug] extends = esp32_base lib_deps = ${esp32_base.lib_deps} https://github.com/vortigont/pzem-edl build_flags = ${esp32_base.build_flags} ${debug.app_serial} -DCOUNTRY="ru" ;src_build_flags = ; ${common.src_build_flags} ;src_build_unflags = ; ${common.src_build_unflags}
[env:espem_current] extends = esp32_base lib_deps = ${esp32_base.lib_deps} https://github.com/vortigont/pzem-edl build_flags = ${esp32_base.build_flags} -DCOUNTRY="ru" ;src_build_flags = ; ${common.src_build_flags} ;src_build_unflags = ; ${common.src_build_unflags}
is it correct ??
many thanks in advanced..
check recently updated code. Should be able to get PSRAM stat via http://espem/fw
Hi @vortigont thanks for your prompt action and reply, screen shoot below what I got
Many thanks in advanced
oops, sorry, this is not a valid json format, I will fix it later. but anyway you can read the values :) first number is 'total', second is 'free'
@vortigont msny thanks for your efforts..
@vortigont I want to use this project on ESP32 WROVER with 16 MB Flash memory & 4 MB PSRAM, how to utilize the PSRAM for this project ? usage of 16 MB memory how can be done? and what changes in the .ini file needs to be done? Thanks in advanced