BBC Micro:Bit MicroPython no module named radio

Questions and discussion about running MicroPython on a micro:bit board.
Target audience: MicroPython users with a micro:bit.
gkb14
Posts: 2
Joined: Tue Jul 19, 2016 11:11 pm

BBC Micro:Bit MicroPython no module named radio

Postby gkb14 » Tue Jul 19, 2016 11:46 pm

Trying to use the radio module in MicroPython on my BBC Micro:Bit. There's example code, intended to create an effect similar to a swarm of fireflies by using multiple flashing Micro:Bits, at http://microbit-micropython.readthedocs ... radio.html.

Tried running, first, code derived from that example and, when that didn't work, tried running an exact copy of the example code. Each time I get an error message saying no module named radio was found.

The lines in the example code supposed to import any modules needed are:
import radio
import random
from microbit import display, Image, button_a, sleep

As these didn't work, I tried varying them to:

from microbit import radio, random, display, Image, button_a, sleep

and, when that didn't work, to

from microbit import *

No joy. I still haven't got to the bottom of the problem of the module not being found and haven't found an answer by Googling.

As may well be apparent, I'm new not only to the Micro:Bit but also to MicroPython.

Any helpful suggestions, please?

Incidentally, I found some material about radio on the micro:bit at https://lancaster-university.github.io/ ... bit/radio/ and that included a note saying it's not possible to run the MicroBitRadio component and Bluetooth Low Energy at the same time. To use the former, you have to disable the BLE stack. A method for doing this was shown in the context of working with C/C++, rather than MicroPython, by editing MicroBitConfig.h. I'm quite unsure whether this is relevant to the problem or whether it is a complete red herring.

User avatar
deshipu
Posts: 931
Joined: Thu May 28, 2015 5:54 pm

Re: BBC Micro:Bit MicroPython no module named radio

Postby deshipu » Wed Jul 20, 2016 12:49 pm

My guess is that you need the most recent version of micropython for this to work. It was just added a few days ago.

gkb14
Posts: 2
Joined: Tue Jul 19, 2016 11:11 pm

Re: BBC Micro:Bit MicroPython no module named radio

Postby gkb14 » Wed Jul 20, 2016 3:08 pm

Thanks very much for the suggestion.

I contacted the author of the code who indicated that I need to use mu, instead of the official BBC Micro:Bit coding tools, if I want to code / run code using the radio module.

http://codewith.mu/#download

I have done this and the author's firefly code now works for me.

===

Most readers of this forum may well be happy to stop reading at this point. People wanting to use mu.exe on Windows 10 might be interested in reading further.

I'm currently using Windows 10 and it has seemed to me rather unfriendly towards mu.exe. It could turn out that there is also some involvement of non-Microsoft security software.

I clicked on the download link and there was the usual animation to indicate a download but I couldn't find it in Downloads. I didn't find out where suspect files are quarantined, to see if the file had been put there. I got it to appear in Downloads by right-clicking and choosing "Save link as". I haven't verified that this (the file vanishes or goes into an unexpected folder) is what really - repeatedly - happens when one simply clicks, rather than right-clicks, on the download link for Windows systems but that's my current impression of what happened.

Then Windows 10 didn't want me to run mu.exe. "Windows SmartScreen prevented an unrecognized app from starting. Running this app might put your PC at risk." I overrode this (after checking the download with a Bitdefender security product). In fairness, there are, judging by Google search results, harmful, or at least potentially unwanted program, files with the same file name, e.g. at least one adware program, though I think most security programs are more sophisticated than simply relying on file names and do some kind of program "fingerprint" recognition. In fairness, maybe the file name didn't come into it. Maybe Windows SmartScreen just discourages you from using anything it hasn't seen before?

The following may reflect my lack of a thorough familiarity with Windows 10 but I found I couldn't get mu.exe on to my list of All apps (available from what used to be the Start icon) or on to my taskbar (a red circle, with a diagonal line across, indicated I could not drag and drop a shortcut to either of these locations) and I couldn't find mu.exe using "Search the web and Windows", in order to locate and run it that way. However, I have been able to create a desktop shortcut to mu.exe (located in Downloads). Thus the difficulties on Windows 10 are not insurmountable.

I note that mu is available for other operating systems and I acknowledge that, personally, I have the option, on my desktop PC, to boot into a choice of Linux distributions instead of Windows.

User avatar
deshipu
Posts: 931
Joined: Thu May 28, 2015 5:54 pm

