First of all many thanks to Espeasy and PZEM-multi developers!! You do an awesome job and help so many enthusiasts!
I used espeasy firmware for 2+ years, but as sensors and setups get more complicated while plugin/controller sets remain quite conservative I have to master custom builds. And here is where problems start, as I'm not developer and not really comfortable with PIO. For example: how to get full output if it is reaaly long? Or how to click on error and got positioned on a guilty line of source code.
I use 1M boards and need both Blynk and PZEM compiled. I tried ESPEasy_mega-20191003 as a source and it worked. Then I wanted to try more up-to-date source, did the same as for 20191003 but neither 20201009 nor 20201016 worked. PIO either throws a lot of 'warning: "BUILD_NO_DEBUG" redefined' junk and overflows console and status = success or fails on some unrelated libraries but second run without any change succeeds. Either way when I flashed and booted, I didn't have BLYNK in Controllers or PZEM in Devices. Initially I wanted to ask for help, but then figured out myself so I'll document it below. May be someone can find it helpful.
What I did:
- downloaded sources
- put PZEM004Tv30.cpp and PZEM004Tv30.h from the Playground to ./lib/PZEM-004T-v30
- had some errors in PZEM004Tv30.cpp regarding a number of arguments (related to ESPeasySerial.h) so I changed PZEM004Tv30.cpp:
swSerial= new ESPeasySerial(receivePin, transmitPin); TO
swSerial= new ESPeasySerial(ESPEasySerialPort::software, receivePin, transmitPin);
- put _P251_PZEM004Tv3.ino to ./src
- changed _P251_PZEM004Tv3.ino
Device[deviceCount].VType = SENSOR_TYPE_QUAD; to
Device[deviceCount].VType = Sensor_VType::SENSOR_TYPE_QUAD;
(thanks to several posts above)
- added a section for my board to platformio_esp82xx_envs.ini
Code: Select all
[env:test_ESP8266_1M]
extends = esp8266_1M
platform = ${testing.platform}
platform_packages = ${testing.platform_packages}
build_flags = ${testing.build_flags}
${esp8266_1M.build_flags}
-DUSE_CUSTOM_H
board = ${esp8266_1M.board}
framework = arduino
- chose this setup as default in platformio.ini
default_envs = test_ESP8266_1M
- added Blynk and PZEM via ./src/Custom.h
#define USES_P251 // PZEM-04T
#define USES_C012 // Blynk HTTP
#define USES_C015 // Blynk
- removed some sensors which I don't use to save memory in ./src/Custom.h like this:
#ifdef USES_P025
# undef USES_P025 // ADS1115
#endif
- just in case I added to define_plugin_sets.h
#define USES_C012 // Blynk HTTP
#define USES_C015 // Blynk
after
#ifdef CONTROLLER_SET_TESTING
and
#define USES_P251 // PZEM-04T
after
#ifdef PLUGIN_SET_TESTING
- Looks like Blynk got skipped due to the following section of define_plugin_sets.h
Code: Select all
// Due to size restrictions, disable a few plugins/controllers for 1M builds
#ifdef SIZE_1M
#ifdef USES_C003
#undef USES_C003
#endif
#ifndef LIMIT_BUILD_SIZE
#define LIMIT_BUILD_SIZE
#endif
#endif
...
#ifdef LIMIT_BUILD_SIZE
...
#ifdef USES_BLYNK
#undef USES_BLYNK
I fixed it by commenting out:
Code: Select all
// #ifdef USES_BLYNK
// #undef USES_BLYNK
// #endif
One question though:
do I need to change wait timeouts in ./lib/ESPEasySerial/ESPeasySoftwareSerial.cpp like in post #126 (
viewtopic.php?p=36179#p36179) ?
MAX_PIN 15 instead of
MAX_PIN 16
and
unsigned long wait = m_bitTime + m_bitTime / 2; instead of
unsigned long wait = m_bitTime + m_bitTime / 3 - 500;
and
while (ESP.getCycleCount()-start < wait);
wait += m_bitTime;
instead of
WAIT;