I am trying to connect to Epever Tracer AN Solar Charge controller from ESP32 using Arduino Framework and below Max485 module but I can't get any repsonse from device.
I was trying to use exactly the same setup mentioned in this project but somehow it's not working: GitHub - tekk/Tracer-RS485-Modbus-Blynk-V2: An arduino sketch to connect the EPSolar/EPEver Tracer A/B Series (RS-485 Modbus) to an ESP8266 and monitor using the Blynk mobile app - the RELOADED version
Using cheap chinese logic analyzer I am getting strange result:
- When I checking A and B lines of my Max485 module I see signal which has been correctly decoded by logic analyzer. However I don't get any response from Solar charge controller.
- When I connect to controller from PC using cheap CH340 USB to RS485 converter and oryginal Solar Charger software everything works as expected. I tried to sniff these transmission using logic analyzer but instead of modbus data I am getting some random stuff. Serial port monitor software shows correct modbus messages (same that I am sending).
Connection parameters used in both cases:
Serial 115200 bit/sec 8 data bit, no parity, 1 stop bit
Modbus Slave ID of controller: 1
Pin connection:
ESP (TX) -> MAX485 (DI)
ESP (RX) -> MAX485 (RO)
ESP (D4) -> MAX485 (DE and RE connected together with jumper)
ESP VIN -> MAX485 VCC
ESP GROUND -> MAX485 GND
Code I am using:
First approach tried to write to serial directly as well:
pinMode(deviceStatus.pinConfig.RSE_MODBUS, OUTPUT);
digitalWrite(deviceStatus.pinConfig.RSE_MODBUS, 1);
Serial.write(1); //Slave ID
Serial.write(4); //READ register
Serial.write(51); //Register number
Serial.write(26); //Register number 2nd bit
Serial.write(0); //Number of registries requested
Serial.write(3); //Number of registries requested 2nd bit
Serial.write(158); //CRC
Serial.write(136); //CRC2 2nd bit
Serial.flush();
digitalWrite(deviceStatus.pinConfig.RSE_MODBUS, 0);
Other approach using Arduino Modbus Master library:
void preTransmission() {
digitalWrite(deviceStatus.pinConfig.RSE_MODBUS, 1);
}
void postTransmission() {
digitalWrite(deviceStatus.pinConfig.RSE_MODBUS, 0);
}
node.begin(1, Serial);
delay(1000);
//callbacks to toggle DE + RE on MAX485
node.preTransmission(preTransmission);
node.postTransmission(postTransmission);
delay(500);
result = node.readInputRegisters(0x3100, 1);
In this approach result returns 226 error code which means timeout waiting for response.
Measured voltages:
Between A and B lines - 0,05V
Between B and ground - 0,64V
Between A and ground - 0,7V
However in working CH340 with oryginal software voltage between A and B lines show 0,6V instead of 0,05V.
What I've checked already that I've read may work:
- Reverting A and B lines
- Reverting RX and TX
- I've tried to use also Wave share module 3485/485
- Tried to either send message using raw Serial.write or use designated modbus libraries
- Putting resistor between VCC and A line or between VCC and B line
- Try to add some 100 Ohm resistor between lines A anb B on MAX485 end
- Try to use common ground between controller and my module (however in CH340 working connection ground is not connected and it works).
- I've try to add some delays before/after I switch RE and DE state
Output from logic analyzer using ESP32 for connection (not working):
Channels are B line, A line, RE&DE switch
Output from logic analyzer using USB CH340 for connections (working):
Channels are B line, A line
Why I still can't see reponse from controller? Why logic analyzer show some random data but it works somehow for oryginal software and CH340 usb connector? What should I change? I really spend few days on it and have no clue how to make it working. I will be grateful for any help on this topic.