microbit as ultibo peripheral

General discussion about anything related to Ultibo.
mark
Posts: 1242
Joined: Mon Oct 03, 2016 2:12 am
Location: Indianapolis, US

microbit as ultibo peripheral

Postby mark » Tue Sep 11, 2018 5:39 am

1. Please post a note if you have a microbit or are interested in getting one to use with ultibo.

2. https://github.com/markfirmware/prototy ... 09.11.0130

I will add $25 to my ultibo forum sponsorship in honor of the first person who tries this. You need a microbit and an rpi3b or 3b+ or zerow.

Button presses are broadcast without any feedback (open loop) and can be lost. I put a button event history in each packet as an error correction code so that ultibo can correct lost broadcasts. The history is implemented in the packet, I haven't yet implemented the ultibo error correction.

I'd like to make sure that at least one other person can work with the microbit before I go further.

Thanks,
Mark
Ultibo - The Internet of Things that Just Work
pjde
Posts: 410
Joined: Tue Feb 09, 2016 6:21 am
Location: Sydney, Australia

Re: microbit as ultibo peripheral

Postby pjde » Tue Sep 11, 2018 7:50 am

Hi Mark

Downloaded the compiled version and copied to SD Card.
Copied the HEX file to the Microbit

Pressed the buttons and saw the events on the Ultibo screen.

You do have to press the buttons slowly as if you press them too quickly, you only receive the Release.

Well Done.

Regards

Paul
mark
Posts: 1242
Joined: Mon Oct 03, 2016 2:12 am
Location: Indianapolis, US

Re: microbit as ultibo peripheral

Postby mark » Tue Sep 11, 2018 8:16 am

pjde wrote:Hi Mark

Downloaded the compiled version and copied to SD Card.
Copied the HEX file to the Microbit

Pressed the buttons and saw the events on the Ultibo screen.

You do have to press the buttons slowly as if you press them too quickly, you only receive the Release.

Well Done.

Regards

Paul
Super. The next version will include timing info in the packet (time between button events) and of course use the history to prevent event loss. Mark.
Ultibo - The Internet of Things that Just Work
Gavinmc42
Posts: 1399
Joined: Sun Jun 05, 2016 12:38 pm
Location: Brisbane, Australia

Re: microbit as ultibo peripheral

Postby Gavinmc42 » Tue Sep 11, 2018 10:47 am

Yippee, it works even on old Pi 3B.

Yep, need to hold the button down until the message is sent otherwise only the release message shows on console.
The event count is correct though, down is odd number, release is even.
Both buttons is another event ;)

You got this working quick, well done.
Makes Pi's gateways now for BLE stuff.

Add buttons to a Pi Zero W to make it the Microbit?
Going to have get some more Microbits and some of those nRF51822 tiny PCBs.

Hey, BLE DCC train controllers?
Tiny bots?
mark
Posts: 1242
Joined: Mon Oct 03, 2016 2:12 am
Location: Indianapolis, US

Re: microbit as ultibo peripheral

Postby mark » Wed Sep 12, 2018 7:59 am

https://github.com/markfirmware/prototy ... 09.12.0337

Ok, I didn't yet add the time duration for the events, but I did use the history in the packet to prevent event loss. I went back to the store and bought the other two microbits that were on the shelf. The ultibo program processes multiple microbit peripherals now. I can't get a lost event using my two thumbs. I'll add a power-on-test mode to the microbit to do stress transmits to see if that can invalidate the proof of concept.

No events are lost but there is some propagation delay. That needs to be measured. There are timing parameters to be tuned in the microbit advertising and the ultibo scanning. More parameters are: how busy is the ble spectrum, how many microbits, how many ultibos.

The log file is the only output. I'll break a unit out of the lpr to provide an event stream and then we can implement something with graphics.

FYI fpc can be used to program the microbit, although I won't be doing it myself any time soon. http://wiki.freepascal.org/micro:bit

