1
\$\begingroup\$

I am trying to connect to Epever Tracer AN Solar Charge controller from ESP32 using below Max485 module but I can't get any repsonse from device.

enter image description here

I was trying to use exactly the same setup mentioned in this project but somehow it's not working: https://github.com/tekk/Tracer-RS485-Modbus-Blynk-V2

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): enter image description here Channels are B line, A line, RE&DE switch

Output from logic analyzer using USB CH340 for connections (working): enter image description here 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.

\$\endgroup\$
2
  • 1
    \$\begingroup\$ Be careful with logic analyzers; they have a very sharp "knee" or trigger voltage, so hide lots of details. What may look clean on a LA could actually be terrible and not work in reality. It would be really helpful to see both sets of waveforms on an actual oscilloscope. \$\endgroup\$
    – rdtsc
    Feb 8, 2022 at 18:47
  • \$\begingroup\$ I agree with @rdtsc, the threshold voltage of the Saleae could be set too low/high and create a logic representation that appears to be noise. Try a capture using the analog channel first, and if that appears correct, then readjust the thresholds to appropriate level. \$\endgroup\$ Feb 8, 2022 at 19:24

1 Answer 1

0
\$\begingroup\$

I tried to sniff these transmission using logic analyzer but instead of modbus data I am getting some random stuff

May be atleast 2 reasons:

  1. This is not modbus: "original software" - proprietary protocol.
  2. If this is modbus, then mismatch in communication settings: check baudrate, parity, stopbits, databits, modbus mode (ascii/rtu) in analyser. Use oscilloscope to determine actual baudrate.

Measured voltages: Between A and B lines - 0,05V

This is not good. It must be < -200mv or > +200mv. (-200mv to +200mv is undefined zone).

  1. Disconnect everything from RS485 module except power.
  2. Pullup DE and RE to VCC.
  3. Toggle pullup to vcc and pulldown to gnd of DI pin and measure AB voltage. It must change polarity according to pull destination, and absolute value must be between 0.2 .. 5V.
  4. If voltage is OK, then connect solar controller RS485 line to MAX485 and repeat voltage measure.
  5. If voltage still not < -200mv or > +200mv, then create AB line pullup and pulldown:

VCC - R1 - A - R2 - B - R3 - GND

R2 = 120 Ohms.

R1 = R3.

R1 < 300(VCC - 0.2)

Look at figure 1 https://www.maximintegrated.com/en/design/technical-documents/app-notes/1/1090.html

  1. Write programm to ESp32 that sends raw request once per second. Dont bother about receiving responce. Connect ESP32 (TX) - 3.3V RS485 - CH340 USB to RS485 converter. Check with PC what data esp sends. (Im using RealTerm prog). Look ESP32 TX line with logic analyser. If logic analyser shows request, but PC doesnt receive any data once per sec (even garbage), then your RS485 module most likely dead. If you receive garbage - check connection parameters. You can connect solar converter in parrallel to RS485 AB lines to sniff on PC what happens between ESP32 and converter on AB lines.

  2. Try to talk with solar converter from PC directly. Connect CH340 USB to RS485 to converter. Use qModMaster program. In monitor window it will show modbus frames sended and received, error responces from converter.

\$\endgroup\$
7
  • \$\begingroup\$ Thank you for reply. Using 3,3 V module: Without connected Controller Voltage is switching between two values -1,76V and 1,76V (step 3). When I connect solar charge controller however and do the same test voltage switches between 0,02V and 0,28V (step 4) However when I switch to 5V module it looks better: 2,8V and -2,2V (step 3) and 2,9V and -2,3V (step 4). Right now I either receive timeout waiting for response or some incorrect respose which has alwyas 0 value. \$\endgroup\$
    – michalo
    Feb 9, 2022 at 21:23
  • 1
    \$\begingroup\$ ESP32 have 3.3V logic and its not 5V tolerant -> use 3.3V logic RS485 module. 5V Rs485 will kill your ESP32 RX pin some day. Yours 3.3V module looks suspicious, when it connected to controller. Try step 5: R1=R3=600-800 Ohms, R2 = 120 Ohms, Vcc = 3.3V. P.S. I think you logic analyser cant work with negative voltages that present on AB line, so you saw garbage (but i'm not about this - check your device datasheet). P.P.S check 6-7 steps \$\endgroup\$ Feb 10, 2022 at 7:17
  • \$\begingroup\$ It's not #1 because Modbus is not a proprietary protocol. \$\endgroup\$ Feb 10, 2022 at 13:50
  • \$\begingroup\$ I meant, than "original software" can use any other protocol than modbus for communication (something written specially for this device). \$\endgroup\$ Feb 10, 2022 at 16:26
  • \$\begingroup\$ #7: Using qmodbus software and same cable and connection parameters I can query solar controller correctly and I am getting correct reponses. I found one issue - my solar controller is newer that recent versions and now one registry address hold only one value. So after I updated code I don't get timeouts however readed registry values are always 0. However using qmodbus I can receive correct value. After I created pullup & pulldown line on 3,3V module voltage between A and B looks correct and module works exactly the same like 3,3V so I am not receiving timeouts anymore but always 0 values. \$\endgroup\$
    – michalo
    Feb 10, 2022 at 20:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.