Digital Serial Port or UART Issues on CubeCell AB01 V2

Hello members and contributors,

Here I am again asking for help. I have a couple of doubts that I haven’t been able to clarify after many attempts and several months of work.

I’m trying to set up a soil moisture monitor with two sensors connected to a Cubecell AB01 V2 , each one linked to an RS485 XY module (automatic RE/DE management). The sensors are powered by an external 5V source, and the board is powered at 4.2V through the JST connector .

I’m using the SoftSerial.h library, but after many tests, the board does not enter Deep Sleep mode . After reading several posts in this forum, I understand that SoftSerial.h causes many issues and is not reliable.

Now, I’m trying to connect one sensor to the board’s native UART port (UART_RX 14; UART_TX 15) , but it does not communicate with the RS485 module . There is some confusion regarding the Rx and Tx pin numbers.

Could someone confirm if SoftSerial.h prevents the board from entering Deep Sleep mode?
Is there another library that allows me to use two digital serial ports?

Thanks, I really need to find a solution.

I’m sharing a test code for communication with a sensor.

 #include "Arduino.h"

// Configuración de pines UART
#define UART_RX 14  // RX del CubeCell
#define UART_TX 15  // TX del CubeCell

// Trama MODBUS para leer 3 registros, ID = 1
const byte requestHTC[8] = { 0x01, 0x03, 0x00, 0x00, 0x00, 0x03, 0x05, 0xCB };
byte sensorResponse[12];  // Buffer para respuesta

void setup() {
  Serial.begin(115200);  // Consola USB para depuración
  delay(500);
  Serial.println("Iniciando comunicación RS485 con sensor CWM-HT...");

  // Inicializar UART1 para comunicación con sensor RS485
  Serial1.begin(9600, SERIAL_8N1, UART_RX, UART_TX);
  delay(1000);  // Espera para estabilización
}

void loop() {
  // Limpiar buffer de entrada
  while (Serial1.available()) {
    Serial1.read();
  }

  // Enviar solicitud al sensor
  Serial.println("\nEnviando solicitud al sensor...");
  Serial1.write(requestHTC, sizeof(requestHTC));

  // Esperar respuesta
  delay(300);  // El sensor suele responder en 100-200 ms

  // Leer respuesta
  int bytesRead = Serial1.readBytes(sensorResponse, 9);  // Mínimo 9 bytes

  if (bytesRead > 0) {
    Serial.print("Respuesta recibida (");
    Serial.print(bytesRead);
    Serial.println(" bytes): ");

    for (int i = 0; i < bytesRead; i++) {
      Serial.printf("%02X ", sensorResponse[i]);
    }
    Serial.println();

    // Validación rápida de la respuesta
    if (bytesRead >= 9 && sensorResponse[0] == 0x01 && sensorResponse[1] == 0x03) {
      // Interpretar humedad y temperatura
      uint16_t humedad = (sensorResponse[3] << 8) | sensorResponse[4];
      uint16_t temperatura = (sensorResponse[5] << 8) | sensorResponse[6];

      Serial.print("Humedad: ");
      Serial.print(humedad / 10.0);
      Serial.println(" %");

      Serial.print("Temperatura: ");
      Serial.print(temperatura / 10.0);
      Serial.println(" °C");
    } else {
      Serial.println("Datos recibidos no válidos.");
    }

  } else {
    Serial.println("No se recibió respuesta del sensor.");
  }

  delay(2000);  // Espera 2 segundos antes de la siguiente consulta
}

I’ve done some initial tests using RS485 with both CubeCell and CubeCell Plus, using softserial communicating via an RS485 adaptor module to an RS485-to-USB adaptor connected to my Mac. Both work fine but the connection does need to go through a UART.

The second UART on the CubeCell Plus is the easy one, just connect the RS485 adaptor TX and RX to the CubeCell Plus UART_TX2 and UART_RX2 pins. But the CubeCell is OK too, through it’s [only, in the case of the V1 board, or only accessible one in the case of the V2 board] UART (UART_TX and UART_RX), as long as you disconnect the USB cable from the CubeCell after uploading software.

You don’t need any definitions for these CubeCell [Plus] pins, just use the identifiers UART_TX/UART_RX or UART_TX2/UART_RX2—they are already defined—and connect the RS485 adaptor to the relevant CubeCell or CubeCell Plus pins. If you need to use the CubeCell’s USB port for anything other than the initial software upload, you might be out of luck—in that case you’ll need to consider using the CubeCell Plus or another processor with more than a single UART. While the ASR6502 processor, used in both the V2 and Plus boards, includes two UARTs, the CubeCell V2 schematic diagram does not indicate any connection to the second one.