Tag Archives: Python

Upgrading the OpenWrt-Yun image on the Yún

via Arduino Blog

ArduinoYun_orizz

Today we released the upgraded version of the OpenWrt-Yun image on the Arduino Yún.
This version includes all the latest and greatest from stable OpenWrt, the latest (Python) Bridge (with a php contribution and fixes to the file module), we also added Mailbox support to REST api and other fixes to some open issues.

The new image contains also the fix to the well known Heartbleed bug, a big security issue that impacted on almost all websites of the world.

If you own an Arduino Yún we suggest you to follow the link and read the procedure to update the board.
You’ll need to download the zip file from the download page. Remember that updating the OpenWrt-Yun image will cause the loss of all files and configurations you previously saved on the flash memory of the Yún.
Enjoy!

Mudra: a Braille dicta-teacher

via Raspberry Pi

Sanskriti Dawle and Aman Srivastav are second-year students at the Birla Institute of Technology and Science in Goa. After a Raspberry Pi workshop they decided they wanted to do something more meaningful than just flash LEDs on and off, and set this month’s PyCon in Montreal as their deadline.

team-mudra1

Aman Srivastav and Sanskriti Dawle

They ended up producing something really special. Mudra means “sign” in Sanskrit: the Raspberry Pi-based device is a learning tool for visually impaired people, which teaches Braille by translating speech to Braille symbols. Braille literacy among blind people is poor even in the developed world: in India, it’s extremely low, and braille teachers are very, very few. So automating the teaching process – especially in an open and inexpensive way like this – is invaluable.

In its learning mode, Mudra uses Google’s speech API to translate single letters and numbers into Braille, so learners can go at their own speed. Exam modes and auto modes are also available. This whole video is well worth your time, but if you’re anxious to see the device in action, fast-forward to 1:30.

Sanskriti and Aman say:

Mudra is an excellent example of what even programming newbies can achieve using Python. It is built on a Raspi to make it as out-of-the-box as possible. We have close to zero coding experience, yet Python has empowered us enough to make a social impact with Mudra, the braille dicta-teacher, which just might be the future of Braille instruction and learning.

We think Mudra’s a real achievement, and a great example of clean and simple ideas which can have exceptional impact. You can see the Mudra repository on GitHub if you’d like a nose around how things work; we’re hoping that Sanskriti and Aman are able to productise their idea and make it widely available to people all over the world.

Learning Python with Raspberry Pi

via Raspberry Pi

If you’ve been round here for any length of time, you’ve probably heard mention of Alex Bradbury. Alex is currently polishing off his PhD thesis at the Computer Lab at the University of Cambridge, and he’s been involved with the Raspberry Pi project as a volunteer from our very early days, back when all we had was alpha development boards. Alex is responsible for building and releasing Raspberry Pi’s Raspbian OS images, and maintaining our Debian repository in his (limited) spare time.

He’s somehow also found the time to write a book with Linux Voice‘s Ben Everard.

Learning Python with Raspberry Pi doesn’t presuppose any computing knowledge, and takes you from a standing start through variables, loops and functions, 3D graphical programming, building games, networking, scripting, interfacing with hardware…and, of course, Minecraft. There’s much more besides: if you work your way through the whole book you’ll be building robots and alarm systems; manipulating sound and video; and learning how to test and debug the Bradbury and Everard way.

As well as what you’ll find in the book, Alex and Ben have made a large code repository available to complement the information and instructions in Learning Python with Raspberry Pi: you’ll be able to download what you need free of charge.

Alex says:

Ever since the introduction of the Raspberry Pi, Python has been touted (with good reason) as the language of choice for anyone wanting to program on the device. Reasonable people can disagree on the ultimate reasons for Python’s success, but I think we can all recognise what an asset its large and friendly community is, as well as the value of its extensive collection of high quality libraries for helping to solve almost any programming task.

Learning Python with Raspberry Pi aims to teach the reader the Python they need to make their Raspberry Pi project ideas a reality. We give lots of examples in the sort of areas likely to be of interest to the Pi community – including physical computing, audio and video, 3d graphics, Minecraft programming, and games.  Another important aspect for us is that every chapter ends with a whole host of ideas and pointers on what you’re now able to do given what you’ve just learnt. Python is the single most useful language to know for the Raspberry Pi, and I like to think that with Learning Python with Raspberry Pi, we’ve managed to produce an entertaining and educational introduction to it. Hopefully you agree!

