Page 1 of 1

Looking for suggestions for a cheaper microcontroller - compatible with basic code used on a microbit powered prototype.

Posted: Mon Oct 07, 2019 4:09 pm
by PixelShady
Hi,

This is all hypothetical . . .

Am planning to home-manufacture a small batch of 20 moving statues, all identical, and with the same basic lighting/movement.

Am looking for suggestions for a cheaper microcontroller - (will need to buy 20 of them) - that will be compatible with the micropython-microbit code already written for the prototype.

Please note that the statue is not interactive in any way, and does not need to use any sensors or buttons. It won't need bluetooth either. Let's say, it only needs to control a single strip of 5 neopixels and two servo motors. Turn it on and it just repeats the same lighting/movement until it is turned off.

Re: Looking for suggestions for a cheaper microcontroller - compatible with basic code used on a microbit powered protot

Posted: Mon Oct 07, 2019 8:46 pm
by OutoftheBOTS_
ESP8266 is the cheapest your going to get and will easily be able to do the job you need. I haven't used micro bit so not sure if the code may need a small change or if it will just plug and play.

https://www.aliexpress.com/wholesale?ca ... _new_app=y

Re: Looking for suggestions for a cheaper microcontroller - compatible with basic code used on a microbit powered protot

Posted: Mon Oct 07, 2019 10:59 pm
by jimmo
Unfortunately the microbit-micropython API is a bit different to anything else. The core MicroPython parts are the same (micropython, gc, sys, etc), but there's no machine module. (The micro:bit port predates the machine module in upstream micropython). (Ok, that's not entirely true, there's a machine module but it's only got a few specialised newer functions). All the hardware access is in the microbit module.

If you want your micro:bit code to run directly, then the best thing to do is to actually use a microbit -- i.e. use the same NRF51822 processor that's in the micro:bit. Here's an example breakout board -- https://www.adafruit.com/product/4076 . Something like this would probably have been perfect if still available -- https://www.tindie.com/products/onehors ... ent-board/ . I did this in a project a few years ago with some students who were familiar with micro:bit and found some little castellated modules on aliexpress for a few dollars each. Note that unless they have a USB daplink interface, you'll have to program them using other tools (SWD / JTAG), but at least your hex files will just work.

Alternatively it would be fairly straightforward to provide a wrapper library in Python that provided all the microbit functionality (Pin, SPI, etc) based on the machine module from any other MicroPython board. (This might be a lot easier!!)

Re: Looking for suggestions for a cheaper microcontroller - compatible with basic code used on a microbit powered protot

Posted: Tue Oct 08, 2019 6:13 am
by OutoftheBOTS_
jimmo wrote:
Mon Oct 07, 2019 10:59 pm
If you want your micro:bit code to run directly, then the best thing to do is to actually use a microbit -- i.e. use the same NRF51822 processor that's in the micro:bit.
Would something like this do the job?

https://www.aliexpress.com/item/3279841 ... b201603_53

and what sort of device is needed to program it? Would this do the job https://www.aliexpress.com/item/3304094 ... b201603_53

and after programmed does it need a external UART to USB converter to access REPL??

Re: Looking for suggestions for a cheaper microcontroller - compatible with basic code used on a microbit powered protot

Posted: Tue Oct 08, 2019 6:57 am
by jimmo
OutoftheBOTS_ wrote:
Tue Oct 08, 2019 6:13 am
Would something like this do the job?

https://www.aliexpress.com/item/3279841 ... b201603_53
Yep, that's pretty similar to what I used.

I can't tell from the product listing that it's definitely the QFAA variant (same as the micro:bit), but it says 16kiB / 256kiB so it likely is.
OutoftheBOTS_ wrote:
Tue Oct 08, 2019 6:13 am
and what sort of device is needed to program it? Would this do the job https://www.aliexpress.com/item/3304094 ... b201603_53
Maybe... It's hard to tell what that is actually compatible with. Is it saying it's a Segger J-Link clone?

I used a Black Magic Probe. But any NRF-compatible SWD programmer would work. I _think_ you can even use an st-link. (I've definitely used an st-link with an NRF52 with openocd).
OutoftheBOTS_ wrote:
Tue Oct 08, 2019 6:13 am
and after programmed does it need a external UART to USB converter to access REPL??
Yes.

The main thing is figuring out all the pin numbering (i.e. which pins the UART is on, and how to map the micro:bit's pin0 etc), but the last page of https://github.com/bbcmicrobit/hardware ... _V1.3B.pdf is quite useful for that.