Mathematica and the Wolfram Language on Raspberry Pi

Have you been staring at the Mathematica and Wolfram Language icons on your Raspbian install, and wondering where to get started? We’ll be featuring several guest posts from Wolfram Research in the coming weeks, so you can start to get to work with them. This first, introductory post is from Arnoud Buzing. Arnoud and the Wolfram team would welcome your feedback in the comments below; so would we. Let us know what you’d like to do with Mathematica and the Wolfram Language – it’ll help shape future posts from Wolfram.

A few weeks ago, on November 21st, we released the Wolfram Language and Mathematica for the Raspberry Pi. Just this past week, it’s become even easier to get the software since The Raspberry Pi Foundation began bundling Mathematica and the Wolfram Language directly with their standard NOOBS package and Raspbian operating system.

The responses to this pilot release have been overwhelmingly positive. It has been great to read tweets from educators, scientists, hobbyists and students all around the world, who are excited about using the Wolfram Language to explore the computational universe on their devices.

Today, Wolfram Research is perhaps most widely known for its computational knowledge engine called Wolfram|Alpha: for many students a website which makes short order of complicated homework problems by providing step-by- step solutions. But to create this website a great many problems had to be solved in a very general and systematic way. It only made sense then to build Wolfram|Alpha in the Wolfram Language.

This language differs from other computer languages in that it is very high level with built-in support for solving a very wide variety of computational problems. For over 25 years this language has grown from being able to compute with simple symbolic expressions to the computational knowledge engine it is today. And this feature of making knowledge computable, as well as its powerful ability to create complex programs with very little code, makes it a great language to run on a Raspberry Pi. It also interfaces extremely well with the ‘outside world’ thanks to its large array of supported data collecting sensors and its GPIO. A few great user examples have already been shared on the Wolfram Community website and I would like to share them here with you.

A recent post from Diego shows how to cook your steak using your Raspberry Pi. In this post he writes a small mathlink wrapper to read thermocouple measurements, which he calibrated by using a LinearModelFit on three data points. All this is then hooked up to a controller which turns a crockpot on or off using DeviceWrite["GPIO",17->1] and DeviceWrite["GPIO",17->0].

Another post from Diego shows how you can connect a Wii Nunchuck via an Arduino Uno to Mathematica over a serial connection. First he opens a serial connection using serial=DeviceOpen["Serial", {"/dev/ttyACM0", "BaudRate"->57600}] and then he interfaces with the sketch running on his Arduino by sending a ping over that serial link and reading back the current Wii Nunchuck state using DeviceReadBuffer[serial].

Bob posted a cool example showing how you can write a simple stepper motor controller using the Wolfram Language. He defines a stepMotor function which takes three arguments: the number of steps, the direction and the step time delay.

There are several other simple examples that are worth checking out if you’re just getting started:

13 comments

Michael Horne avatar

There was me thinking that Mathematica was only for doing maths problem solving on the Pi. Wrong! Thanks for the great info!

u8nc avatar

If you search on “Von Neumann Bottleneck” you’ll find that from the largest super transputers to the humblest of .. pi’s all work the same way in that the CPU is away from the Data Store area ( typically, but not limited to, RAM )

The complexity and work just addressing and routing the data back and forth to the registers in the CPU is what is the bottleneck.
There is a web page somewhere, maybe you can find it that discusses “non-von” computers. Sometimes these are referred to as neural networks, where the data is set up in FPGA style, and the program is released upon it, goes through it like the proverbial packet of salts, and leaves the finished calculation. Then like a Conway Game Of Life struct, the program disappears.

Apparently one can simulate this activity on a regular ‘puter simple through the mathematics that underpin the binary, and various non-OS languages are developed for this purpose.
I find it exciting that W|A is involved here as it is one step closer to primary school children being able join in with the exploration alongside Princeton or Stanford sorry, those are mere low grade schools, alongside Cambridge researchers.
Sweet.

nico avatar

Seems to be very powerful.

But being a noob I find it difficult to follow and understand the code examples.

A more detailed code explanation would be great :)

I want to start a project with a MCP3008 in Python, as this seems to be the bread-and-butter approachonthe Raspi. But it seems as if it would be easier using Mathematica should the complexity be removed :)

Matt avatar

Bringing the power of Mathematica and the Wolfram Language to the RPi is great news. I’ve been looking to develop a system that can image capture from a microscope and apply some algorithms for processing the image. With some basic add ons for the Pi I have been able to control the focus of the microscope. Using the Wolfram Language and the Pi together I now hope to develop an auto focus algorithm by providing feedback between the captured image and the focus controller.

AndrewS avatar

Have a look at http://openlabtools.eng.cam.ac.uk/Instruments/Microscope/

There used to be a bunch of detailed PDFs on there, one of which explained their auto-focus algorithm, but it seems the links have been removed :-(

Maybe there’s still useful stuff in https://github.com/OpenLabTools/Microscope

Tom avatar

Hi,

This may be a bit of an advanced topic but I thought it would be cool to learn a bit more about the machine learning capabilities of Mathematica. Linear regression, neural networks, svn, clustering, etc…

I seen there’s a commercial add-on package for this but I’m guessing Mathematica will probably have some support for this out of the box?

Mark Swope avatar

“…It only made sense then to build Wolfram|Alpha in the Wolfram Language.”
The link, “http://reference.future.wolfram.com/language/index.html” doesn’t appear to be valid.

Andrew Jones avatar

The preliminary version of the Wolfram Language documentation is at:
http://reference.wolfram.com/language/
which might be where the link was meant to go to.

joris verrips avatar

yes, fascinating, but i dislike the licence agreement, because it is like wolfram owns your code in the sense that you are not allowed to ship it and/or share it. why?

Bill avatar

I appreciate very much that Wolfram has shown how to take advantage of rPi hardware within their language . But none of the examples provided distinguish Wolfram from any other language that one could use on the rPi. My hope for this article was that I would glean a bit about what sets Wolfram apart from other rPi language, not just what it has in common.
In that regard, it seems the message is a bit backwards. Instead of “Hey rPi users, look at the amazing things you can do in Wolfram!” the message seems to be “Hey Wolfram programmers, look at the tiny computer with a GPIO you can run Wolfram on!”
I could be wrong – I’m not always the most perceptive member of the audience.

Don avatar

How can one make a Wolfram/Alpha query on the RPI from within Mathematica or from within the Wolfram Language?

A few details and an example please.

Thankyou

John avatar

1. It is all very well giving the fancy examples of using Wolfram but nowhere could I find basic instructions on getting started with the programme.
2. The entry for wolfram is miniscule and when ‘quit’ is entered per what there is simply the reply back ‘quit’. I have to reboot the RPi to get out.

Caillin avatar

It’s case sensitive. Try Quit (note the capital Q) :)

Comments are closed