Navigation

    LILYGO

    • Register
    • Login
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    1. Home
    2. utr_brk
    3. Posts
    U
    • Profile
    • Following 0
    • Followers 0
    • Topics 2
    • Posts 2
    • Best 0
    • Groups 0

    Posts made by utr_brk

    • T-RSC3 Serial Ports

      T-RSC3 has one isolated RS-232 port, one isolated RS-485 port and one TTL serial port on 2x6 female header.
      And there is also one virtual serial port which is used for programming etc, on the USB-C port.

      I can access Virtual serial port as Serial, TTL serial port as Serial0.
      But never achieved to access RS-232 and RS-485 ports.
      I am using Arduino-IDE to program T-RSC3.

      Any suggestions to use 232/485 ports will be much appeciated.

      Best regards.
      BT

      posted in Product information
      U
      utr_brk
    • T-RSC3 Serial Ports

      I cannot receive or transmit data from RS232 orRS485 ports.
      USB-C port is ok.
      I use Serial.begin(9600); for USB port and Serial232.begin(RS485_BAUD, SERIAL_8N1, RS232_RX_PIN, RS232_TX_PIN); for the 232 port.
      What is the correct ports for RS232 and RS485 ports, Serial1 or Serial0?

      Kind regards,

      #if CONFIG_FREERTOS_UNICORE
      #define ARDUINO_RUNNING_CORE 0
      #else
      #define ARDUINO_RUNNING_CORE 1
      #endif
      
      #include "Arduino.h"
      #include "HardwareSerial.h"
      #include <Adafruit_NeoPixel.h>
      
      #define Serial232        Serial1
      #define RS485_BAUD       9600
      #define RS232_RX_PIN     1
      #define RS232_TX_PIN     0
      #define LED_PIN          4
      #define KEY_PIN          2
      #define BOOT_PIN         9
      #define NUMPIXELS        1
      #define DELAYVAL 1000
      #define RS485_TX_ENABLE  HIGH
      #define RS485_RX_ENABLE  LOW
      
      Adafruit_NeoPixel pixels(NUMPIXELS, LED_PIN, NEO_GRB + NEO_KHZ800);
      bool RS485mode = true;
      
      void TaskBlink( void *pvParameters );
      void Task_RS485( void *pvParameters );
      void Task_RS232( void *pvParameters );
      void colorWipe(uint32_t color, int wait);
      
      void setup()
      {
        Serial232.begin(RS485_BAUD, SERIAL_8N1, RS232_RX_PIN, RS232_TX_PIN);
          Serial.begin(9600);
          pixels.begin();
          pixels.setBrightness(255);
          pixels.clear();
      
          
          delay(100);
      
      Serial.println("com6");
      Serial232.println("com232");
          xTaskCreatePinnedToCore(
              TaskBlink
              ,  "TaskBlink"
              ,  1024  // This stack size can be checked & adjusted by reading the Stack Highwater
              ,  NULL
              ,  2  // Priority
              ,  NULL
              ,  ARDUINO_RUNNING_CORE);
      
          xTaskCreatePinnedToCore(
              Task_RS232
              ,  "Task_RS232"
              ,  1024  // Stack size
              ,  NULL
              ,  1  // Priority
              ,  NULL
              ,  ARDUINO_RUNNING_CORE);
      
      }
      
      void loop()
      {
          vTaskDelay(10);
      }
      
      void TaskBlink(void *pvParameters)
      {
          (void) pvParameters;
          for (;;) {
      
              colorWipe(pixels.Color(255,   0,   0), 500); // Red
              colorWipe(pixels.Color(  0, 255,   0), 500); // Green
              colorWipe(pixels.Color(  0,   0, 255), 500); // Blue
              vTaskDelay(5);
          }
      }
      
      void Task_RS232(void *pvParameters)
      {
          (void) pvParameters;
      
          for (;;) {
              while (Serial.available())
                  Serial232.write(Serial.read());
              while (Serial232.available())
                  Serial.write(Serial232.read());
              vTaskDelay(10);
          }
      }
      
      void colorWipe(uint32_t color, int wait)
      {
          for (int i = 0; i < pixels.numPixels(); i++) {
              pixels.setPixelColor(i, color);
              pixels.show();
              vTaskDelay(wait);
          }
      }
      
      posted in Common problems
      U
      utr_brk