The microbit can advertise (used here to broadcast button state) and can accept connections. I have yet to confirm that it can scan for other ble devices and/or initiate a connection to them. However, accepting connections permits a hub to connect for more secure, structured, reliable, and efficient communication versus broadcasting.

With some usb driver support, ultibo should be able to flash over usb new hex files to the microbit. Over the air update might also be possible. The microbit presents a serial/usb interface which might be helpful later.

So what manual input options are there?
  • two buttons
  • 3 touch buttons
  • coarsely-grained tilt left/right/up/down/none can be a 5 state shift key
  • shake
  • compass (manual rotation)
  • thumb over thermometer to increase measured temparature?
  • thumb over the led array to modulate the ambient light measurement?

The more input used, the more clever the encoding that is needed to fit the data into the packet, in a lossless over broadcast way.

For a game or such, finely-grained tilting might be the ticket.

Mark
Ultibo - The Internet of Things that Just Work
Gavinmc42
Posts: 1399
Joined: Sun Jun 05, 2016 12:38 pm
Location: Brisbane, Australia

Re: microbit as ultibo peripheral

Postby Gavinmc42 » Wed Sep 12, 2018 10:35 am

That's working better.

Nice find for Microbit/FPC.
The next genchip nRF52832 has much more memory, should make FPC on it even more useful.

Microbit as RC controller for Zero W combat bot?
Wireless game controller, same code?

Hey just remembered, my old walking bot project needed an accelerometer.
Need more Microbits.
Gavinmc42
Posts: 1399
Joined: Sun Jun 05, 2016 12:38 pm
Location: Brisbane, Australia

Re: microbit as ultibo peripheral

Postby Gavinmc42 » Wed Sep 12, 2018 11:32 am

Low cost SWD programmer for those BLE pcbs and other ARM chips?
https://www.tindie.com/products/Electro ... -debugger/
User avatar
Ultibo
Site Admin
Posts: 2040
Joined: Sat Dec 19, 2015 3:49 am
Location: Australia

Re: microbit as ultibo peripheral

Postby Ultibo » Wed Sep 12, 2018 11:06 pm

Nice work Mark.

mark wrote:With some usb driver support, ultibo should be able to flash over usb new hex files to the microbit. Over the air update might also be possible. The microbit presents a serial/usb interface which might be helpful later.

From the Schematics page on the microbit website it indicates that the device implements a Mass Storage Class interface (ie a USB drive) which is already fully supported by the Ultibo drivers, it also says that the serial port is presented as a CDC device which also has a supported Ultibo driver.

Based on that there is a good chance that all of the necessary USB support is already available, anyone like to plug the USB into an Ultibo project and see what is reported?
Ultibo.org | Make something amazing
https://ultibo.org
Gavinmc42
Posts: 1399
Joined: Sun Jun 05, 2016 12:38 pm
Location: Brisbane, Australia

Re: microbit as ultibo peripheral

Postby Gavinmc42 » Thu Sep 13, 2018 1:47 am

Duh! must be getting old, that's how how you update the Microbit's code, just drop the file onto the MSD.
Pi B+'s can handle 4 Microbits via USB :D
Thanks Garry.

Hmm interesting to try Zero's, may need to grab some USB connectors and make some tiny cables.
Microbit's can do SPI, USB LCD drivers? Wish they had a less silly IO connector.
mark
Posts: 1242
Joined: Mon Oct 03, 2016 2:12 am
Location: Indianapolis, US

Re: microbit as ultibo peripheral

Postby mark » Thu Sep 13, 2018 3:26 am

Ultibo wrote:Nice work Mark.

Thanks.
Ultibo wrote:Based on that there is a good chance that all of the necessary USB support is already available, anyone like to plug the USB into an Ultibo project and see what is reported?
USB 2.0 full speed DAPLink CMSIS-DAP vid 0D28 pid 0204

This is an embedded on-device monitor for development.

See https://github.com/ARMmbed/DAPLink - I only glimpsed the readme but it is a composite usb interface. Mark.
Ultibo - The Internet of Things that Just Work

Return to “Discussion”

Who is online

Users browsing this forum: No registered users and 1 guest