Learning Python with Raspberry Pi is available from Amazon, and from a good book shop near you: we hope to be stocking it in the Swag Store soon too.

 

 

Raspberry Pi Projects: a big book by Andrew Robinson and Mike Cook

via Raspberry Pi

Ben here – Liz is currently non-functional due to her body having no idea what time it was when she arrived at the office this morning after landing back from San Francisco at the weekend.

Raspberry Pi Projects is a fantastic book from Wiley, the publishers of Eben and Gareth’s Raspberry Pi User Guide and Carrie Anne’s Adventures in Raspberry Pi. It’s written by two great Pioneers: Dr. Andrew Robinson (creator of PiFace) and Mike Cook (co-author of Raspberry Pi for Dummies and creator of many awesome hardware projects).

The book comprises of 16 practical software and hardware projects for the Raspberry Pi – all put together and documented by Andrew and Mike (with help) that are designed to help you better understand the system and become more confident in development of a range of projects. The projects are handily presented in rough order of difficulty, starting with the easier ones to get you going – and move on to more complex ones.

The book covers interactive text based games in Python, graphical games with PyGame, interactive game hardware, application with PiFace Digital, making a toy chicken send tweets, chaotic pendulum hamonographs, car racing and more – as well as a chapter on Minecraft by Sean McManus, and Home Automation by Jonathan Evans.

I wrote on here recently about things you can do with your Raspberry Pi – and this book is crammed full of amazing examples. Books like this and Carrie Anne’s will guide you through a given project and provide you with learning points along the way, which is a great way to learn about Linux, Python, hardware hacking or anything. Beginner or not you’ll learn lots by following the guide set out by experts such as these.

Here are some examples of the projects Mike put together:

PacMan made in Python PyGame:

Disco lights:

See more previews of the contents of the book on Mike’s blog!

Raspberry Pi Projects is available from Amazon and also as a two-part e-book from Wiley: Part 1 & Part 2

Graphic equaliser

via Raspberry Pi

Our good friends at Adafruit put this project on their Learning System earlier this month. It’s a beaut: you’ll learn something making it, and it looks fantastic when set up. Before we get into the nitty gritty, here’s some video:

This graphic equaliser (a spectrum analys/zer if you’re from the USA) is made from a RGB led strip, with everything down to the audio processing run on the Pi. Everything you see in the video is happening in real time. The setup runs Python, and is based on LightShowPi (which was originally designed to orchestrate Christmas lights), so you’ll be able add LightShowPi features like SMS control from your phone if you’re an advanced user.

Some soldering is required – but soldering is easy, and this is a good project to earn your soldering wings on if you haven’t already. There’s the usual full and helpful tutorial over at Adafruit, along with tips, a parts list, code and all that good stuff. I wish I’d had one of these for my student bedroom. Imagine the parties!

Embedded Scripting (Lua, Espruino, Micro Python)

via OSHUG

The thirty-second OSHUG meeting will take a look at the use of scripting languages with deeply embedded computing platforms, which have much more constrained resources than the platforms which were originally targeted by the languages.

Programming a microcontroller with Lua

eLua is a full version of the Lua programming language for microcontrollers, running on bare metal. Lua provides a modern high level dynamicaly typed language, with first class functions, coroutines and an API for interacting with C code, and yet which is very small and can run in a memory constrained environment. This talk will cover the Lua language and microcontroller environment, and show it running on-off-the-shelf ARM Cortex boards as well as the Mizar32, an open hardware design built especially for eLua.

Justin Cormack is a software developer based in London. He previously worked at a startup that built LED displays and retains a fondness for hardware. He organizes the London Lua User Group, which hosts talks on the Lua programming language.

Bringing JavaScript to Microcontrollers

This talk will discuss the benefits and challenges of running a modern scripting language on microcontrollers with extremely limited resources. In particular we will take a look at the Espruino JavaScript interpreter and how it addresses these challenges and manages to run in less than 8kB of RAM.

Gordon Williams has developed software for companies such as Altera, Nokia, Microsoft and Lloyds Register, but has been working on the Espruino JavaScript interpreter for the last 18 months. In his free time he enjoys making things - from little gadgets to whole cars.

