logo elektroda
logo elektroda
X
logo elektroda

How to connect DI and RO from RS485 converter to ESP8266 NodeMCU?

robo1973 1842 14
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
  • #1 18262035
    robo1973
    Level 15  
    Hello !!!!
    I bought an RS485 ba TTL adapter .
    In the loaded program I have the description
    
      // communicate with Modbus slave ID 2 over Serial (port 0)
      node.begin(1, Serial);
    
    .

    To which pin to connect DI and R0 from the converter ?
    Greetings !!!
  • ADVERTISEMENT
  • #2 18262228
    khoam
    Level 42  
    If it is a converter as in the image below then DI from TX and R0 from RX.

    How to connect DI and RO from RS485 converter to ESP8266 NodeMCU? .
  • ADVERTISEMENT
  • #3 18262239
    piterek-23
    Level 33  
    You still need to connect DE/RE to control the direction of reception/transmission
  • ADVERTISEMENT
  • #4 18262290
    robo1973
    Level 15  
    piterek-23 wrote:
    You still need to connect DE/RE to control the receive/transmit direction


    I only want to receive from the device How to connect these signals ?
  • ADVERTISEMENT
  • #5 18262365
    khoam
    Level 42  
    robo1973 wrote:
    I only want to receive from the device How do I connect these signals ?
    .
    Which library are you specifically using?
  • #6 18262514
    robo1973
    Level 15  
    
    #include <ModbusMaster.h>
    #include <ArduinoOTA.h>
    
    // instantiate ModbusMaster object
    ModbusMaster node;
    
    void setup(){
      
      // use Serial (port 0); initialize Modbus communication baud rate
      Serial.begin(115200);
      delay(10);
      //Serial.swap();
      //RS 482  DI z TX, a R0 z RX. 
      
      // communicate with Modbus slave ID 2 over Serial (port 0)
     
    node.begin(1, Serial);
      //RS 482
    ..
    ...
    ..
    
    
    
    .
  • #8 18262562
    robo1973
    Level 15  
    which means that
    
      // Callbacks allow us to configure the RS485 transceiver correctly
      node.preTransmission(preTransmission);
      node.postTransmission(postTransmission);
    

    settles the matter?

    By the way, what does this function do
    publishFloat("Ppv", glueFloat(node.getResponseBuffer(1), node.getResponseBuffer(2)));

    because client.publish(topic, value); publishes to mqtt a publishFloat ?
  • #9 18262583
    khoam
    Level 42  
    robo1973 wrote:
    settles the issue ?
    .
    In the code example I referred to, yes.

    Added after 8 [minutes]:

    robo1973 wrote:
    By the way, what does this function do
    publishFloat("Ppv", glueFloat(node.getResponseBuffer(1), node.getResponseBuffer(2)));
    .
    You haven't given me any chance, I'm going to guess :)
    Code: C / C++
    Log in, to see the code

    Source: https://github.com/jkairys/growatt-esp8266/blob/master/growatt-mqtt.ino
  • #10 18263039
    robo1973
    Level 15  
    hee ok thank you for your help
    so it sends data to topic_char, value_char ?
  • #11 18282311
    robo1973
    Level 15  
    How do I define communication over UART 1 TX1 RX1 ?

    Currently I have after UART 0 TX,RX

    
    void setup(){
      // use Serial (port 0); initialize Modbus communication baud rate
      Serial.begin(115200);
      Serial.swap();
      
      // communicate with Modbus slave ID 2 over Serial (port 0)
      node.begin(1, Serial);
    


    Serial.swap(); function starts communication on UART 1 but disables it on UART 0 And I would like to have RS458 on uart1 and uart0 logging on usb
  • #13 18284437
    robo1973
    Level 15  
    Can you explain to me how this function counts ?
    
    float glueFloat(unsigned int d1, unsigned int d0){
      unsigned long t;
      t = d1 << 16;
      t += d0;
    
      float f;
      f = t;
      f = f / 10;
      return f;
    }
    
     publishFloat("Pac", glueFloat(node.getResponseBuffer(11), node.getResponseBuffer(12)));
    
    .
  • #14 18284720
    khoam
    Level 42  
    unsigned long and unsigned int are the same types in ESP8266 -. uint32_t .
    This entire function can be replaced by the following:
    Code: C / C++
    Log in, to see the code
    .
  • #15 18285244
    robo1973
    Level 15  
    for the number d0 = 10 the function gives the value 1

    what does d1 do I don't really understand what it affects because each value does not change the result of the function ?

Topic summary

The discussion revolves around connecting the DI (Data Input) and RO (Receive Output) pins from an RS485 to TTL converter to an ESP8266 NodeMCU for Modbus communication. Users clarify that DI should connect to the TX pin and RO to the RX pin of the NodeMCU. Additionally, it is emphasized that DE/RE pins must be controlled to manage the direction of data transmission. The conversation also touches on using the ModbusMaster library for communication, with examples provided for setting up the serial communication and handling data transmission. Follow-up questions address UART configuration and the functionality of specific code snippets related to data publishing and float conversion.
Summary generated by the language model.
ADVERTISEMENT