RS485 with RAK11200

Hello
I would like to know if you can help me how to modulate with the rak11200 core my code that I made with the RAK4631, since the RAK 4631 works with the ArduinoRS485 library and the other one (RAK11200) does not.
I am using the RAK5802 IO.

I saw the use of the AduinoRS485 library in the examples for the RAK5802 with the RAK4631 core.
In the case of the examples using the RAK11200, it makes use of the ModbusRTU library but I can’t understand how I can handle the RS485 protocol as halfduplex.

code:

#include “EasyScheduler.h”
#include <ArduinoRS485.h>

Schedular Task1;
uint8_t Voltage_Batery[8] = {0x01, 0x04, 0x31, 0x04, 0x00, 0x01, 0x26, 0x60};

byte st[6];
byte buffer[10];

void setup()
{
Serial.begin(115200);
Serial1.begin(115200);
RS485.begin(115200);
pinMode(WB_IO2, OUTPUT);
digitalWrite(WB_IO2, HIGH);
Task1.start();

}

void loop() {
Task1.check(Batery, 60000);//call function batery every minute

}

void Batery()
{

RS485.beginTransmission();
RS485.write(Voltage_Batery,8);
RS485.flush();
RS485.endTransmission();

delay(100);

RS485.receive();
int numbytes= RS485.available();
Serial.println(numbytes);
if(numbytes>0)
{
RS485.readBytes(buffer, numbytes);
RS485.flush();

}
delay(100);
Serial.printBuffer(buffer,numbytes,’:’);
Serial.println();
st[0]=0x00;//dato
st[1]=0x01;
st[2]=buffer[3];
st[3]=buffer[4];
st[4]=buffer[5];
st[5]=buffer[6];

Serial.printBuffer(st,14,’:’);
Serial.println();
RS485.beginTransmission();
RS485.write(st,14);
RS485.flush();
RS485.endTransmission();
delay(100);
}

Hi @JorgeFG ,

I have limited working knowledge of RS485. But I have the modules here so I can try to help. What exactly are you trying to do? 2 WisBlock Core communicating to each other? 1 WisBlock Core and external RS485 peripheral [sensor, actuator, etc.]?

thanks for taking the time @carlrowan. What I want to do is communicate with an external peripheral by RS485.

Before communicating with the device, you want to understand how the ModbusRTU library works since the ArduinoRS485 Library for the RAK4631 core is very similar to the Serial one. in this case, for testing, it would be to send the byte array Battery_Voltage and wait for any response from another RAK11200.

Hello, I don’t know if I get your problem right. But if you are trying to send the byte array Battery_Voltage from a WisBlock Core(RAK11200) to another WisBlock Core(RAK11200), you just have to assign a master and slave.

You can refer to these examples:
WisBlock/RTU-master.ino at master · RAKWireless/WisBlock (github.com)

WisBlock/RTU-slave.ino at master · RAKWireless/WisBlock (github.com)

I hope this helps.