"Can´t convert NoneType to int" issue
-
Hello,
I am working on a simple program.
I receive a value between 0 and 1000 by MQTT and convert it to a digital value from 0 to 255.
Then I want to put it on the DAC channel 0.But if I want to proceed with the digital value within the main loop I get the error "Can´t convert NoneType to int".

I understand that this is a NoneType, which can´t convert into an integer, but I need to work with the digital value in the main loop, because I have to do some calculations (filtering), which is not possible in the MQTT function.
How can I solve this issue?

-
I found a workaround meanwhile with if-else.
It is not nice, but it´s working:
-
I convert the DAC Value into a String.
-
Then I check, if it is "None", if yes I send a 0 to the DAC.
-
If DAC Value is not "None" I convert it back to integer and send it directly to the DAC.

-
-
Are you using a “convert to int” block to convert the value being sent to the dac?
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