🤖Have you ever tried Chat.M5Stack.com before asking??😎
    M5Stack Community
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    Serial2 on M5StickC

    M5 Stick/StickC
    3
    5
    15.7k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • K
      klimbot
      last edited by

      Has anyone been able to get Serial2 working on the M5StickC?
      I've tried all that I can think of but I'm stuck.

      I'm trying to use the hat pins at the top of the board, and from what I've read the ESP32 has the ability to assign almost any function to a particular pin. In my case I wanted to use pins 26 and 36 for TX and RX.

      I've tried a few different things including:

      • Using pins 36, 26 in setup
      • Using pins 5 and 15 in setup (based on this diagram I thought the pins might have been wrong)
      • Switched to just trying digitalWrite on the pins and looking for a result.

      My setup is:

      • M5StickC connected via USB to laptop - COM6
      • USB to serial device (jumper set to 3.3v) - COM7
      #include <M5StickC.h>
      
      
      void setup() {
        // Setup the TFT display
        M5.begin();
        
        // Setup the serial port for debugging
        Serial.begin(115200);
        Serial.println();
        Serial.println("Ready.");
      
        //Serial2.begin(115200, SERIAL_8N1, 26, 36);
        //Serial2.println("Testing Serial2");
        pinMode(5, OUTPUT);
        pinMode(15, OUTPUT);
      }
      
      void loop() {
        //Serial2.print("Testing Serial2: ");
        //Serial2.println(millis());
      
        digitalWrite(5, HIGH);
        digitalWrite(15, HIGH);
        delay(10);
        digitalWrite(5, LOW);
        digitalWrite(15, LOW);
         
      }
      

      Any thoughts?

      1 Reply Last reply Reply Quote 0
      • ChrisWRC
        ChrisWR
        last edited by

        Pin 36 can only be set as input, so 36 has to be rx

        K 1 Reply Last reply Reply Quote 0
        • K
          klimbot @ChrisWR
          last edited by

          @chriswr thanks for the suggestion, but still no luck.

          I've gone back to basics and tried to do a loopback test but can't even get that working! Will look further in to the manuals and see if there is any restriction on pins used for UART.

          Out of interest, can anyone tell me if the pin numbers quoted on the GitHub page for the M5StickC are the actual pin numbers we are supposed to use in the Arduino environment? Or do the GPIO numbers need to be converted to pin numbers?

          Thanks

          1 Reply Last reply Reply Quote 0
          • K
            klimbot
            last edited by

            I think I may have found my answer in the RS485 hat lib: https://github.com/m5stack/M5StickC/blob/master/examples/Hat/RS485/RS485.ino

            ajb2k3A 1 Reply Last reply Reply Quote 0
            • ajb2k3A
              ajb2k3 @klimbot
              last edited by

              @klimbot Sorry, not a user of arduino, I use micropython but yes, the rshat gives the clue.

              Pin 26, 0 is the communication port, 36 is the input.

              UIFlow, so easy an adult can learn it!
              If I don't know it, be patient!
              I've ether not learned it or am too drunk to remember it!
              Author of the WIP UIFlow Handbook!
              M5Black, Go, Stick, Core2, and so much more it cant be fit in here!

              1 Reply Last reply Reply Quote 0
              • First post
                Last post