Hey guys,
I’m new here.
My setup is: ESP8266 (NoceMCU), EPEver Tracer A and MAX485 module.
I’ve tried to make a upgraded version of jaminNZx’s Tracer-RS485-Modbus-Blynk repo, because I wasn’t getting some of the data out from the Tracer. For example, load current and load power were always 0.00.
I also tried to add option to turn the load ON/OFF from the Blynk app, unsuccessfully for now.
Anyhow, I’ve used the cheapo MAX485 module, and it works flawlessly.
Exactly this one:
And I’ve also tried to utilize RXD2
and TXD2
to communicate with the solar module, hoping to avoid the need of disconnecting MAX485’s serial pins from the ESP8266 on every upload.
According to ESP8266 official documentation about Serial, when you call Serial.swap()
after Serial.begin
your Serial pins change from GPIO1 (TX)
and GPIO3 (RX)
to GPIO13 (D7)
and GPIO15 (D8)
.
I haven’t been successful at this, because no matter what I did, even when Tracer was connected to
GPIO13 (D7) / RXD2
and GPIO15 (D8) / TXD2
, I wasn’t able to upload code until I disconnected the MAX485 from these pins.
What I also wanted to accomplish by this is that you would also get USB serial debug messages (also Tracer output values) and meanwhile it wouldn’t collide with the Modbus communication.
I’ve also added preTransmission()
and postTransmission()
callback’s code to trigger the DE
/ RE
pins of the MAX485.
Next, I’ve found a bug that could cause the Tracer become unresponsive in nextRegistryNumber()
function:
// function to switch to next registry
void nextRegistryNumber() {
// better not use modulo, because after overlow it will start reading in incorrect order
currentRegistryNumber++;
if (currentRegistryNumber >= ARRAY_SIZE(Registries)) {
currentRegistryNumber = 0;
}
}
I’ve also find some bugs in the ModbusMaster
library, because the UART HW buffer length is hardcoded to 64 bytes there, and ESP8266 has 256 byte hardware buffer. I think this has also made problems reading correct values. I considered to rewrite also the ModbusMaster library, but haven’t time for that…
Another thing that I was trying is to use SoftwareSerial
for ESP8266, which would in other way work just ok, (it does115200 baud pretty well), but again, the way the ModbusMaster
library is written, it’s unable to work with SoftwareSerial
, it’s dependent on HW UART, it’s harcoded there. So again, the only solution for this would be to rewrite whole ModbusMaster
Arduino library.
I also added hooks for ArduinoOTA
, because it weren’t implemented in the original repo, and upload over the air didn’t work either.
Another thing that I think is a bug I found, in AddressRegistry_3100
function readInputRegisters
reads only 7 registers, which are 16-bit (uint16_t
to be more specific), but in following lines it reads the output buffer registers at position 0x11
etc… This would mean we would need to read at least 0x11 = 17 DEC
16-bit registers.
Meanwhile I’ve got to that state with my branch, that I was able to read all values successfully, BUT then I’ve tried to “just improve the code a little bit” and I accidentally rewrote the whole logic and now it doesn’t work “very well”.
I’ve got many SBCs in my hamshack, so maybe I will write just some Python script to upload the data to Blynk.
My modified repo is here - branch name code-fixes-by-tekk
.
Any ideas and suggestions are welcome.