Micro Python — Python for microcontrollers

Microcontrollers have recently become powerful enough to host high-level scripting languages and run meaningful programs written in them. In this talk we will explore the software and hardware of the Micro Python project, an open source implementation of Python 3 which aims to be as compatible as possible with CPython, whilst still fitting within the RAM and ROM constraints of a microcontroller. Many tricks are employed to put as much as possible within ROM, and to use the least RAM and minimal heap allocations as is feasible. The project was successfully funded via a Kickstarter campaign at the end of 2013, and the hardware is currently being manufactured at Jaltek Systems UK.

Damien George is a theoretical physicist who likes to write compilers and build robots in his spare time.

Note: Please aim to by 18:15 as the first talk will start at 18:30 prompt.

Sponsored by:

A pure Python interface for the camera module: meet picamera!

via Raspberry Pi

If you have a Raspberry Pi camera module, you’ve probably used raspistill and raspivid, which are command line tools for using the camera. Dave Jones, a Database Admin, software developer and SQL know-it-all based in Manchester has been working on an equivalent, feature complete implementation of these in Python. This means you can access the camera module directly from a Python script, without using os.system or executing a subprocess.

At Oggcamp I set up a big TV with a Pi and camera taped on top. I SSH’d in to the Pi from my laptop and entered commands in to iPython using picamera.

Speaking as an avid Pythonist, picamera’s implementation is beautiful and it really is a wonderful library to use. It works really well for demonstrations using the Pi camera, and for real world applications. Part of the appeal of the Raspberry Pi is that you can work on embedded electronics projects without needing to know low-level languages or have to program a microprocessor – instead you have the choice of a range of accessible high-level languages such as Python – and this is an extension of that kind of abstraction, which open up a world of possibilities to a wider diversity of makers.

Example usage:

import picamera
from time import sleep

camera = picamera.PiCamera()
camera.capture('image.jpg')

camera.start_preview()
camera.vflip = True
camera.hflip = True
camera.brightness = 60

camera.start_recording('video.h264')
sleep(5)
camera.stop_recording()

Also you can do things like this:

for i in range(100):
    camera.brightness = i
    sleep(0.1)

and watch the preview flow through the brightness levels.

The library has many configurations – you can change the brightness, contrast, saturation, image effects, exposure modes and such, as well as optionally show a live preview of the camera’s view. You can capture single images and sequences of images as well as video streams.

Here’s a presentation of picamera Dave gave at Manchester Raspberry Jam XVI – where he demonstrates the basic usage of the module by typing commands in to a Python prompt on his laptop, with a monitor displaying the camera output (unfortunately out of shot in the video):

Dave’s wife Holly works in the Palaeontology department at Manchester University (Interesting fact: when Dave and Holly got married, they picked a new surname to take (Dave was previously a Hughes) – so Holly could become Dr. Jones, and he would become Davy Jones) where they regularly capture images from microscopes. Rather than mount a huge camera on top of a microscope, Dave suggested attaching the Pi’s camera module to the lens.

An early version of the crudely mounted Picroscope

He ended up writing a web app to support its use. This allows the user to control camera configuration settings through a web page, and capture photographs at the click of a button, as well as archive pictures taken in to a database along with metadata and extra information entered in a web form.

The web app showing pictures taken (smaller field of view due to temporary mounting setup)

Single view of image taken through the web app, with metadata fields

Picroscopy configuration settings

Dave gave another presentation at the Manchester Jam, this time demonstrating a simple version of a Python web app for such an application (please excuse the numerous technical hiccups):

As Dave says in the video:

“This is where having a library is particularly useful. If we were doing this with, say, raspistill and raspivid, when you want to alter the brightness of your preview, you’d have to shut down the program, regenerate the command line, restart the program. Here we’re just saying “set a property”. This is why a library is better for an interactive application like this. There’s nothing wrong with raspistill and raspivid as far as they go, but they’re not ideal for building this sort of application. If you have interactivity, you want a library.”

See more videos from the Manchester Jam: Jam #16 Videos.

picamera has been available in pypi since October (v0.5), so it’s already in the wild – but now it’s hit the v1.0 milestone Dave considered feature complete, it’s packaged in the Raspbian archives so you install with apt-get (remember to run apt-get update first):

