Navigation

    M5Stack Community

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    1. Home
    2. Xio1996
    3. Best
    X
    • Continue chat with Xio1996
    • Start new chat with Xio1996
    • Flag Profile
    • Profile
    • Following
    • Followers
    • Blocks
    • Topics
    • Posts
    • Best
    • Groups

    Best posts made by Xio1996

    • RE: ESP-Now UIFlow to Arduino

      Hi Lukas,

      Thank you for the link. I will see if I can use their method. I did find a solution that works.

      I noticed that the received data starting at index 11 was getting ASCII codes so I modified the Arduino code to construct a String starting from that position. The ESP-Now OnDataRecv callback now looks like this (the string construction is in bold).

      void OnDataRecv(const uint8_t *mac_addr, const uint8_t *data, int data_len)
      {
      char macStr[18];

      String tData="";
      char Ascii[1];
      for(int i=10;i<data_len;i++)
      {
      tData+=(char)data[i];
      }

      snprintf(macStr, sizeof(macStr), "%02x:%02x:%02x:%02x:%02x:%02x",
      mac_addr[0], mac_addr[1], mac_addr[2], mac_addr[3], mac_addr[4], mac_addr[5]);

      Serial.print("Last Packet Recv from: "); Serial.println(macStr);
      Serial.print("Data Length: "); Serial.println(data_len);
      Serial.print("Last Packet Recv Data: '"); Serial.print(tData);
      Serial.println("'");
      }

      Arduino Output

      13:38:11.806 -> Last Packet Recv from: d8:a0:1d:55:4b:38
      13:38:11.806 -> Data Length: 22
      13:38:11.806 -> Last Packet Recv Data: 'Hello World!'

      posted in UIFlow
      X
      Xio1996