Having Trouble Getting PyCharm to work with Microbit

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
APlot
Posts: 3
Joined: Wed Jan 01, 2020 8:39 pm

Having Trouble Getting PyCharm to work with Microbit

Post by APlot » Wed Jan 01, 2020 9:22 pm

I have been trying to move over from Mu-Editor to PyCharm for developing code form my BBC Microbit, though I just can’t seem to get the configuration to work properly. I initially tried the basic walkthrough provided by JetBrains for their plugin, though I wasn’t able to get the uFlash module installed in the default interpreter; it kept running into an issue with the SSL module not being available. So then I switched PyCharm to my Anaconda interpreter, which I had uFlash already installed to. Using this method I am able to successfully connect to my Microbit, and can even run code in REPL mode no problem. It is when I try to flash the device, however, my code is only partially functional. Even when using the exact same code I had previously flashed it with successfully in Mu-Editor.

Kasey00
Posts: 1
Joined: Sat Jan 11, 2020 7:07 pm

Re: Having Trouble Getting PyCharm to work with Microbit

Post by Kasey00 » Sat Jan 11, 2020 7:19 pm

APlot wrote:
Wed Jan 01, 2020 9:22 pm
I have been trying to move over from Mu-Editor to PyCharm for developing code form my BBC Microbit, though I just can’t seem to get the configuration to work properly. I initially tried the basic walkthrough provided by JetBrains for their plugin, though I wasn’t able to get the 9apps uFlash module installed in the default interpreter; it kept running into an issue with the SSL module not being available. So then I switched PyCharm to my Anaconda interpreter, which I had uFlash already installed to. Using this method I am able to successfully connect to my Microbit, and can even run code in REPL mode no problem. It is when I try to flash the device, however, my code is only partially functional. Even when using the exact same code I had previously flashed it with successfully in Mu-Editor.
I use Mu Editor as my main MicroPython IDE. It's really great for small to medium projects.
It works with the BBC:micro-bit and Adafruit boards but also with a few ESP8266 and ESP32. The only catch for the "non supported" boards is that you must run Mu Editor from the source code after poking a few lines.
The code is very readable. You just need to skip the "vid" and "pid" filter and you are ready to go: Capable code editor, REPL and file transfer.
Last edited by Kasey00 on Tue Jan 14, 2020 7:17 am, edited 1 time in total.

User avatar
jimmo
Posts: 2754
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: Having Trouble Getting PyCharm to work with Microbit

Post by jimmo » Sat Jan 11, 2020 10:51 pm

APlot wrote:
Wed Jan 01, 2020 9:22 pm
It is when I try to flash the device, however, my code is only partially functional
What does "partially functional" mean? That might give some hints as to what's going wrong.

APlot
Posts: 3
Joined: Wed Jan 01, 2020 8:39 pm

Re: Having Trouble Getting PyCharm to work with Microbit

Post by APlot » Sun Jan 12, 2020 10:03 pm

jimmo wrote:
Sat Jan 11, 2020 10:51 pm
APlot wrote:
Wed Jan 01, 2020 9:22 pm
It is when I try to flash the device, however, my code is only partially functional
What does "partially functional" mean? That might give some hints as to what's going wrong.
The accelerometer will not function at all.

Upon further digging, I have discovered that Microbit switched from a separate accelerometer and compass on earlier iterations to a single combined sensor. Would it be safe to assume then that the Pycharm extension simply hasn’t been updated to account for this change?

User avatar
jimmo
Posts: 2754
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: Having Trouble Getting PyCharm to work with Microbit

Post by jimmo » Sun Jan 12, 2020 10:57 pm

Yep, that would be exactly it.

If pycharm is using uflash, then it might just be a matter of updating uflash? (uflash provides the base firmware image that your Python code is appended to).

APlot
Posts: 3
Joined: Wed Jan 01, 2020 8:39 pm

Re: Having Trouble Getting PyCharm to work with Microbit

Post by APlot » Mon Jan 13, 2020 12:18 am

SO I tried updating uFlash, but unfortunately the Pycharm plugin didn’t like that, saying that it needs to install uFlash>=1.0.8,<1.1. Looks like I’m out of luck until the developer updates the plugin to support the newer version of this module.

User avatar
jimmo
Posts: 2754
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: Having Trouble Getting PyCharm to work with Microbit

Post by jimmo » Mon Jan 13, 2020 12:26 am

In the meantime, uflash is pretty easy to use from the command line. So you'll still be able to use pycharm to edit and access the REPL etc, just have a second window with a terminal ready to run the uflash command.

User avatar
jimmo
Posts: 2754
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: Having Trouble Getting PyCharm to work with Microbit

Post by jimmo » Mon Jan 13, 2020 12:27 am

FYI, if you are using uflash, if you also have the latest daplink firmware on your microbit, you can get _much_ faster flashing times. Well worth checking and updating the firmware if necessary.

See https://support.microbit.org/support/so ... -micro-bit

Post Reply