robintibor/python-mindwave-mobile

neurosky mobile 2 with raspberry pi and python 3

robotsaura opened this issue · 1 comments

I've never left a comment/ reported an issue... so forgive me if this is misplaced. I have been trying to connect the neurosky mindwave mobile 2 with raspberry pi 3 via python3. I finally got it working thanks to these examples, though I had a bit of issues that I wanted to share in case anyone is going through something similar.

My experience level in python and linux OS is very beginner. I typically just blindly follow directions first and then try to address issues as they come up.

  1. when I originally found this example, I used the command in the terminal that pulls from the github repository. Unfortunately, this loaded an older version, not the current one. Not sure how I would have done the latest one. I noticed that the version I loaded was for python2 as the errors I received (and googled) pointed this issue out. I was getting this error: "TypeError: Can't convert 'bytes' object to str implicitly" ... apparently that's a python 2 thing and python 3 has a different way of do it.

  2. when I went to the actual github site (this one), I noticed that the conversion from python2 to 3 had been made (oh, so sweet, thank you). So, I copy pasted all the guts of each of these files ( "MindwaveMobileRawReader", "MindwaveDataPoints", "MindwavePacketPayloadParser","MindwaveDataPointReader") because I don't know to update it. I'm not used to linux commands to know how to do it otherwise.

  3. I did have issues being able to save / change code , so I made a new folder with all the python code and it's allowing me to rewrite them now. It wouldn't even let me change the permissions in the 'preferences' for the original folder.

  4. I connected my neurosky to the raspberry pi manually, but this actually caused an issue because the python code is also trying to connect. When I disconnected manually and then run the code, it reconnected fine.

  5. I got these errors: "SystemError: Parent module '' not loaded, cannot perform relative import". I went through the format of how some of these files are imported. I noticed in the "read_mindwave_mobile" it says "from MindwaveDataPoints import RawDataPoint", but the error was about "MindwaveMobileRawReader" not being able to be imported. The file trying to import was in "MindwaveDataPointReader" and this one had a period before the words so it looked like "from .MindwaveMobileRawReader import MindwaveMobileRawReader" and when I deleted that period, it worked fine. Again, I'm not well versed in python or linux... not sure what the period means (I'm assuming something about how to find that folder/file), and so maybe where my files are may not be where they should be or how it was intended. Currently, all my mindwave python files are in the same folder. I'm using "Thonny python IDE" as it comes with the image for raspPi that I downloaded from the raspberry site 5/28/2019. (edit: I removed all the periods from all the files that had them, then it worked)

thanks
s

Thanks for writing all this! :) 1/2 is a bit strange, you should have the newest version, also when you pull it, no idea what happened there.

About 5, the dot is for relative imports (https://stackoverflow.com/questions/7279810/what-does-a-in-an-import-statement-in-python-mean) .. in any case if it works for you after deleting dot, it's ok.