BBC micro:bit plugin - wiki and discussion

207 views
Skip to first unread message

madlyR

unread,
Oct 25, 2016, 3:35:24 AM10/25/16
to DroidScript
Hi all,

I created in DS Wiki a new page under Plugins with BBC micro:bit documentation.

Some info is pasted from plugin docs, some are my diggings. It's on very early phase. I plan to add full documentation as a part o volunteer support to say thank for great environment. Please feel free to correct my horrible English, still I hope that it's still better than nothing ;-).

Probably there will be a lot of questions, so Dave and Steve be warned and prepared ;-). 

I don't have rights to upload files to Wiki - is it possible to add me (user madlyr) privileges to upload files?
May I suggest to add tag micro:bit or MicroBit?

Best regards,
Radek / madlyr

Steve Garman

unread,
Oct 25, 2016, 5:07:33 AM10/25/16
to DroidScript
Radek,

I will email you about this once I have checked one or two things.

Eric Geer

unread,
Dec 24, 2016, 12:34:30 AM12/24/16
to DroidScript
Installed espruino firmware on the microbit and setup microbit.Connect(); with my MAC address for the micro bit, but it is not communicating. I'm not seeing any errors either. I tried all the samples from the doc, and no luck. Flashed back to normal firmware, re-paired it to the android, then re-flashed espruino_1v89_microbit.hex, but same results. Not sure what the issue could be. If I pair it to the droid with standard flash, I can upload code to it just fine, but won't work with the DroidScript plugin. Is this an issue running the beta version of DroidScript?

Steve Garman

unread,
Dec 24, 2016, 1:50:36 AM12/24/16
to DroidScript
Eric,
I think this is an issue you have had before.

In order to use the Espruino firmware, the android device must NOT be paired with the micro:bit.

If you have already paired it, you need to go into the android device bluetooth settings and forget it.

Steve Garman

unread,
Dec 24, 2016, 3:08:48 AM12/24/16
to DroidScript
I have added a rudimentary troubleshooting guide to the wiki http://wiki.droidscript.me.uk/doku.php?id=microbit:troubleshooting

Please feel free to improve it.

Eric Geer

unread,
Dec 27, 2016, 10:52:20 PM12/27/16
to DroidScript
Hi Steve,

I made sure to unpair it.  Tried two different Micro:Bit now, with older firmwares as well as two different android devices running droidscript.  It doesn't seem to work at all.  I think it's likely an issue with the beta version of droidscript.

Steve Garman

unread,
Dec 28, 2016, 11:16:30 AM12/28/16
to DroidScript
Eric,
I'm not quite clear what beta you are referring to. As far as I am aware, there is currently no beta running.
The latest version of DroidScript is the version on the playstore and if that is not what you are using, you should download it.

The code below works for me with the Espruino version linked from
microbit-js.org

Does it work for you?

app.LoadPlugin( "MicroBit" );

function OnStart()
{
lay = app.CreateLayout( "Linear", "VCenter,FillXY" );
btn = app.CreateButton( "Smile" );
btn.SetOnTouch( btn_OnTouch );
lay.AddChild( btn );
app.AddLayout( lay );

microbit = app.CreateMicroBit();
microbit.Scan();
}

function btn_OnTouch()
{
microbit.Reset();
setTimeout(smile,500);
}
function smile()
{

microbit.SetLEDs( "0111010001001000010010001" );
}

Gloglas´s Studio

unread,
Dec 28, 2016, 2:23:03 PM12/28/16
to DroidScript
For me it is working fine. I had same issue when i tried it but i have it paired. So i unpaired it and i had another issue. Sometimes you must send microbit.Reset(); and microbit.Clear();( and then if you want microbit.SendCode(...); or something else) because if i sent program to running program it run 2 scripts/program at once. And sometimes i must also replug the power. But i think that most of these things you tried..

Eric Geer

unread,
Dec 30, 2016, 4:22:50 PM12/30/16
to DroidScript
On my results, I connect after the scan, then click smile and my debug output shows it try's to initiate the send and then a few seconds later it says disconnected. Nothing shows up on the micro bit.

