# Heltec Wireless Stick V3: Modbus RS485 not working

**URL:** <https://forum.arduino.cc/t/heltec-wireless-stick-v3-modbus-rs485-not-working/1235237>\
**Category:** Networking, Protocols, and Devices\
**Created:** [March 13, 2024, 10:21pm UTC](https://forum.arduino.cc/t/heltec-wireless-stick-v3-modbus-rs485-not-working/1235237 "2024-03-13T22:21:14Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ondyy](https://avatars.discourse-cdn.com/v4/letter/o/258eb7/32.png) [@ondyy](https://forum.arduino.cc/u/ondyy)\
**Post date:** [March 13, 2024, 10:21pm UTC](https://forum.arduino.cc/t/heltec-wireless-stick-v3-modbus-rs485-not-working/1235237/1 "2024-03-13T22:21:14Z")

</div>

Hello,I am trying to set up communication with the Epever MPPT controller via Modbus. Unfortunately, with Heltec Wireless Stick V3 ([Wireless Stick(V3) – Heltec Automation](https://heltec.org/project/wireless-stick-v3/)) based on ESP32 the communication does not work - on the serial port it prints periodically same nonsense strings.

I tried the same code on the ESP32 Wroom kit, where the communication works properly and I get data from the controller as:

```arduino
PV Voltage:
0.00
PV Current:
0.00
Battery Voltage:
12.47

```

So the registers in the code must be set correctly.

I am using MAX3485 converter, pins DE and RE\_NEG are defined and wired the same. I have connected the RO and DI pins of the converter to the RX and TX pins of the Heltec Wireless Stick V3 board.

The connection of MAX3485 and Heltec Wireless Stick is:

```arduino
RO -> RX (GPIO 44)
RE| -> 46
DE -> 45
DI -> TX (GPIO 43)

```

The registers are definitely defined correctly, so the problem must be in the communication between Wireless Stick and converter for RS485.

I am attaching the code I was trying using ModbusMaster library:

```arduino
#include <ModbusMaster.h>

#define MAX485_DE 45
#define MAX485_RE_NEG 46

ModbusMaster node;

void preTransmission()
{
  digitalWrite(MAX485_RE_NEG, 1);
  digitalWrite(MAX485_DE, 1);
}

void postTransmission()
{
  digitalWrite(MAX485_RE_NEG, 0);
  digitalWrite(MAX485_DE, 0);
}

void setup()
{
  // put your setup code here, to run once:
  pinMode(MAX485_RE_NEG, OUTPUT);
  pinMode(MAX485_DE, OUTPUT);
  // Init in receive mode
  digitalWrite(MAX485_RE_NEG, 0);
  digitalWrite(MAX485_DE, 0);

  // Modbus communication runs at 115200 baud
  Serial.begin(115200);

  //Modbus slave ID 1
  node.begin(1, Serial);
  // Callbacks allow us to configure the RS485 transceiver correctly
  node.preTransmission(preTransmission);
  node.postTransmission(postTransmission);

  Serial.println("test");
}

void loop()
{
  // put your main code here, to run repeatedly:
  uint8_t resultMain;

  resultMain = node.readInputRegisters(0x3100, 6);
  if (resultMain == node.ku8MBSuccess)
  {
    Serial.println(" - - - - - - - - ");
    Serial.println("PV Voltage: ");
    Serial.println(node.getResponseBuffer(0x00) / 100.0f);
    Serial.println(node.getResponseBuffer(0x00) / 100.0f);
    Serial.println(node.getResponseBuffer(0x00) / 100.0f);
    Serial.println("PV Current: ");
    Serial.println(node.getResponseBuffer(0x01) / 100.0f);
    Serial.println("Battery Voltage: ");
    Serial.println(node.getResponseBuffer(0x04) / 100.0f);
    Serial.println("Battery Charge Current: ");
    Serial.println(node.getResponseBuffer(0x05) / 100.0f);
  }
  else
  {
    Serial.println("Error ");
    Serial.println(resultMain);
  }

  delay(1000);

}

```

This if `(resultMain == node.ku8MBSuccess)` returns false and resultMain says value **226**.

I have tried different combinations of wiring RE| and DE but it didn't help.

I looked at this similar thread: [Reading Solar Charger COM via MODBUS (MAX485) Problem - Using Arduino / Networking, Protocols, and Devices - Arduino Forum](https://forum.arduino.cc/t/reading-solar-charger-com-via-modbus-max485-problem/697035) but it also didn't solve it.

Could you please help me find out where the problem is and how to solve it? Thanks

---

<div class="post-metadata">

**Author:** ![horace](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/horace/32/1014299_2.png) [@horace](https://forum.arduino.cc/u/horace)\
**Post date:** [March 14, 2024, 6:42am UTC](https://forum.arduino.cc/t/heltec-wireless-stick-v3-modbus-rs485-not-working/1235237/2 "2024-03-14T06:42:24Z")

</div>

are you sure the basic serial IO is working  
I don't have a Heltec Wireless Stick V3 but the following test works on the V1 and V2

```cpp
// TTGO LoRa32 SX1276 OLED Serial1 test - for loopback test connect pins 16 and 17

// Board Heltec WiFi LoRa 32 (V2) works on Heltec WiFi LoRa 32 V1 aand V2

#define RXD1 16
#define TXD1 17

void setup() {
  // initialize both serial ports:
  Serial.begin(115200);
  //Serial1.begin(115200, SERIAL_8N1, RXD1, TXD1);
  Serial1.begin(115200, SERIAL_8N1, RXD1, TXD1);
  Serial.println();
  Serial.println("\n\nESP32 serial1 test Rx pin 16 Tx pin 17");
  Serial.write(" for loopback test connect pin 16 to pin 17\n");
}

void loop() {
  // read from port 1, send to port 0:
  if (Serial1.available()) {
    int inByte = Serial1.read();
    Serial.write(inByte);
  }

  // read from port 0, send to port 1:
  if (Serial.available()) {
    int inByte = Serial.read();
    //Serial.write(inByte);
    Serial1.write(inByte);
  }
}

```

I find it is worth getting a USB-RS485 dongle for testing the network and monitoring traffic

---

<div class="post-metadata">

**Author:** ![ondyy](https://avatars.discourse-cdn.com/v4/letter/o/258eb7/32.png) [@ondyy](https://forum.arduino.cc/u/ondyy)\
**Post date:** [March 14, 2024, 11:17pm UTC](https://forum.arduino.cc/t/heltec-wireless-stick-v3-modbus-rs485-not-working/1235237/3 "2024-03-14T23:17:11Z")

</div>

Thank you so much for the advice, you are a god! You helped me solve a problem I've been really dealing with for a month. Perfect!

First I verified serial communication within one Heltec V3 board, then with another ESP32 and then with the MPPT controller.

Here are the values:

00:14:45.545 -\> - - - - - - - -  
00:14:45.545 -\> PV Voltage:  
00:14:45.545 -\> 2.95  
00:14:45.545 -\> PV Current:  
00:14:45.545 -\> 0.00  
00:14:45.545 -\> Battery Voltage:  
00:14:45.545 -\> 12.17  
00:14:45.545 -\> Battery Charge Current:  
00:14:45.545 -\> 0.00

Now I just need to adjust the measurements in between deep sleep mode, but hopefully that won't be such a problem anymore.

Thank you ☺ 🙏

---

<div class="post-metadata">

**Author:** ![horace](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/horace/32/1014299_2.png) [@horace](https://forum.arduino.cc/u/horace)\
**Post date:** [March 15, 2024, 5:18am UTC](https://forum.arduino.cc/t/heltec-wireless-stick-v3-modbus-rs485-not-working/1235237/4 "2024-03-15T05:18:04Z")

</div>

good to hear it worked!  
mark post 2 as the solution to assist anyone else with a similar problem

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [September 11, 2024, 5:18am UTC](https://forum.arduino.cc/t/heltec-wireless-stick-v3-modbus-rs485-not-working/1235237/5 "2024-09-11T05:18:19Z")

</div>

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.
