Wireless communication and libaries

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
umassstudent
Posts: 1
Joined: Wed Nov 04, 2015 6:31 pm

Wireless communication and libaries

Post by umassstudent » Wed Nov 04, 2015 6:33 pm

I am a student at Umass Dartmouth working on a project that has to deal with measuring the distance between a speaker and microphone. This process will be done with acoustics and your microcontroller. I would like to be able to send and receive the data wirelessly, not wifi, between multiple pyboards(point to multipoint).

What wireless modules do you recommend to work with your microcontroller?

Also, does it support libraries such as numpy and scypy? If not can you recommend any libraries that perform the functionality of those listed above? We are trying to utilize those libraries to do signal processing.

blmorris
Posts: 348
Joined: Fri May 02, 2014 3:43 pm
Location: Massachusetts, USA

Re: Wireless communication and libaries

Post by blmorris » Wed Nov 04, 2015 7:26 pm

The nRF24L01+ has a supported driver written in pure Python, which can be used to establish a point-to-point serial link. Not sure if it supports point to multipoint, though.

You won't be able to run numpy or scipy directly on the pyboard, these are relatively large libraries that require more memory than the STM32F405 has available. That said, it is possible to roll your own signal processing routines, and the processor should have enough power to do some interesting things. @pythoncoder is a frequent contributor here, and has written a set of FFT routines in combined uPy and assembler, available here: https://github.com/peterhinch/micropython-fourier

Even if this isn't what you need, it is a good example of what is possible.

How are you planning to read / playback audio remotely? DAC/ADC or audio codec? Note that I2S is not supported in the main branch yet, but I am working on an I2S driver and looking for users / testers - some posts on the topic are already written up here, just search the forum for I2S.

-Bryan

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: Wireless communication and libaries

Post by pythoncoder » Thu Nov 05, 2015 8:53 am

The nrf24l01+ is very flexible and is capable of reliable transmission with automatic CRC checking and retrying, so the source can detect whether the transmission was successfully received. I've only used it on point to point links, but it's a highly capable chip and I believe it can be used in mesh networks to enable data to be propagated to multiple receivers. Alternatively one source can transmit to multiple destinations sequentially - a message is tagged with a pipeline code for the intended destination and will be ignored by others. I don't know about broadcasting simultaneously to multiple destinations: the reception of acknowledgements from multiple destinations might be problematic, but it may be possible to get each destination to send its acknowledgement to a different source pipe. But these are guesses based on having studied the datasheet some time ago...

As for signal processing the question is whether this needs to be done in real time. If so, you may need to consider using the inline assembler to achieve sufficient performance. I have posted code here https://github.com/peterhinch/micropython-filters for FIR filters capable of handling realtime audio frequency data: if you're doing realtime correlation you might consider using/adapting this.

For non-realtime DSP Python is your friend but as @blmorris says the big libraries simply won't fit on a microcontroller.

[edit]
On second thoughts having each destination acknowledge to a different source pipe would surely fail as they'd all simultaneously acknowledge on the same RF channel.
Peter Hinch
Index to my micropython libraries.

Post Reply