need help converting text to int (CORE2)
-
how to convert text extracted from a string via ESP NOW.
How to convert X to digital type integer?
I have error messages !
-
X = int("x")
-
@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.
Error : can't convert noneType to int
Error : name 'X' isn't defined
Error : can't convert noneType to int
How to convert X (ex "7") to 7?
Lack of documentation is a real problem
-
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.
-
Define X within the Setup function like this...
-
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.
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).
-
-
There's execute code block also