Waveshare ESP32 RS485 to controllino

Hi all !

I'm trying for days to get the waveshare ESP32-CAN-RS485 module to communicate with my Controllino MAXI. Even the simplest demo for sending receiving does do anything.
It's confirmed the waveshare has GPIO 17 for TX and 18 For RX , GPIO 21 for EN

The controllino code for receiving :

  



 
#include <SPI.h>
#include <Controllino.h>

void setup()
{
Serial.begin(115200);

delay(3000);

Serial.println("CONTROLLINO RS485 READY");

Serial3.begin(9600);

// IMPORTANT
Controllino_RS485Init();

// receive mode
DDRJ = DDRJ | B01100000;
PORTJ = PORTJ & B10011111;
PORTJ = PORTJ | B00100000;

Serial.println("RS485 RECEIVE ENABLED");

}

void loop()
{
while (Serial3.available())
{
char c = Serial3.read();

    Serial.write(c);
}

}



And the ESP32 code for sending (ESPIF):


#include <cstring>




#include "driver/uart.h"

#include "driver/gpio.h"




#include "freertos/FreeRTOS.h"

#include "freertos/task.h"




#define TEST_UART UART_NUM_1




extern "C" void app_main()

{

    uart_config_t uart_config = {};




    uart_config.baud_rate = 9600;

    uart_config.data_bits = UART_DATA_8_BITS;

    uart_config.parity = UART_PARITY_DISABLE;

    uart_config.stop_bits = UART_STOP_BITS_1;

    uart_config.flow_ctrl = UART_HW_FLOWCTRL_DISABLE;

    uart_config.source_clk = UART_SCLK_DEFAULT;




    uart_driver_install(TEST_UART, 512, 512, 0, NULL, 0);




    uart_param_config(TEST_UART, &uart_config);




    uart_set_pin(TEST_UART,

                 GPIO_NUM_17,

                 GPIO_NUM_18,

                 UART_PIN_NO_CHANGE,

                 UART_PIN_NO_CHANGE);




    while (true)

    {

        const char *msg = "HELLO FROM ESP32\r\n";




        uart_write_bytes(TEST_UART,

                         msg,

                         strlen(msg));




        uart_wait_tx_done(TEST_UART,

                          pdMS_TO_TICKS(100));




        vTaskDelay(pdMS_TO_TICKS(1000));

    }

}

Whatever i try , swapping A+ and B- , trying other GPIO's , nothing works.
The LED on the waveshare ESP32 indicates that it is indeed sending over RS485.
But by no means i can receive on the controllino. For now i don't have a USB dongle to test.

Any ideas someone ? Thanks a zillion if you do :slight_smile:

I would suggest getting a USB_RS485 module for a PC
use it to get basic RS485 communication working between the PC and the waveshare ESP32-CAN-RS485 module

then start experimenting with the waveshare ESP32-CAN-RS485 module to Controllino MAXI - you can use the USB-RS485 module to monitor the communication traffic which may help debugging

make sure you have the correct terminating resistors at each end of the RS485 bus

have you an oscilloscope to look at the A and B signals?

Verify your receive setup. CONTROLLINO_Library/examples/MAXI/DemoRS485/DemoRS485.ino at master · CONTROLLINO-PLC/CONTROLLINO_Library · GitHub

I have tried this code before too, same result.

I just ordered a USB dongle, my osciloscope is broken.

Posting your annotated schematic may help us get you a valid answer quickly. Post links to technical information on each of the hardware devices.

In the end the Controllino was the cause . Got a USB RS485 adaptor and the esp32 did work just fine , but even with the default demo code I can’t get the Controllino to send or receive anything.

I’m going to change to the arduino Opta for my project