Can't compile with a new plugin (PZEM004T)
Moderators: grovkillen, Stuntteam, TD-er
Can't compile with a new plugin (PZEM004T)
Hi,
First I would like to say that I am new to the ESP world and second I am new to compiling of firmware and ... english is not my primary language so please bare with me...
I'm trying to build a firmware that would include the PZEM004T plugin, I installed the Atom environment together with the PlateformIO and I have been able to build the vanilla ESPeasy bin file, not without issues (I had errors with the some IR that I removed from the build to fix) but I got it to build a firmware.
Then, I dowloaded the PZEM004T.io thast i added in the src directory and I also dowloaded the PZEM004.ZIP (containing the librairies, .h files etc) that I put in the lib directory and tried building a normal 4096 file and I got the following errors:
pioenvs\normal_ESP8266_4096\libf16\libEspSoftwareSerial_ID168.a(SoftwareSerial.o): In function `sws_isr_0()':
SoftwareSerial.cpp:(.iram.text+0xf8): multiple definition of `sws_isr_0()'
.pioenvs\normal_ESP8266_4096\lib076\libSoftwareSerial.a(ESPeasySoftwareSerial.o):ESPeasySoftwareSerial.cpp:(.iram.
text+0xd4): first defined here
.pioenvs\normal_ESP8266_4096\libf16\libEspSoftwareSerial_ID168.a(SoftwareSerial.o): In function `sws_isr_1()':
SoftwareSerial.cpp:(.iram.text+0x110): multiple definition of `sws_isr_1()'
.pioenvs\normal_ESP8266_4096\lib076\libSoftwareSerial.a(ESPeasySoftwareSerial.o):ESPeasySoftwareSerial.cpp:(.iram.
text+0xec): first defined here
.pioenvs\normal_ESP8266_4096\libf16\libEspSoftwareSerial_ID168.a(SoftwareSerial.o): In function `sws_isr_2()':
SoftwareSerial.cpp:(.iram.text+0x128): multiple definition of `sws_isr_2()'
.pioenvs\normal_ESP8266_4096\lib076\libSoftwareSerial.a(ESPeasySoftwareSerial.o):ESPeasySoftwareSerial.cpp:(.iram.
text+0x104): first defined here
collect2.exe: error: ld returned 1 exit status
*** [.pioenvs\normal_ESP8266_4096\firmware.elf] Error 1
I have no clue as to what might be my problem,
can anyone please give me some hints ?
thanks a lot
First I would like to say that I am new to the ESP world and second I am new to compiling of firmware and ... english is not my primary language so please bare with me...
I'm trying to build a firmware that would include the PZEM004T plugin, I installed the Atom environment together with the PlateformIO and I have been able to build the vanilla ESPeasy bin file, not without issues (I had errors with the some IR that I removed from the build to fix) but I got it to build a firmware.
Then, I dowloaded the PZEM004T.io thast i added in the src directory and I also dowloaded the PZEM004.ZIP (containing the librairies, .h files etc) that I put in the lib directory and tried building a normal 4096 file and I got the following errors:
pioenvs\normal_ESP8266_4096\libf16\libEspSoftwareSerial_ID168.a(SoftwareSerial.o): In function `sws_isr_0()':
SoftwareSerial.cpp:(.iram.text+0xf8): multiple definition of `sws_isr_0()'
.pioenvs\normal_ESP8266_4096\lib076\libSoftwareSerial.a(ESPeasySoftwareSerial.o):ESPeasySoftwareSerial.cpp:(.iram.
text+0xd4): first defined here
.pioenvs\normal_ESP8266_4096\libf16\libEspSoftwareSerial_ID168.a(SoftwareSerial.o): In function `sws_isr_1()':
SoftwareSerial.cpp:(.iram.text+0x110): multiple definition of `sws_isr_1()'
.pioenvs\normal_ESP8266_4096\lib076\libSoftwareSerial.a(ESPeasySoftwareSerial.o):ESPeasySoftwareSerial.cpp:(.iram.
text+0xec): first defined here
.pioenvs\normal_ESP8266_4096\libf16\libEspSoftwareSerial_ID168.a(SoftwareSerial.o): In function `sws_isr_2()':
SoftwareSerial.cpp:(.iram.text+0x128): multiple definition of `sws_isr_2()'
.pioenvs\normal_ESP8266_4096\lib076\libSoftwareSerial.a(ESPeasySoftwareSerial.o):ESPeasySoftwareSerial.cpp:(.iram.
text+0x104): first defined here
collect2.exe: error: ld returned 1 exit status
*** [.pioenvs\normal_ESP8266_4096\firmware.elf] Error 1
I have no clue as to what might be my problem,
can anyone please give me some hints ?
thanks a lot
Last edited by goldriver on 14 Dec 2018, 16:59, edited 1 time in total.
Re: Can't compile with a new plugin (PZEM004T)
Hi,
I have exactly the same issue (and also new to that topic). Did you get any help or could you solve it?
BR Udo
I have exactly the same issue (and also new to that topic). Did you get any help or could you solve it?
BR Udo
Re: Can't compile with a new plugin (PZEM004T)
I used the latest build and it worked for me
Re: Can't compile with a new plugin (PZEM004T)
For latest of ESPeasy just replace 3 files
from ESPEasyPluginPlayground-master to base dir
libraries\PZEM004T-master
![Image](https://i.imgur.com/MFQZ88t.jpg)
from ESPEasyPluginPlayground-master to base dir
Code: Select all
//#######################################################################################################
//################### Plugin 171 PZEM-004T AC Current and Voltage measurement sensor ####################
//#######################################################################################################
//
// This plugin is interfacing with PZEM-004T Sesor with softserial communication as the sensor
// has an UART pinout (TX/RX/VCC/GND)
//
#include <ESPeasySoftwareSerial.h>
#include <PZEM004T.h>
PZEM004T *Plugin_171_pzem;
IPAddress pzemIP(192,168,1,1); // required by the library but not used (dummy value)
#define PLUGIN_171
#define PLUGIN_ID_171 171
#define PLUGIN_171_DEBUG false //activate extra log info in the debug
#define PLUGIN_NAME_171 "Voltage & Current (AC) - PZEM-004T [TESTING]"
#define PLUGIN_VALUENAME1_171 "Voltage (V)"
#define PLUGIN_VALUENAME2_171 "Current (A)"
#define PLUGIN_VALUENAME3_171 "Power (W)"
#define PLUGIN_VALUENAME4_171 "Energy (Wh)"
// local parameter for this plugin
#define PZEM_MAX_ATTEMPT 3
boolean Plugin_171(byte function, struct EventStruct *event, String& string)
{
boolean success = false;
switch (function)
{
case PLUGIN_DEVICE_ADD:
{
Device[++deviceCount].Number = PLUGIN_ID_171;
Device[deviceCount].Type = DEVICE_TYPE_DUAL;
Device[deviceCount].VType = SENSOR_TYPE_QUAD;
Device[deviceCount].Ports = 0;
Device[deviceCount].PullUpOption = false;
Device[deviceCount].InverseLogicOption = false;
Device[deviceCount].FormulaOption = true;
Device[deviceCount].ValueCount = 4;
Device[deviceCount].SendDataOption = true;
Device[deviceCount].TimerOption = true;
Device[deviceCount].GlobalSyncOption = false;
break;
}
case PLUGIN_GET_DEVICENAME:
{
string = F(PLUGIN_NAME_171);
break;
}
case PLUGIN_GET_DEVICEVALUENAMES:
{
strcpy_P(ExtraTaskSettings.TaskDeviceValueNames[0], PSTR(PLUGIN_VALUENAME1_171));
strcpy_P(ExtraTaskSettings.TaskDeviceValueNames[1], PSTR(PLUGIN_VALUENAME2_171));
strcpy_P(ExtraTaskSettings.TaskDeviceValueNames[2], PSTR(PLUGIN_VALUENAME3_171));
strcpy_P(ExtraTaskSettings.TaskDeviceValueNames[3], PSTR(PLUGIN_VALUENAME4_171));
break;
}
case PLUGIN_WEBFORM_LOAD:
{
addFormNote(F("SoftSerial: 1st=RX-Pin, 2nd=TX-Pin"));
success = true;
break;
}
case PLUGIN_WEBFORM_SAVE:
{
success = true;
break;
}
case PLUGIN_READ:
{
if (PLUGIN_171_DEBUG) {
String log = F("PZEM004T: Reading started.");
addLog(LOG_LEVEL_INFO, log);
}
float pzVoltage = Plugin171_ReadVoltage();
float pzCurrent = Plugin171_ReadCurrent();
float pzPower = Plugin171_ReadPower();
float pzEnergy = Plugin171_ReadEnergy();
//-------------------------------------------------------------------
// readings can be ZERO if there's no AC input on the module.
// in this case V A and W are reported correctly as ZERO but
// the accumulated Energy paramenter will not be saved so to
// preserve previous value
//-------------------------------------------------------------------
UserVar[event->BaseVarIndex] = pzVoltage;
UserVar[event->BaseVarIndex + 1] = pzCurrent;
UserVar[event->BaseVarIndex + 2] = pzPower;
if (pzEnergy>=0) UserVar[event->BaseVarIndex + 3] = pzEnergy;
if (PLUGIN_171_DEBUG) {
String log = F("PZEM004T: Reading completed.");
addLog(LOG_LEVEL_INFO, log);
}
success = true;
break;
}
case PLUGIN_INIT:
{
if (!Plugin_171_pzem)
{
int pzemRXpin = Settings.TaskDevicePin1[event->TaskIndex];
int pzemTXpin = Settings.TaskDevicePin2[event->TaskIndex];
Plugin_171_pzem = new PZEM004T(pzemRXpin, pzemTXpin);
if (PLUGIN_171_DEBUG) {
String log = F("PZEM004T: Object Initialized");
log += F(" - RX-Pin="); log += pzemRXpin;
log += F(" - TX-Pin="); log += pzemTXpin;
addLog(LOG_LEVEL_INFO, log);
}
Plugin_171_pzem->setAddress(pzemIP); // This initializes the PZEM004T library using a (useless) fake IP address
if (PLUGIN_171_DEBUG) {
String log = F("PZEM004T: setup address (dummy)");
log += F(" - "); log += pzemIP;
addLog(LOG_LEVEL_INFO, log);
}
}
success = true;
break;
}
}
return success;
}
//************************************//
//***** reading values functions *****//
//************************************//
// NOTE: readings are attempted only PZEM_AMX_ATTEMPT times
float Plugin171_ReadVoltage() {
int counter = 0;
float reading = -1.0;
do {
reading = Plugin_171_pzem->voltage(pzemIP);
wdt_reset();
counter++;
} while (counter < PZEM_MAX_ATTEMPT && reading < 0.0);
if (reading == -1) reading = 0;
return reading;
}
float Plugin171_ReadCurrent() {
int counter = 0;
float reading = -1.0;
do {
reading = Plugin_171_pzem->current(pzemIP);
wdt_reset();
counter++;
} while (counter < PZEM_MAX_ATTEMPT && reading < 0.0);
if (reading == -1) reading = 0;
return reading;
}
float Plugin171_ReadPower() {
int counter = 0;
float reading = -1.0;
do {
reading = Plugin_171_pzem->power(pzemIP);
wdt_reset();
counter++;
} while (counter < PZEM_MAX_ATTEMPT && reading < 0.0);
if (reading == -1) reading = 0;
return reading;
}
float Plugin171_ReadEnergy() {
int counter = 0;
float reading = -1.0;
do {
reading = Plugin_171_pzem->energy(pzemIP);
wdt_reset();
counter++;
} while (counter < PZEM_MAX_ATTEMPT && reading < 0.0);
return reading;
}
//#endif
Code: Select all
#include "PZEM004T.h"
#define PZEM_VOLTAGE (uint8_t)0xB0
#define RESP_VOLTAGE (uint8_t)0xA0
#define PZEM_CURRENT (uint8_t)0xB1
#define RESP_CURRENT (uint8_t)0xA1
#define PZEM_POWER (uint8_t)0xB2
#define RESP_POWER (uint8_t)0xA2
#define PZEM_ENERGY (uint8_t)0xB3
#define RESP_ENERGY (uint8_t)0xA3
#define PZEM_SET_ADDRESS (uint8_t)0xB4
#define RESP_SET_ADDRESS (uint8_t)0xA4
#define PZEM_POWER_ALARM (uint8_t)0xB5
#define RESP_POWER_ALARM (uint8_t)0xA5
#define RESPONSE_SIZE sizeof(PZEMCommand)
#define RESPONSE_DATA_SIZE RESPONSE_SIZE - 2
#define PZEM_BAUD_RATE 9600
#ifdef PZEM004_SOFTSERIAL
PZEM004T::PZEM004T(uint8_t receivePin, uint8_t transmitPin)
{
ESPeasySoftwareSerial *port = new ESPeasySoftwareSerial(receivePin, transmitPin);
port->begin(PZEM_BAUD_RATE);
this->serial = port;
this->_isSoft = true;
}
#endif
PZEM004T::PZEM004T(HardwareSerial *port)
{
port->begin(PZEM_BAUD_RATE);
this->serial = port;
this->_isSoft = false;
}
PZEM004T::~PZEM004T()
{
if(_isSoft)
delete this->serial;
}
void PZEM004T::setReadTimeout(unsigned long msec)
{
_readTimeOut = msec;
}
float PZEM004T::voltage(const IPAddress &addr)
{
uint8_t data[RESPONSE_DATA_SIZE];
send(addr, PZEM_VOLTAGE);
if(!recieve(RESP_VOLTAGE, data))
return PZEM_ERROR_VALUE;
return (data[0] << 8) + data[1] + (data[2] / 10.0);
}
float PZEM004T::current(const IPAddress &addr)
{
uint8_t data[RESPONSE_DATA_SIZE];
send(addr, PZEM_CURRENT);
if(!recieve(RESP_CURRENT, data))
return PZEM_ERROR_VALUE;
return (data[0] << 8) + data[1] + (data[2] / 100.0);
}
float PZEM004T::power(const IPAddress &addr)
{
uint8_t data[RESPONSE_DATA_SIZE];
send(addr, PZEM_POWER);
if(!recieve(RESP_POWER, data))
return PZEM_ERROR_VALUE;
return (data[0] << 8) + data[1];
}
float PZEM004T::energy(const IPAddress &addr)
{
uint8_t data[RESPONSE_DATA_SIZE];
send(addr, PZEM_ENERGY);
if(!recieve(RESP_ENERGY, data))
return PZEM_ERROR_VALUE;
return ((uint32_t)data[0] << 16) + ((uint16_t)data[1] << 8) + data[2];
}
bool PZEM004T::setAddress(const IPAddress &newAddr)
{
send(newAddr, PZEM_SET_ADDRESS);
return recieve(RESP_SET_ADDRESS);
}
bool PZEM004T::setPowerAlarm(const IPAddress &addr, uint8_t threshold)
{
send(addr, PZEM_POWER_ALARM, threshold);
return recieve(RESP_POWER_ALARM);
}
void PZEM004T::send(const IPAddress &addr, uint8_t cmd, uint8_t data)
{
PZEMCommand pzem;
pzem.command = cmd;
for(int i=0; i<sizeof(pzem.addr); i++)
pzem.addr[i] = addr[i];
pzem.data = data;
uint8_t *bytes = (uint8_t*)&pzem;
pzem.crc = crc(bytes, sizeof(pzem) - 1);
while(serial->available())
serial->read();
serial->write(bytes, sizeof(pzem));
}
bool PZEM004T::recieve(uint8_t resp, uint8_t *data)
{
uint8_t buffer[RESPONSE_SIZE];
#ifdef PZEM004_SOFTSERIAL
if(_isSoft)
((ESPeasySoftwareSerial *)serial)->listen();
#endif
unsigned long startTime = millis();
uint8_t len = 0;
while((len < RESPONSE_SIZE) && (millis() - startTime < _readTimeOut))
{
if(serial->available() > 0)
{
uint8_t c = (uint8_t)serial->read();
if(!c && !len)
continue; // skip 0 at startup
buffer[len++] = c;
}
yield(); // do background netw tasks while blocked for IO (prevents ESP watchdog trigger)
}
if(len != RESPONSE_SIZE)
return false;
if(buffer[6] != crc(buffer, len - 1))
return false;
if(buffer[0] != resp)
return false;
if(data)
{
for(int i=0; i<RESPONSE_DATA_SIZE; i++)
data[i] = buffer[1 + i];
}
return true;
}
uint8_t PZEM004T::crc(uint8_t *data, uint8_t sz)
{
uint16_t crc = 0;
for(uint8_t i=0; i<sz; i++)
crc += *data++;
return (uint8_t)(crc & 0xFF);
}
Code: Select all
#ifndef PZEM004T_H
#define PZEM004T_H
#if defined(ARDUINO) && ARDUINO >= 100
#include "Arduino.h"
#else
#include "WProgram.h"
#endif
// #define PZEM004_NO_SWSERIAL
#if (not defined(PZEM004_NO_SWSERIAL)) && (defined(__AVR__) || defined(ESP8266))
#define PZEM004_SOFTSERIAL
#endif
#if defined(PZEM004_SOFTSERIAL)
#include <ESPeasySoftwareSerial.h>
#endif
#include <IPAddress.h>
#define PZEM_DEFAULT_READ_TIMEOUT 1000
#define PZEM_ERROR_VALUE -1.0
struct PZEMCommand {
uint8_t command;
uint8_t addr[4];
uint8_t data;
uint8_t crc;
};
class PZEM004T
{
public:
PZEM004T(uint8_t receivePin, uint8_t transmitPin);
PZEM004T(HardwareSerial *port);
~PZEM004T();
void setReadTimeout(unsigned long msec);
unsigned long readTimeout() {return _readTimeOut;}
float voltage(const IPAddress &addr);
float current(const IPAddress &addr);
float power(const IPAddress &addr);
float energy(const IPAddress &addr);
bool setAddress(const IPAddress &newAddr);
bool setPowerAlarm(const IPAddress &addr, uint8_t threshold);
private:
Stream *serial;
bool _isSoft;
unsigned long _readTimeOut = PZEM_DEFAULT_READ_TIMEOUT;
void send(const IPAddress &addr, uint8_t cmd, uint8_t data = 0);
bool recieve(uint8_t resp, uint8_t *data = 0);
uint8_t crc(uint8_t *data, uint8_t sz);
};
#endif // PZEM004T_H
![Image](https://i.imgur.com/MFQZ88t.jpg)
Re: Can't compile with a new plugin (PZEM004T)
Solution works but it's dirty because as soon as you update the PZEM library it won't work again...
I was thinking to remove this library dependencies before to include this pluing in the standard REP but still not time to complete this task...
I was thinking to remove this library dependencies before to include this pluing in the standard REP but still not time to complete this task...
My TINDIE Store where you can find all ESP8266 boards I manufacture --> https://www.tindie.com/stores/GiovanniCas/
My Wiki Project page with self-made PCB/devices --> https://www.letscontrolit.com/wiki/inde ... :Papperone
My Wiki Project page with self-made PCB/devices --> https://www.letscontrolit.com/wiki/inde ... :Papperone
Re: Can't compile with a new plugin (PZEM004T)
The library has not been updated for a long time and is unlikely to be updated). I have a lot of sensors working on a new one and I didn’t want to use an old binary, as it’s not working well. For a long time, it showed that everything is working fine. Who helped - put like)
Re: Can't compile with a new plugin (PZEM004T)
Ho Lyovav,
Other than changing the content of the .ino. .cpp and .h files, have you made any other changes to the master zip files ?
I am trying to build with the latest master file and the informations you provided but I have these error at build time:
pioenvs\normal_ESP8266_4096\libf16\EspSoftwareSerial_ID168\SoftwareSerial.cpp.o: In function `sws_isr_0()':
SoftwareSerial.cpp:(.iram.text+0xf8): multiple definition of `sws_isr_0()'
.pioenvs\normal_ESP8266_4096\lib29e\ESPEasySoftwareSerial\ESPeasySoftwareSerial.cpp.o:ESPeasySoftwareSerial.cpp:(.iram.text+0xd4): first defined here
.pioenvs\normal_ESP8266_4096\libf16\EspSoftwareSerial_ID168\SoftwareSerial.cpp.o: In function `sws_isr_1()':
SoftwareSerial.cpp:(.iram.text+0x110): multiple definition of `sws_isr_1()'
.pioenvs\normal_ESP8266_4096\lib29e\ESPEasySoftwareSerial\ESPeasySoftwareSerial.cpp.o:ESPeasySoftwareSerial.cpp:(.iram.text+0xec): first defined here
.pioenvs\normal_ESP8266_4096\libf16\EspSoftwareSerial_ID168\SoftwareSerial.cpp.o: In function `sws_isr_2()':
SoftwareSerial.cpp:(.iram.text+0x128): multiple definition of `sws_isr_2()'
.pioenvs\normal_ESP8266_4096\lib29e\ESPEasySoftwareSerial\ESPeasySoftwareSerial.cpp.o:ESPeasySoftwareSerial.cpp:(.iram.text+0x104): first defined here
in fact, it's the same issue I had in the past that I overpass by working with prior release of easyesp but I need fonctionnality that are only in the latest espeasy version.
thanks for any help you van provide
Other than changing the content of the .ino. .cpp and .h files, have you made any other changes to the master zip files ?
I am trying to build with the latest master file and the informations you provided but I have these error at build time:
pioenvs\normal_ESP8266_4096\libf16\EspSoftwareSerial_ID168\SoftwareSerial.cpp.o: In function `sws_isr_0()':
SoftwareSerial.cpp:(.iram.text+0xf8): multiple definition of `sws_isr_0()'
.pioenvs\normal_ESP8266_4096\lib29e\ESPEasySoftwareSerial\ESPeasySoftwareSerial.cpp.o:ESPeasySoftwareSerial.cpp:(.iram.text+0xd4): first defined here
.pioenvs\normal_ESP8266_4096\libf16\EspSoftwareSerial_ID168\SoftwareSerial.cpp.o: In function `sws_isr_1()':
SoftwareSerial.cpp:(.iram.text+0x110): multiple definition of `sws_isr_1()'
.pioenvs\normal_ESP8266_4096\lib29e\ESPEasySoftwareSerial\ESPeasySoftwareSerial.cpp.o:ESPeasySoftwareSerial.cpp:(.iram.text+0xec): first defined here
.pioenvs\normal_ESP8266_4096\libf16\EspSoftwareSerial_ID168\SoftwareSerial.cpp.o: In function `sws_isr_2()':
SoftwareSerial.cpp:(.iram.text+0x128): multiple definition of `sws_isr_2()'
.pioenvs\normal_ESP8266_4096\lib29e\ESPEasySoftwareSerial\ESPeasySoftwareSerial.cpp.o:ESPeasySoftwareSerial.cpp:(.iram.text+0x104): first defined here
in fact, it's the same issue I had in the past that I overpass by working with prior release of easyesp but I need fonctionnality that are only in the latest espeasy version.
thanks for any help you van provide
Re: Can't compile with a new plugin (PZEM004T)
@goldriver
In the PZEM004T library folder, in library.json remove the dependancy to EspSoftwareSerial :
It took me some time to find but now it compiles.
@lyovav, did you use a voltage level shifter or some kind of modification as adding a resistor to connect the esp8266 ?
In the PZEM004T library folder, in library.json remove the dependancy to EspSoftwareSerial :
Code: Select all
{
"name": "PZEM004T",
"frameworks": "arduino",
"keywords": "peacefair, pzem, powermeter",
"description": "Enables communication with Peacefair PZEM-004T Energy monitor",
"url": "https://github.com/olehs/PZEM004T",
"authors": [
{
"name": "Oleg Sokolov"
}
],
"repository": {
"type": "git",
"url": "https://github.com/olehs/PZEM004T.git"
},
"platforms": "*",
"version": "1.1.2",
"dependencies": [
]
}
@lyovav, did you use a voltage level shifter or some kind of modification as adding a resistor to connect the esp8266 ?
Sébastien - espRFLinkMQTT gateway RFLink MQTT on esp
Re: Can't compile with a new plugin (PZEM004T)
@seb82
Thanks, I have been able to compile, since I am away from home won't be able to test on esp8266 until few weeks
Thanks, I have been able to compile, since I am away from home won't be able to test on esp8266 until few weeks
Re: Can't compile with a new plugin (PZEM004T)
CORRECTION
when I compiled yesterday it was with a mega I had on my computer dating from september, I tried dowloading the latest and now new compile errors:
Compiling .pioenvs\normal_ESP8266_4096\lib41b\LiquidCrystal_I2C\LiquidCrystal_I2C.cpp.o
In file included from lib\PZEM004T-master\PZEM004T.cpp:1:0:
lib\PZEM004T-master\PZEM004T.h:17:35: fatal error: ESPeasySoftwareSerial.h: No such file or directory
*******************************************************************************
* Looking for ESPeasySoftwareSerial.h dependency? Check our library registry!
*
* CLI > platformio lib search "header:ESPeasySoftwareSerial.h"
* Web > https://platformio.org/lib/search?query ... reSerial.h
*
*******************************************************************************
#include <ESPeasySoftwareSerial.h>
^
compilation terminated.
*** [.pioenvs\normal_ESP8266_4096\lib686\PZEM004T-master\PZEM004T.cpp.o] Error 1
Compiling .pioenvs\normal_ESP8266_4096\src\ESPEasy.ino.cpp.o
C:/easyesp/ESPEasy-mega-20190107/src/_P171_PZEM-004T.ino:11:35: fatal error: ESPeasySoftwareSerial.h: No such file or directory
looks like we are back to research again
when I compiled yesterday it was with a mega I had on my computer dating from september, I tried dowloading the latest and now new compile errors:
Compiling .pioenvs\normal_ESP8266_4096\lib41b\LiquidCrystal_I2C\LiquidCrystal_I2C.cpp.o
In file included from lib\PZEM004T-master\PZEM004T.cpp:1:0:
lib\PZEM004T-master\PZEM004T.h:17:35: fatal error: ESPeasySoftwareSerial.h: No such file or directory
*******************************************************************************
* Looking for ESPeasySoftwareSerial.h dependency? Check our library registry!
*
* CLI > platformio lib search "header:ESPeasySoftwareSerial.h"
* Web > https://platformio.org/lib/search?query ... reSerial.h
*
*******************************************************************************
#include <ESPeasySoftwareSerial.h>
^
compilation terminated.
*** [.pioenvs\normal_ESP8266_4096\lib686\PZEM004T-master\PZEM004T.cpp.o] Error 1
Compiling .pioenvs\normal_ESP8266_4096\src\ESPEasy.ino.cpp.o
C:/easyesp/ESPEasy-mega-20190107/src/_P171_PZEM-004T.ino:11:35: fatal error: ESPeasySoftwareSerial.h: No such file or directory
looks like we are back to research again
Re: Can't compile with a new plugin (PZEM004T)
It does compile with release 20181231.
In release 20190107, it looks like they changed the name of the library from ESPEasySoftwareSerial to ESPEasySerial (in source/lib).
These changes will have to be reported in the plugin .ino file and possibly in the modified PZEM004 library as references and objects name may have changed.
For now, I would go with 20181231 and wait for things to get more stable on the softwareserial side.
In release 20190107, it looks like they changed the name of the library from ESPEasySoftwareSerial to ESPEasySerial (in source/lib).
These changes will have to be reported in the plugin .ino file and possibly in the modified PZEM004 library as references and objects name may have changed.
For now, I would go with 20181231 and wait for things to get more stable on the softwareserial side.
Sébastien - espRFLinkMQTT gateway RFLink MQTT on esp
-
- New user
- Posts: 6
- Joined: 16 Jan 2019, 22:00
Re: Can't compile with a new plugin (PZEM004T)
I also have some problems with building this project
I think that is not a hardware problem, wifi-iot firmware works fine, but with the hardware serial.
Im already tried to change GPIOs to another with the same result.
There is no Voltage measuring, A W Wh only
Its helps me to compile firmware without any errors, but my pzem just not working. I always see 0.0
I think that is not a hardware problem, wifi-iot firmware works fine, but with the hardware serial.
Im already tried to change GPIOs to another with the same result.
There is no Voltage measuring, A W Wh only
- Attachments
-
- Снимок.JPG (100.53 KiB) Viewed 32929 times
Re: Can't compile with a new plugin (PZEM004T)
I tested first with an Arduino Nano to make sure hardware was ok with code from these links:
https://github.com/JhonControl/PZEM-004 ... SoftSerial
http://pdacontrolen.com/electricity-con ... uino-nano/
You can probably compile it for a D1 mini. Just need to use the correct pins (GPIO3 for RX and GPIO1 for TX if I am not mistaken).
Two other ideas :
- For a D1 mini, it requires a logic level converter from 5V to 3.3V. Otherwise it does not work (it is well explained in the second link above).
- I had problems on another project with core 2.4.2 and softwareserial but with modifications provided by lyovav it should be using ESPEasy softwareserial
https://github.com/JhonControl/PZEM-004 ... SoftSerial
http://pdacontrolen.com/electricity-con ... uino-nano/
You can probably compile it for a D1 mini. Just need to use the correct pins (GPIO3 for RX and GPIO1 for TX if I am not mistaken).
Two other ideas :
- For a D1 mini, it requires a logic level converter from 5V to 3.3V. Otherwise it does not work (it is well explained in the second link above).
- I had problems on another project with core 2.4.2 and softwareserial but with modifications provided by lyovav it should be using ESPEasy softwareserial
Sébastien - espRFLinkMQTT gateway RFLink MQTT on esp
Re: Can't compile with a new plugin (PZEM004T)
I forked the library and included modifications to get it to work with ESPEasy last release (20190116):
https://github.com/seb821/PZEM004T
The .ino plugin file I use is also included.
To compile with platformio :
- .ino file goes into source/src
- other files go into source/lib/PZEM004T
- in platformio.ini, add "-D USES_P184" at the end of the parameter build_flags corresponding to the device you want to build (alternative: comment "#ifdef USES_P171" / "#endif // USES_P171" in the .ino file)
https://github.com/seb821/PZEM004T
The .ino plugin file I use is also included.
To compile with platformio :
- .ino file goes into source/src
- other files go into source/lib/PZEM004T
- in platformio.ini, add "-D USES_P184" at the end of the parameter build_flags corresponding to the device you want to build (alternative: comment "#ifdef USES_P171" / "#endif // USES_P171" in the .ino file)
Sébastien - espRFLinkMQTT gateway RFLink MQTT on esp
-
- New user
- Posts: 6
- Joined: 16 Jan 2019, 22:00
Re: Can't compile with a new plugin (PZEM004T)
Still not working. With the new library even log show nothing
I have checkd hardware again with Atmega 328p (same library for arduino) and esp12 with wi-fi_iot firmware. Both are working fine.
But when I change firmware to ESPEasy - I still have always 0.00V
Last try i just checked answer from PZEM on the receive pin of ESP. Its looking so good but I think that, then ESPEasy do nothing with the signal))
I have checkd hardware again with Atmega 328p (same library for arduino) and esp12 with wi-fi_iot firmware. Both are working fine.
But when I change firmware to ESPEasy - I still have always 0.00V
Last try i just checked answer from PZEM on the receive pin of ESP. Its looking so good but I think that, then ESPEasy do nothing with the signal))
- Attachments
-
- Снимок.PNG (5.1 KiB) Viewed 32841 times
-
- Снимок2.PNG (14.72 KiB) Viewed 32841 times
-
- Снимок3.PNG (1.94 MiB) Viewed 32841 times
Re: Can't compile with a new plugin (PZEM004T)
To be sure, I have just recompiled with the files directly from my github (library + .ino) for release 20190116 and it works.
Maybe you could try setting PLUGIN_171_DEBUG to true in the .ino file and see if you get more information. And also, maybe try other pins and double check wiring with the logic level converter.
Maybe you could try setting PLUGIN_171_DEBUG to true in the .ino file and see if you get more information. And also, maybe try other pins and double check wiring with the logic level converter.
Sébastien - espRFLinkMQTT gateway RFLink MQTT on esp
-
- New user
- Posts: 6
- Joined: 16 Jan 2019, 22:00
Re: Can't compile with a new plugin (PZEM004T)
I have a lot of warnings due compiling, but it always finished succesfully
May you give me the binary just to make sure? Im using ESP12E 4mb
Thx
Nothing changed after setting up debug
May you give me the binary just to make sure? Im using ESP12E 4mb
Thx
Nothing changed after setting up debug
-
- New user
- Posts: 6
- Joined: 16 Jan 2019, 22:00
Re: Can't compile with a new plugin (PZEM004T)
Finnaly Ive beat it
Just replace pzemTXpin and pzemRXpin with hardware pins 3,1 in the plugin code.
Just replace pzemTXpin and pzemRXpin with hardware pins 3,1 in the plugin code.
Re: Can't compile with a new plugin (PZEM004T)
Great !
It means you used hardware serial RX/TX, doesn't it ?
Normally, you should be able to change it directly in the web interface. But first, you must disable serial log in the advanced page.
It means you used hardware serial RX/TX, doesn't it ?
Normally, you should be able to change it directly in the web interface. But first, you must disable serial log in the advanced page.
Sébastien - espRFLinkMQTT gateway RFLink MQTT on esp
-
- New user
- Posts: 6
- Joined: 16 Jan 2019, 22:00
Re: Can't compile with a new plugin (PZEM004T)
Yes, it is a real hardware serial. But if I only changing GPiO in device settings, i have just software serial over gpio 3/1. Of course it does not work this way:lol:
Re: Can't compile with a new plugin (PZEM004T)
大神们,能给个最新编译过的版本?
Re: Can't compile with a new plugin (PZEM004T)
Great God, can you give a newly compiled version?
Re: Can't compile with a new plugin (PZEM004T)
For me it does not work too.
But i get connected another uart converter to tx from pzem module and it send data, but showing only zero values on devices page.
Below is a scrren from hercules due sending data from pzem module.
I tried changing pins, enabling input, comile with different cores etc. and still unfortunately it does not work for me.
###edited###
Ok on HW UART is working well
To enable Hardware uart for pzem need to disable it on advanced page.
But i get connected another uart converter to tx from pzem module and it send data, but showing only zero values on devices page.
Below is a scrren from hercules due sending data from pzem module.
I tried changing pins, enabling input, comile with different cores etc. and still unfortunately it does not work for me.
###edited###
Ok on HW UART is working well
To enable Hardware uart for pzem need to disable it on advanced page.
- Attachments
-
- pzem2.png (8.65 KiB) Viewed 32394 times
-
- pzem.png (26.09 KiB) Viewed 32395 times
Who is online
Users browsing this forum: Ahrefs [Bot] and 32 guests