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

M.-A. Lemburg mal at egenix.com
Mon Nov 21 04:18:00 EST 2016


On 20.11.2016 17:30, Radomir Dopieralski wrote:
> It may be still a little problematic, because MicroPython on the ESP8266
> doesn't have an implementation of I2C slave (and neither does
> Micro:bit).

This was the main reason I didn't continue trying to solder
on two cables to the pins (I was surprised that soldering did
work well on those pins).

Tom, who was working with me at the sprint, found the documentation
saying that I2C is only implemented in master mode, so I didn't want
to mess with the MB only to find out that things aren't working.

We then turned to SPI where the cabling looked more promising...

> On Sun, 20 Nov 2016 16:05:39 +0000
> Mark Shannon <mark at hotpy.org> wrote:
> 
>> Hi,
>>
>> If you use the latest firmware, you can use any of the pins for I2C.
>> Hope that helps.

Thanks, Mark. We did use the latest firmware, but I guess the
documentation hasn't been updated yet, since we couldn't find
any API to adjust the pin selection:

http://microbit-micropython.readthedocs.io/en/latest/i2c.html

The PR Carlos mentioned points to a new init() function for this:

https://github.com/bbcmicrobit/micropython/pull/377
https://github.com/bbcmicrobit/micropython/commit/e88e3b2f6c579eab0eafda02242092bff51f6934

>> Cheers,
>> Mark.
>>
>> On 20/11/16 15:04, M.-A. Lemburg wrote:
>>> 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,
>>>  
>> _______________________________________________
>> Microbit mailing list
>> Microbit at python.org
>> https://mail.python.org/mailman/listinfo/microbit
> 
> 

-- 
Marc-Andre Lemburg
eGenix.com

Professional Python Services directly from the Experts (#1, Nov 21 2016)
>>> Python Projects, Coaching and Consulting ...  http://www.egenix.com/
>>> Python Database Interfaces ...           http://products.egenix.com/
>>> Plone/Zope Database Interfaces ...           http://zope.egenix.com/
________________________________________________________________________

::: We implement business ideas - efficiently in both time and costs :::

   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/
                      http://www.malemburg.com/



More information about the Microbit mailing list