I am using the RP2040 pico pi with Arduino, on the board I have implemented Modbus TCP and RTU. The TCP works seamlessly while I am not able to get the Modbus RTU on RS485 to work.
I am using the MAX3485 chipset with TX connected to GP4 and RX (DO) connected to GP5 (DI) , the RE/DE is connected to GP14. GP4/GP5 is Uart1.
In the Library that I am using I am only able to change the TX pin GP14.
I'm also handling a Modbus RTU issue. I'm using the Arduino Modbus Library, and I can verify my code on UNO and Mega, but when I try to compile the same code in RPI PICO, the RS485 driver comes out and gives several errors; I tried to change the .h file in RS485 lib but failed...
The problem underneath is the difference between PICO and UNO handles UART? Or maybe there are some assumptions when Arduino writes RS485 driver that PICO doesn't follow?
If you have fixed your problem, please do share. Thanks!
I may have some progress here. I looked up the Arduino MEGA board's 'pins_arduino.h' file; in the last part, there are definitions about 'SERIAL_PORT_HARDWARExxxx,' copy and paste these to RPI PICO's 'pins_arduino.h' file and change these pins according to your designs.
I didn't test how things work here because I don't have my rs485 adaptors right now, but I made Arduino IDE compile successfully after this modification.
If you ever met some issue with the I2C device when using PICO, consider using the 'wire.h' from rp2040 libraries, which should resolve some compile issues.
error: no matching function for call to 'RS485Class::RS485Class(int, unsigned int, int, int)'
189 | RS485Class RS485(SERIAL_PORT_HARDWARE, RS485_DEFAULT_TX_PIN, RS485_DEFAULT_DE_PIN, RS485_DEFAULT_RE_PIN);
note: no known conversion for argument 1 from 'int' to 'arduino::HardwareSerial&'
no known conversion for argument 1 from 'int' to 'arduino::HardwareSerial&'
22 | RS485Class::RS485Class(HardwareSerial& hwSerial, int txPin, int dePin, int rePin):
note: candidate: 'constexpr RS485Class::RS485Class(const RS485Class&)'
45 | class RS485Class : public Stream {
I also met your problem; I can use it on UART 1 (@GP4/5), but I didn't make it run on GP0/1; since I have spear pins, I used this configuration for my application.
@dj1zulu , Did you manage to get the slave modbus RTU working on Serial1 with GP4 and GP5 ? I am facing a similar issue. I do not have any compilation errors but the communication is not happening with the Master node