[Microbit-Python] SPI APIs on BBC micro:bit and ESP8266

David Whale david at thinkingbinaries.com
Sun Nov 20 13:20:58 EST 2016


Ian Stephenson (aka @sniffCode on twitter) had the SPI working with an
SDCard really reliably, back in May:

http://www.sniff.org.uk/2016/05/spi-explained-connecting-sd-cards-to.html

Might be worth comparing notes with him. Sniff uses the standard mbed SPI
driver, same as the micro:bit does.

Also double check your SPOL and SPHA settings to make sure they are
compatible with the receiving end.

https://en.wikipedia.org/wiki/Serial_Peripheral_Interface_Bus#Clock_polarity_and_phase

David



___________________________________________________________
David Whale, B.Sc (Hons), MIET
*Software Engineer and IET Schools Liaison Officer, Essex*


On 20 November 2016 at 17:06, Nevil Hunt <nevil.hunt at hotmail.co.uk> wrote:

>  Marc-Andre,
>
>
> As regards...
>
>
> * the connection is rather unreliable: we had lots of data loss or
>   data corruption, with bytes not being transmitted or with lost bits
>   - we tried several different baud rates without success
>
> I'd certainly be interested if you can find out why.
>
> I hooked a micro:bit up to a SPI RAM about a month ago and was able to
> write then read back from it, however it was a bit unreliable as sometimes
> the 'Reads' returned corrupted data.
>
> From my recollection it looked like it was the 'Write' that was getting
> corrupted as repeated 'Reads' always returned the same corrupted data.
>
> I used the 'Bus Pirate' to try and debug it but I wasn't able to determine
> whether it was a h/w or s/w problem...then I ran out of time and haven't
> returned to it!
>
> I have however been in touch with Paul from Microsoft who has a micro:bit
> talking to an SD Card with s/w written in 'C' so it looks like the
> micro:bit SPI interface can be made to work!
>
>
> Cheers,
>
>
> Nevil
>
> ------------------------------
> *From:* Microbit <microbit-bounces+nevil.hunt=hotmail.co.uk at python.org>
> on behalf of M.-A. Lemburg <mal at egenix.com>
> *Sent:* 20 November 2016 15:04
> *To:* For Pythonic MicroBit related discussions
> *Subject:* [Microbit-Python] SPI APIs on BBC micro:bit and ESP8266
>
> Hello,
>
> over the weekend, we tried to get a connection from a BBC Microbit
> to an ESP8266, both running the latest MicroPython for the resp.
> platform, established via SPI.
>
> We found several problems with this:
>
> * the SPI APIs on the ESP8266 are all non-blocking and return
>   whatever is currently in the buffer (using 0x00 for missing data
>   and 0xff in case no connection is available)
>
> * the SPI APIs on the Microbit are all blocking, only returning
>   if all data is sent / received
>
> * the connection is rather unreliable: we had lots of data loss or
>   data corruption, with bytes not being transmitted or with lost bits
>   - we tried several different baud rates without success
>
> On the plus side, we did get SPI to work fine between two Microbits,
> but that's not really what we were after, since we wanted to get
> one of the Microbits in our mesh network connected to a WLAN and
> work as gateway.
>
> The blocking nature of the MB APIs make it difficult to write
> interfaces which aim at being fault tolerant and work as
> gateways. Having non-blocking versions would be better for this
> sort of application.
>
> Are there better ways to connect MBs and ESP8266 ?
>
> We also tried I2C, but gave up, since the pins on the MB for
> accessing I2C were too tiny to connect to without a breakout
> board.
>
> BTW: We were impressed by the new radio module. Getting MBs
> to connect using these low level radios is really easy.
>
> Cheers,
> --
> Marc-Andre Lemburg
> eGenix.com
>
> Professional Python Services directly from the Experts
> >>> Python Projects, Coaching and Consulting ...  http://www.egenix.com/
>
> eGenix.com - Professional Python Software, Skills and Services
> <http://www.egenix.com/>
> www.egenix.com
> eGenix™ is your leading partner for Python and database focused custom
> projects, services, coaching, consulting and products. We implement
> business ideas ...
>
>
>
> >>> Python Database Interfaces ...           http://products.egenix.com/
>
> eGenix.com Products <http://products.egenix.com/>
> products.egenix.com
> eGenix.com offers a large portfolio of products for Python and
> Python-based applications, many of them focusing on database connectivity.
>
>
>
> >>> Plone/Zope Database Interfaces ...           http://zope.egenix.com/
>
> eGenix.com: eGenix.com Plone & Zope Products <http://zope.egenix.com/>
> zope.egenix.com
> Plone/Zope Database Connectivity. eGenix.com has been actively working in
> the field of Python database connectivity for more than 15 years. Using our
> Zope and Plone ...
>
>
>
> ________________________________________________________________________
>
> ::::: Try our mxODBC.Connect Python Database Interface for free ! ::::::
>
>    eGenix.com Software, Skills and Services GmbH  Pastor-Loeh-Str.48
>     D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
>            Registered at Amtsgericht Duesseldorf: HRB 46611
>                http://www.egenix.com/company/contact/
>
> eGenix.com: Company: Contact <http://www.egenix.com/company/contact/>
> www.egenix.com
> We provide various ways of contacting eGenix.com depending on what area of
> interest you have. EMail. General Questions: info at egenix.com Support:
> support at egenix.com
>
>
>
> _______________________________________________
> Microbit mailing list
> Microbit at python.org
> https://mail.python.org/mailman/listinfo/microbit
>
> Microbit Info Page - Python
> <https://mail.python.org/mailman/listinfo/microbit>
> mail.python.org
> The MicroBit is a small programmable device for children created by the
> BBC (in partnership with various other organisations, such as the PSF).
>
>
>
>
> _______________________________________________
> Microbit mailing list
> Microbit at python.org
> https://mail.python.org/mailman/listinfo/microbit
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/microbit/attachments/20161120/2837ee73/attachment-0001.html>


More information about the Microbit mailing list