Dave Smart

unread,
Dec 31, 2016, 2:42:52 PM12/31/16
to DroidScript
Is it paired with more than one device perhaps?

Which version of the .hex file are you using (where did you get it from)?

Are you using the latest version of the microbit DS plugin (the one with the Read digital input example)?

Eric Geer

unread,
Dec 31, 2016, 6:12:12 PM12/31/16
to DroidScript
Everything is unpaired. I know it's connecting, just not receiving any code, then eventually disconnects.

Tried both espruino_1v89_microbit.hex and espruino_1v85_microbit.hex on both micro bit units.

Re-installed the micro bit plugin.

Eric Geer

unread,
Jan 9, 2017, 4:32:00 PM1/9/17
to DroidScript
Hi Folks,

Still having issues.  Not sure where to take it from here.  Let me know if you have any ideas.

Cheers,

Dave Smart

unread,
Jan 10, 2017, 12:46:48 PM1/10/17
to DroidScript
I suggest you try to connect with the Espruino IDE and see if that is working for you.  You might need a laptop with webbluetooth, or you might be able to use a tablet to run the Espruino IDE from the espruino web site.

madlyR

unread,
Jan 10, 2017, 1:21:29 PM1/10/17
to DroidScript
Dave, I have the same problems.

Micro:bit disconnects after few seconds from Espruino IDE. I could play with Espruino, but not with DroidScript. Maybe we have another batch of micro:bit? My was from kitronik.co.uk with the Kitronik Inventor's Kit for the BBC micro:bit .

I tried some programs in Espruino and I found, that the more recent Espruino, then there is less free memory. Below is memory info shortened from

process.memory()

on fresh Espruino firmware.
Version 1v85.138 is from microbit-js.org  


1v85 = { "free": 330, "usage": 20, "total": 350 }
1v85.138 = { "free": 330, "usage": 20, "total": 350 }
1v86 = { "free": 290, "usage": 20, "total": 310 }
1v87 = { "free": 290, "usage": 20, "total": 310 }
1v88 = { "free": 79, "usage": 21, "total": 100 }

Maybe this is the reason, why there are problems with DS?

On Espruino IDE, even on 1v85 programs with more code doesn't work. The simply are out of memory. Below is simple program which uses 3 external switches (motor speed up / down with 3 speeds and off state, LED blink on/off), one DC motor controlled via PWM and one LED. This program runs out of memory on 1v85.

var debugMode = true;

var motorSpeed = 0;
var motorScale = 0.175;
var motorPWMoffset = 0.3;
var motorPWMFreq = 1500;

var portLamp = D1;
var portMotor = D0;
var portBtnMotorDown = D8;
var portBtnMotorUp = D12;
var portBtnLamp = D16;
var isLampBlinking = false;

var lampIntervalOn, lampIntervalOff = 0;
var watchMotorDown, watchMotorUp, watchLamp = 0;

function debug( txt ) {
  if (debugMode) console.log( txt );
}

function onMotorUp(e) {
  debug("onMotorUp");
  if (motorSpeed < 4) {
    motorSpeed++;
    debug(motorSpeed);
    var realSpeed = motorPWMoffset + motorSpeed * motorScale;
    if (realSpeed > 1) realSpeed = 1;
    analogWrite(portMotor, realSpeed, {freq: motorPWMFreq});
  }
}

function onMotorDown(e) {
  debug("onMotorDown");
  if (motorSpeed > 0) {
    motorSpeed--;
    debug(motorSpeed);
    var realSpeed = motorPWMoffset + motorSpeed * motorScale;
    if (motorSpeed === 0) realSpeed = 0;
    analogWrite(portMotor, realSpeed, {freq: motorPWMFreq});
  }
}