Re: BBC Micro:Bit MicroPython no module named radio

Postby deshipu » Wed Jul 20, 2016 8:13 pm

A lot of 'security' software is unhappy about programs written in Python and bundled into an exe file, because Python is popular among both white and black hat security people. If I remember correctly, pyInstaller, one of the programs that produces executables from Python programs, was even listed among virus signatures...

User avatar
pythoncoder
Posts: 1382
Joined: Fri Jul 18, 2014 8:01 am

Re: BBC Micro:Bit MicroPython no module named radio

Postby pythoncoder » Thu Jul 21, 2016 6:57 am

@gkb14 As a general point makers and experimenters tend to use Linux; I suspect you're beginning to appreciate one of the reasons why! And much of the expertise and advice in forums such as this is based on Linux. A Linux virtual machine or a Raspberry Pi could be your friend here ;)
Peter Hinch

a1ig
Posts: 1
Joined: Wed Sep 28, 2016 4:07 am

Re: BBC Micro:Bit MicroPython no module named radio

Postby a1ig » Wed Sep 28, 2016 8:00 am

Has anyone got this code running on a Rasp pi - microbit? I downloaded MU onto Rasp Pi 3, tried the firefly code and got the same error as when using micropython one the microbit web interface... Radio module not found.....

I want to develop some interaction between Rasp Pi / Microbit for STEM education

User avatar
deshipu
Posts: 931
Joined: Thu May 28, 2015 5:54 pm

Re: BBC Micro:Bit MicroPython no module named radio

Postby deshipu » Wed Sep 28, 2016 11:45 am

You need mu from the codewith.mu website, not from the raspbian repositories.

xspamo
Posts: 1
Joined: Sun Jan 15, 2017 10:05 pm

Re: BBC Micro:Bit MicroPython no module named radio

Postby xspamo » Sun Jan 15, 2017 10:16 pm

[quote="deshipu"]You need mu from the codewith.mu website, not from the raspbian repositories.[/quote]

I am getting the same problem. I'm using a Raspberry Pi with MU installed. I installed MU with the following command in terminal:

sudo apt-get install mu

This works great with the Mcrobit but I wanted to use the Speech feature and the Radio feature after going through the tutorials at http://microbit-micropython.readthedocs ... /tutorials

Unfortunately I don't think they are implemented in the Raspberry Pi version on MU (please correct me if I'm wrong).

The code that can be obtained from the codewith.mu website is for x86 based computers using Linux, not ARM based computers like the Pi (again, please correct me if I'm wrong).

User avatar
deshipu
Posts: 931
Joined: Thu May 28, 2015 5:54 pm

Re: BBC Micro:Bit MicroPython no module named radio

Postby deshipu » Mon Jan 16, 2017 12:47 am

xspamo wrote:Unfortunately I don't think they are implemented in the Raspberry Pi version on MU (please correct me if I'm wrong).

The code that can be obtained from the codewith.mu website is for x86 based computers using Linux, not ARM based computers like the Pi (again, please correct me if I'm wrong).


You are wrong :-)

Or rather, you are right that the version of Mu included in the Raspbian repositories doesn't have those features yet, and that the binaries available for Linux on the codewith.mu page are for the x86 platform and will not work on the RaspberryPi. However, Mu is a program written in Python and as such doesn't have to be run from binaries -- you can run it from source easily. To do that, click on the "fork me at github" link in the upper right corner of the website, and once there, select the "clone or download" green button, and select "Download ZIP". Then simply unpack that archive anywhere on your computer, and run the "run.py" file. That should give you the newest and greatest version of Mu, without having to wait for the Raspbian developers to package it.

rcolistete
Posts: 85
Joined: Thu Dec 31, 2015 3:12 pm

Re: BBC Micro:Bit MicroPython no module named radio

Postby rcolistete » Mon Jan 16, 2017 3:13 pm

Why not look at the source code page (GitHub) ?
https://github.com/mu-editor/mu
Which points to the the latest builds :
http://ardublockly-builds.s3-website-us-west-2.amazonaws.com/?prefix=microbit
Including Raspberry Pi (ARM) releases :
http://ardublockly-builds.s3-website-us-west-2.amazonaws.com/?prefix=microbit/raspberry_pi/
As last version is from 31/12/2016, it contains 'MicroPython v1.7-9-gbe020eb on 2016-04-18' firmware (lasted official one).


Return to “The micro:bit”

Who is online

Users browsing this forum: No registered users and 1 guest