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);
}