function lampBlink(enable) {
  debug("lampBlink: "+enable);
  if (enable) {
    if (lampIntervalOn) clearInterval(lampIntervalOn);
    if (lampIntervalOff) clearInterval(lampIntervalOff);
    digitalWrite(portLamp, 0);
    lampIntervalOn = setInterval("digitalWrite(portLamp, 1);", 1000);
    lampIntervalOff = setInterval("digitalWrite(portLamp, 0);", 2000);
  } else {
    if (lampIntervalOn) clearInterval(lampIntervalOn);
    if (lampIntervalOff) clearInterval(lampIntervalOff);
    lampIntervalOn = lampIntervalOff = 0;
    digitalWrite(portLamp, 0);
  }
  isLampBlinking = !isLampBlinking;
}

function onLamp(e) {
  debug("onLamp");
  lampBlink(!isLampBlinking);
}

function onInit() {
  debug("onInit");
  var btnOptions = { repeat:true, edge:'rising', debounce:20 };

  pinMode(portBtnMotorDown, 'input_pulldown');
  pinMode(portBtnMotorUp, 'input_pulldown');
  pinMode(portBtnLamp, 'input_pulldown');

  watchMotorDown = setWatch(onMotorDown, portBtnMotorDown, btnOptions);
  watchMotorUp = setWatch(onMotorUp, portBtnMotorUp, btnOptions);

  watchLamp = setWatch(onLamp, portBtnLamp, btnOptions);
}

onInit();


Memory issues?

Cheers, 
Radek

Eric Geer

unread,
Jan 12, 2017, 6:05:49 PM1/12/17
to DroidScript
I'd like to keep pecking at this if we can.  Out of two Micro:bit units I've tested, I'm surprised none can communicate with DroidScript, even on the older more stable 1.85.  This is the final step I need to have full vehicle integration with DroidScript to control other physical wiring functions that my serial interface doesn't.

Dave Smart

unread,
Jan 14, 2017, 9:54:38 AM1/14/17
to DroidScript
OK, I think this might be an Android version issue.  My Galaxy S4 works but my new Asus Zenpad (Android 6) is disconnecting... will investigate.

Dave Smart

unread,
Jan 14, 2017, 11:28:44 AM1/14/17
to DroidScript
After much investigation.... what solved it for me was just rebooting my Android 6 tablet.   I've read that BT resources can get maxed out on some devices.

Have you guys tried rebooting?

Eric Geer

unread,
Jan 31, 2017, 5:19:59 PM1/31/17
to DroidScript
Hi Dave,

Thanks for the info.  I shut down my Samsung tablet nightly, because, no thanks to Samsung, it ONLY charges on the Samsung wall wart it came with, and NO other device unless completely powered off.  What I haven't tried though is to attempt to connect to it immediately following a reboot.  I'll give it a try later today.  Anyway, that said, I'm hoping this to be more stable as I intend to use it in automotive platforms for unlocking the car.  It would not be good if I got stuck outside the car and needed to reboot the android inside.

Dave Smart

unread,
Feb 1, 2017, 7:40:06 AM2/1/17
to DroidScript
Hi Eric,

If you continue to have unexplained difficulties, you might want to consider switching to Puck.js instead.

Eric Geer

unread,
Feb 1, 2017, 11:05:36 PM2/1/17
to DroidScript
Ok, so I see Puck.js works with Espruino firmware, but the scan can't see the microbit. The micro bit plugin can see it and connect, but never gets a command, even after reboot of the tablet.

Steve Garman

unread,
Feb 2, 2017, 4:15:20 AM2/2/17
to DroidScript
I suspect Dave was recommending a change of hardware, rather than just a change of plugin.

JustAnotherDude

unread,
Feb 3, 2017, 6:45:52 AM2/3/17
to DroidScript
If I develope a software then I care synonymous for that which works and does not ask the customers to change to the hardware

(Google Translator FTW xD)

Eric Geer

unread,
Feb 9, 2017, 1:30:51 AM2/9/17
to DroidScript
I'm actually surprised how much more the puck costs, considering the micro:bit does more for $20. I would really like to get the plugin for the micro:bit working though. Seems puck.js works with espruino, but I couldn't get it to connect.
Reply all
Reply to author
Forward
0 new messages