apt-get install python-picamera

or

apt-get install python3-picamera

depending on your taste.

Dave also mentioned to me that this is by far the most popular project he’s ever published – and he’s been impressed by how brilliant the feedback has been from the Pi community. He’s had a great response on the forums, detailed bug reports provided by users and plenty of help from James Hughes, the author of raspistill, and from Alex Bradbury in getting it packaged for Raspbian.

See the source for picamera and the picroscopy web app on github. Thanks to Dave for his hard work in building this library. Enjoy!

Wireless Encryption Between Galileo and a MSP430

via Hack a Day» hardware

[Mark] recently finished his latest project, where he encrypts wireless communications between the new Intel Galileo and a Texas Instruments MSP430. The wireless interfaces used are the very common nRF24L01+ 2.4GHz transceivers, that had a direct line of sight 15 feet range during [Mark]‘s tests. In his demonstration, the MSP430 sends an encrypted block of data representing the state of six of its pins configured as inputs. This message is then received by a sketch running on the Galileo and stored in shared memory. A python script then wakes up and is in charge of decrypting the message. The encryption is done using AES-128bits in Electronic Codebook mode (ECB) and semaphores are used to prevent simultaneous accesses to the received data. As it is the first project using an Intel Galileo we received, don’t hesitate to send us a tip if you found other ones.


Filed under: hardware, Microcontrollers

PyPy 2.1 beta released

via Raspberry Pi

Back in May, we mentioned that we’d been sponsoring the development of the ARM port of PyPy, the high-performance Python interpreter. Earlier today the team released a first beta of the upcoming 2.1 release, which for the first time adds ARM as an officially supported architecture.

You can see the announcement here, and download binaries for Raspbian here. Give it a spin and let us know what you think.

PyPy on Pi

via Raspberry Pi

While we love all programming languages equally here at the Foundation, we do love Python an awful lot. Most users run their code under the “default” CPython interpreter, but over the last few years the PyPy project has made great strides in producing an highly compatible alternative interpreter with an integrated tracing JIT compiler. On x86 platforms this can improve the performance of some workloads by a factor of ten or more, and the PyPy team are now bringing the same sort of boost to the ARM world.

You can download an Pi-compatible alpha release of PyPy for ARM and see some benchmarks here. We’re proud to have been able to contribute a small amount of funding to the latter stages of this project; over the next few weeks we’ll be running an irregular series highlighting some of the other open source projects that we’ve been contributing to.

Minecraft in the classroom?

via Raspberry Pi

Last week I ran a short session at Campus London with a roomful of students from local schools. Only one of the students had seen a Raspberry Pi before and only a couple had used a command line interface or seen a computer program. In just over an hour they learned how to set up the Raspberry Pi, did a bit of Linux and then hacked Minecraft using Python. Here’s what they thought of it:

“I used a raspberry pi and it showed me how exciting and useful new technology can be. Also learning simple coding was very useful and made me want to learn more. It made me more interested in technology and coding. It made me really consider my careers options involving technology.” —William

“This has pushed me to finish my game I am currently developing.” —Joseph

“It has made me interested about learning coding. I have realised coding isn’t as hard as I thought.” —Lara

“I want to learn more about programming, because it was really interesting.” —Ellie

“The most important thing I learned was how to use Raspberry Pi.” —Finley

Running minecraft from the command line

“The most important thing I learned was how to change the commands to Mine Craft.” —Harjoat

“We had a go using a device called a Raspberry Pi which let us hack into a game and let us give it commands. It was really fun and exciting to learn all these new things.” —Jasmine

Reading these comments makes me smile, it was a fantastic session and shows what you can learn in short amount of time. A few lessons jump out from the feedback:

  1. When given the opportunity, most young people find computing to be a powerful and exciting thing.
  2. Everyone gets something different out of learning how to tell a computer what to do.
  3. Play is a powerful way to learn and computers are a good way to play.

These lessons are hardly new—it’s where Logo, Scratch and Lego Mindstorms come from—but what has changed is the accessibility and opportunity. With a £30 computer and a free game you can learn computer science in a beautiful, constructionist sandbox. (“Why dig when you can code?” “Are you an Alpha or an Epsilon?” “Hack with your brain, not with your pickaxe.” And other rubbish aphorisms coming soon to a T-shirt near you.) Quite simply, you can teach yourself to think in powerful ways while messing about. I don’t know about you, but as a teacher I think that this is quite profound.

