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

    TAIL485

    Scheduled Pinned Locked Moved Modules
    4 Posts 3 Posters 9.0k Views 1 Watching
    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.
    • C Offline
      cepics
      last edited by cepics

      hi all,
      I'm reading a serial machine data out , on ATOM, with this RS422/TTL YL-128 adaptor
      datasheet

      with this code

      void setup() {
      
        Serial.begin(115200);
        delay(1000);
      
      //              speed, mode,      rx, tx
        Serial2.begin(9600, SERIAL_8N1, 26, 32);
        delay(1000);
      
      void loop() {
        recvBytesWithStartEndMarkers();
        showNewData();
      }
      
      void recvBytesWithStartEndMarkers() {
        static boolean recvInProgress = false;
        static byte ndx = 0;
        byte startMarker = 0x7C; // "|"
        byte endMarker = 0x0A; // (LF) "/n"
      
        //  byte startMarker = 0x0A; // "/n"
        //  byte endMarker = 0x0D; // (CR) "/r"
      
      
        byte rb;
      
        while (Serial2.available() > 0 && newData == false) {
          rb = Serial2.read();
      
          if (recvInProgress == true) {
            if (rb != endMarker) {
              receivedBytes[ndx] = rb;
              ndx++;
              if (ndx >= numBytes) {
                ndx = numBytes - 1;
              }
            }
            else {
              receivedBytes[ndx] = '\0'; // terminate the string
              recvInProgress = false;
      
              numReceived = ndx;  // save the number for use when printing
              ndx = 0;
              newData = true;
            }
          }
      
          else if (rb == startMarker) {
            recvInProgress = true;
          }
        }
      }
      
      void showNewData() {
        if (newData == true) {
      
          //    Serial.print(" ... HEX Value.. ");
          for (byte n = 0; n < numReceived; n++) {
            Serial.print(receivedBytes[n], HEX);
            Serial.print(' ');
      
            if (receivedBytes[numReceived - 3] == 0x36 && receivedBytes[numReceived - 6] == 0x30) {
              unit = 0; // CM ARRI 60
            }
      
            if (receivedBytes[numReceived - 3] == 0x37 && receivedBytes[numReceived - 6] == 0x30) {
              unit = 1; //FT ARRI 70
            }
      
            if (unit == 0 && receivedBytes[numReceived - 6] == 0x31) {
              cm = receivedBytes[numReceived - 4] * 100 + receivedBytes[numReceived - 3] * 10 + receivedBytes[numReceived - 2];
      
            }
            if (unit == 1 && receivedBytes[numReceived - 6] == 0x31) {
              ft = receivedBytes[numReceived - 5] * 10 + receivedBytes[numReceived - 4];
              inc = receivedBytes[numReceived - 3] * 10 + receivedBytes[numReceived - 2];
      
            }
          }
          Serial.println();
          Serial.print ("cm ");
          Serial.println (cm);
          Serial.print ("ft ");
          Serial.println (ft);
          Serial.print ("inc ");
          Serial.println (inc);
      
          newData = false;
      
        }
      }
      

      and this connections:

      machine----------------------------- RS422/TTL
      grd ------------------------------------ A ............. Y-----NC
      sgl ------------------------------------- B ............. Z----NC
      12V ----- +12v

      RS422/TTL ---------- ATOM
      TX ---------------------- RX
      RX -----------------------TX
      5V ---------------------- 5V
      GRD -------------------- GRD

      the newbie question is:

      can I use instead RS485 module based on SP485EEN-L ??

      tnks a lot

      1 Reply Last reply Reply Quote 0
      • C Offline
        cepics
        last edited by

        nobody?

        1 Reply Last reply Reply Quote 0
        • m5stackM Online
          m5stack
          last edited by

          The RS422 module you are using is not compatible with our RS485

          J 1 Reply Last reply Reply Quote 0
          • J Offline
            Johnny241 @m5stack
            last edited by

            @m5stack Hello!

            I would like to know to which bronchi pins A and B of the RS485 extension card are connected to the BUS, please.

            I can't get my M5 to communicate via RS485, however I soldered the small expansion card well.
            For my program I am using an ESP32 based Arduino library for the Modbus RTU

            1 Reply Last reply Reply Quote 0

            Hello! It looks like you're interested in this conversation, but you don't have an account yet.

            Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

            With your input, this post could be even better 💗

            Register Login
            • First post
              Last post