Closed duyle1402 closed 5 months ago
Hi @duyle1402 ,
Because you tested the code with UART2 (UART2 <=> USB) and it works fine, the problem lies in the UART1 <=> RS485 conversion. Check some of the following conditions: -What Baud rate are you operating at? The circuit board uses 1nF capacitors combined with 56k resistors to take care of auto DE and RE so it is actually designed to work well at baud rates of 4800 - 115200, I think it will cover almost all speeds. popular that we often use. -Have you enabled power for the RS485 block? Help me determine accurately using a meter (VOM). If there is no power (3.3V) at the RS485 terminal, try connecting 3.3V power on the I2C terminal to the RS485 terminal (use wire). Because there exists a hardware error regarding power activation on version 1.
I have update code (add description) Plz pull again. thank you.
Thanks a Nam for quickly reply, Here is my code I tested with Uart1 and it's work, i had ENABLE for RS485 block.
`#define BUFFER_SIZE 64 // Rak define
void setup() {
pinMode(LED, OUTPUT); pinMode(VRS_PIN, OUTPUT); digitalWrite(VRS_PIN, PWR_ON); //On power Vrs485 pinMode(VSS_PIN, OUTPUT); digitalWrite(VSS_PIN, PWR_ON); //On power Vsensor // Khởi tạo cổng serial với tốc độ baud là 9600 Serial.begin(115200); // uart 2 for minitor Serial1.begin(9600); // uart 1 } void loop() { // check data if (Serial1.available() > 0) { // create receive buffer char receivedData[BUFFER_SIZE]; int i = 0; // Biến chỉ mục cho buffer while (Serial1.available() > 0) { receivedData[i] = Serial1.read(); i++; delay(10); } // end of receive data by null receivedData[i] = '\0'; // print data Serial.print("Received: "); Serial.println(receivedData); }
// send data to computer
if (Serial1.available() > 0)
{
Serial1.println("data from rak through uart 1");
delay(1000);
}
}
`
Result:
So, how about Read/Write with Modbus poll now bro?
If it still not work, jelp me take some picture like this:
Wait me a minutes and I will update result soon,
I sill cant read data,
Here modbus's display images
_frameDelay = 5; //24000/_baud;
The others is same as this lib, I guest this is problem of Rak and RUI3 or We are missing some thing importantCuz you recieved character correct in side RAK, and transmit from Modbus Poll success. It mean Rx of RAK work good. So I beliver it related to DE-RE or Tx of RAK.
Can you see both led on board (led tx and rx of modbus, color blue) flicker? A 15sec video of how the leds blink would be helpful to me.
Helpme change this to value 0
Hi a Nam, To facilitate communication, I can connect with you via zalo or whatapp and we will post the results after solving the problem so everyone can follow along if they encounter the same problem?
My whatsapp: https://wa.me/84969809444
Sloved: At these moments, the newer version we can download is 4.1.0, try Update RUI3 version to the 4.1.1 (not stable version), I think Rak Team will release this version soon. Can follow this link to download: https://forum.rakwireless.com/t/rui3-best-practice-collection-of-rui3-example-code/11256 After update RUI3 version, this example will work. Thanks, a Nam for helping.
I am experiencing an issue with the Canopus version 1 board. The Modbus Master example code available on GitHub is not working, and my own code that uses the frames is also not working. I could not find the library you mentioned when I tried to download it.
Dear @sl446, Nice to know you. Since this topic is closed, could you help me open a new issue and add some descriptive information like the status of the modbus Tx and Rx leds working? The correct connection diagram is A to A, B to B and the register address you want to read, along with your code.
This will make it easier to track for those who encounter similar problems in the future. I have received your feedback via email and whatsaap, since you need to solve it quickly, I hope it can be done via anydesk to reduce your waiting time.
Hi a Nam, I tested your example code Rak3172 working as Modbus slave but it's doesn't work, I am using your example and Modbus Poll working as master for reading data from Rak_v1 I don't know exactly where is the problem. I tested some simple cases and wiring or hardware is not problem.
But when I am using this code for Rak3172 and it can't run. Any suggest for me, Did I forget anything? Thanks.