Hacking Pi Minecraft using the API and Python.

I’m going to blog more about Pi Minecraft in future; I think that its potential as a teaching and learning tool is huge.  I’ll be writing lesson plans for it and hopefully not just computing lessons: Martin O’Hanlon’s analogue clock for example would be a brilliant to teach trig and geometry in the constructionist stylee. If anyone out there—teachers, programmers, Notch, whoever—want to help then get in touch. The School of Minecraft has a nice ring to it don’t you think?

P.S. Campus is an amazing place: if you are a tech start-up or entrepreneur (or would like to be!) and can get down there, check it out. I love it.

PiUi – control your Pi with your phone

via Raspberry Pi

David Singleton has been laid up with a broken leg, and has taken the downtime to do some work on PiUi. PiUi enables you to add a mobile phone user interface to a Raspberry Pi project when a screen and keyboard aren’t a practical solution. It’s magic: PiUi makes your Pi behave like a wireless access point, and connecting your phone is as easy as…[restrains self from making obvious bad pun].

This is a really, really useful piece of software; I’ve already had about ten ideas for ways I can usefully deploy PiUi in the house. We’re finally replacing our wobbly green 1970s nightmare of a kitchen this year, and I’m hoping to have a Pi controlling some of the lighting, the coffee machine, the heating and some of the cooking hardware when we do. Using a phone rather than the touchscreen I’d been intending to mount on a wall is a no-brainer. You can find everything you need at GitHub, including lots of documentation. (Note to developers: we love it when you include lots of documentation.) David also has a post about the project on his blog.

This is something I expect we’re going to see a lot of people here using in future Pi projects; it’s simple, elegant and very nicely implemented. Do you have plans for PiUi? Let us know in the comments.

Livebots

via Raspberry Pi

This is brilliant. Livebots is a project which allows you to control a robot (powered by the Pi, of course) over the internet. Follow the link, or watch this rather excellent video to see what’s going on.

You’ll be using buttons in the browser to send Python instructions to the robots via their serial ports. The robots are available to control depending on which of them is online at the moment you visit. There’s a robot with googly eyes, one that does ballet poses and urinates (!), and plenty of LEDs to flash on and off.

Detailed instructions on adding your own robot to the collection are available at Instructables. We are torn between our love for the breakdancing robot and for the creepy robotic hand. It’s up to you to add some more so we can do some more arguing about which is our favourite.

No Starch Press discounts for Pi users (now 40% off – see below for update)

via Raspberry Pi

A few notices: if you’re at BETT this week, come to Stand B240 to meet one of the Robs, Clive and a bunch of impaled Jelly Babies.

Pete Lomas is at Campus Party in Sao Paolo, Brazil. He’ll be giving a talk on Friday at 5.30pm; if you’re in town, go and hear what he has to say!

Finally, Eben and I are flying out for some meetings in the US today; we’ll be incommunicado until the weekend. 

Update, Feb 1: I just had mail from the folks at No Starch Press, who say:

We heard from a couple customers that they were a little stretched by the price of the books and the international shipping costs, so we decided to bump the coupon value to 40% off to make it easier on everyone. We’re applying the 40% discount to anyone who already used the code, so they’ll have the best price, too.

We were sent copies of two books from No Starch Press last week. Super Scratch Programming Adventure and Python for Kids are terrific; they’re colourful, engaging and just the sort of thing we think kids are going to respond to.

We enjoyed both books, but in particular, we really think the authors of Super Scratch Programming Adventure are on to something: what kid doesn’t enjoy pyramids full of treasure; and what kid doesn’t want to write a game about them? As well as introducing them to Scratch itself, and to programmatic thinking, the book’s a great introduction to game design. Kids will start building games from the first page. And we loved the presentation; this thing is part comic, part storybook.

 No Starch have an offer for Raspberry Pi users: if you enter RPi at the checkout on their website, you’ll get 30% off both of the books (either purchased separately or together). Print book purchases come with free ebook editions, and the code will work for ebooks alone, too, so you don’t need to fork out for shipping if you don’t want to. Click on the books to order.