Connecting an energy meter with a NodeMCU using modbus protocol

Hello all,
since 3 weeks I’m struck in this . please help me out.

I’m using NodeMCU to connect to an “Schneider electric EM-6436” energy meter via RS-485 connector using modbus protocol. When i try to send a query to the meter , i’m not getting any response from the meter. I checked with NodeMCU and RS-485 connector , everything is working fine. I think there may be a timing difference between querying and getting response.

This is the code i used:

#include <SoftwareSerial.h>
SoftwareSerial mySerial(13, 15); // RX, TX
void setup()

  • mySerial.begin(19200);*

  • pinMode(5,OUTPUT);*

  • pinMode(4,OUTPUT);*
    char rx=0;
    int i;
    int query[8]={0x01,0x03,0x0f,0x49,0x00,0x02,0x16,0xc9}; //This query i checked with simply modbus

  • master software*
    void loop()

  • digitalWrite(5,HIGH); //to make ~RE disable and DE enable of RS485*

  • digitalWrite(4,HIGH);*

  • for(i=0;i<8;i++)*

  • {*
    _ Serial.write(query*);_
    } *_

* Serial.flush();*

* digitalWrite(5,LOW); //to make ~RE enable and DE disable*
* digitalWrite(4,LOW);*

* while (mySerial.available()>0) ;*
* {*
* rx=;*
* Serial.print(rx);*
* mySerial.println(rx);*
* }*