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

    need help converting text to int (CORE2)

    Scheduled Pinned Locked Moved UIFlow
    5 Posts 3 Posters 12.1k Views 2 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.
    • ArnoA Offline
      Arno
      last edited by

      how to convert text extracted from a string via ESP NOW.
      0_1614535758163_1a40b9f8-a807-4ef2-ad77-33e8720834cb-image.png

      How to convert X to digital type integer?

      0_1614535888010_825dc2f1-470a-4490-9d1b-a66aa025e815-image.png

      I have error messages !

      I only use Uiflow ! with M5STACK Gray, RED, CORE2, ATOM, ATOM Lite,M5Paper, M5Tough, ATOM Display, M5 Stamp pico and more Unit...

      1 Reply Last reply Reply Quote 0
      • T Offline
        Thrasher
        last edited by

        X = int("x")

        1 Reply Last reply Reply Quote 0
        • ArnoA Offline
          Arno
          last edited by

          @thrasher said in need help converting text to int (CORE2):

          X = int (« x »)

          I have variment of help, voci several attempts with the error messages with UiFlow 1.7.3.

          0_1615742996554_af1d7cc7-db37-4694-8bef-31a105479a0f-image.png Error : can't convert noneType to int

          0_1615743082788_9cd8efde-3ef1-4d06-a2bb-a895cffb1d9b-image.png Error : name 'X' isn't defined

          0_1615743145276_d531ba80-10e2-4344-aa75-383e7304f263-image.png Error : can't convert noneType to int

          How to convert X (ex "7") to 7?

          Lack of documentation is a real problem

          I only use Uiflow ! with M5STACK Gray, RED, CORE2, ATOM, ATOM Lite,M5Paper, M5Tough, ATOM Display, M5 Stamp pico and more Unit...

          world101W 1 Reply Last reply Reply Quote 0
          • world101W Offline
            world101 @Arno
            last edited by world101

            @arno

            I think your issue is because you are using variable X within the ESP Now Receive Callback to hold the string data coming from the ESP Now transmitter device. Then within the Loop, you are trying to convert it to an integer. Upon program execution, the Python code has X=None, and is trying to convert X (which has no data yet) to an integer, thus throwing the error: can't convert noneType to int. So you have a few options. These worked for me.

            1. Define X within the Setup function like this...
              0_1615815666547_Screen Shot 2021-03-15 at 9.39.13 AM.png

            2. Redesign your program to perform all the calculations within the Receive Callback function. I actually prefer this option, because it doesn't require a Loop and is therefore non-blocking (no 1 second delay in the Loop). You're just waiting to receive data from ESP Now and then take action on it. However, I'm not sure what the rest of your program is supposed to achieve, so just take this into consideration.
              0_1615816004028_Screen Shot 2021-03-15 at 9.44.27 AM.png

            For reference, here is my ESP Now transmitter flow. It's an M5StickC with the JoyC Hat. It sends the X position data of the left joystick, mapped from 0 to 180, so it will turn a servo connected to port A on the Core2 (the ESP Now receiver).
            0_1615816326750_Screen Shot 2021-03-15 at 9.49.55 AM.png

            1 Reply Last reply Reply Quote 4
            • T Offline
              Thrasher
              last edited by

              There's execute code block also

              1 Reply Last reply Reply Quote 1

              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