Connect your Raspberry Pi Pico to a MIDI output socket and play some Bach!

DIY electronic music enthusiast Kevin, who you can find on Twitter, has been experimenting with the new Raspberry Pi Pico and taking what he calls “a first look” at its capabilities in the electro-music arena. With a bit of MicroPython and via some wiring-up to a MIDI output socket, he’s managed to get the Pico to play Bach’s Prelude in C Major! You can see the playback in the video below and you can see a full description of the set-up (including wiring, via a Fritzing diagram), on his blogPlease note his warnings and caveats about what socket/module to use in particular, resistor values etc.

 

CircuitPython from Adafruit runs on the Raspberry Pi Pico

Image from Les Pounder on Twitter!

As highlighted by Les Pounder on Twitter and again by ‘tannewt’ (Scott Shawcroft) on the Raspberry Pi Forums, Adafruit’s CircuitPython will run on the Raspberry Pi Pico and, more generally, RP2040 boards, such as Adafruit’s upcoming Feather 2040.

According to this post on the Forum you just follow these instructions:

You load it just like loading MicroPython.

While CircuitPython is based on MicroPython, there are some key differences why you may want to use CircuitPython instead of MicroPython.

  1. Editing code is simpler because CircuitPython presents a CIRCUITPY drive with a code.py file on it you edit. When you save the file, your code is automatically rerun. See Welcome to CircuitPython for details.
  2. There are 260+ libraries for the standard CircuitPython API. Most of these will already work. Listed here
  3. Tons of guides and tutorials at https://learn.adafruit.com/category/circuitpython
  4. Most CircuitPython libraries also work on Raspberry Pis via the Blinka library.

You may want to use MicroPython for:

  1. Advanced APIs such as interrupts and threading.
  2. Complete PIO API (CircuitPython’s support is incomplete)
  3. Using existing MicroPython code

To get started, download CircuitPython for the Pico from circuitpython.org: https://circuitpython.org/board/raspberry_pi_pico/

For now, click “Absolute Newest“, then click your language code such as “en_US”, and finally download the UF2 file at the top. That will be the latest and greatest version of CircuitPython. As support matures, the download page will have beta and then stable releases.

After dragging the CircuitPython UF2 to RPI-RP2 the chip will reset and show a CIRCUITPY drive.

See the Welcome to CircuitPython and CircuitPython Essentials guides for CircuitPython basics. API Docs are here though they won’t include RP2040-specific modules until support is merged in. A Pico specific guide that will grow in time is here.

Join the Adafruit Discord for #help-with-circuitpython and feel free to mention Scott Shawcroft (@tannewt) for RP2040-specific questions.

The current code is available here: https://github.com/adafruit/circuitpython/pull/4031

Raspberry Pi Pico – a surprise, yet very exciting, new product from Raspberry Pi

Today, Raspberry Pi has announced the launch of their new board – and what a surprise it is! It is their first micro-controller and is called the Raspberry Pi Pico!

Raspberry Pi Pico has been built around Raspberry Pi’s own silicon, developed in-house by them over the last few years. The chip, the RP2040, is a dual-core ARM Cortex M0+ processor, with a flexible clock running up to 133MHz.

Key features:

  • RP2040 microcontroller chip designed by Raspberry Pi in the United Kingdom
  • Dual-core ARM Cortex M0+ processor, flexible clock running up to 133 MHz
  • 264kB of SRAM, and 2MB of on-board Flash memory
  • Castellated module allows soldering direct to carrier boards
  • USB 1.1 Host and Device support
  • Low-power sleep and dormant modes
  • Drag & drop programming using mass storage over USB
  • 26 multi-function GPIO pins
  • 2×SPI, 2×I2C, 2×UART, 3×12-bit ADC, 16×controllable PWM channels
  • Real-time clock (RTC)
  • Temperature sensor
  • Accelerated floating point libraries on-chip
  • 8×Programmable IO (PIO) state machines for custom peripheral support

Here’s the full datasheet with a lot more technical detail.

It runs both C/C++ and MicroPython and you can see a pinout of this very capable little board below:

One of the most impressive things about the Pico is the price – just $4/£3.60 or thereabouts.

You can read the full Raspberry Pi announcement here.

You can buy the Pico from The Pi Hut, and of course from the pirates at Pimoroni and other official resellers. Pimoroni, in particular, have gone all-out to release a set of extras – check them out here.

Pimoroni have also been working on the tinyest 2040-based board called the Tiny 2040 – it’s coming soon and is the size of the end of your finger!

If you subscribe to Hackspace magazine, or you’re lucky enough to find a copy in a newsagent/supermarket, there is a FREE one on the cover this month!

There’s even a book to help get you started – which you can buy here or download for free here.

Thinking to yourself “oh, it’s just a microcontroller”? Take a look at Dave Akerman’s post in which he uses the Pico as a high altitude balloon tracker! Take a look also at Russell’s experiments with Pimoroni breakout garden displays!

For a review of the Pico, take a look at Les Pounder’s piece over at Tom’s Hardware.

Take a look also at Jeff Geerling’s blog for his review. He highlights one of the flaws with the Pico – a lack of pin labelling on the top of the board which means that once it’s plugged into a breadboard, or even a carrier board, you have to consult a pin-out to find out which pin’s which. You can check out his review video below:

Here’s a lovely close-up picture of the new silicon, courtesy of The Pi Hut.

Pi Wars 2021 – Online Conference tickets now on sale! – Event is on 23rd & 24th January

Pi Wars 2021 at Home Conference logo

The Pi Wars team is delighted to announce that tickets for our 2021 Online Conference are now available. They are free but everyone viewing the Conference must have one. That’s one per device watching. You will need to register for the Hopin.to platform to get your ticket and get access to the Conference content.

There are two types of tickets, so please make sure you get the one that is appropriate for you and your viewing group:

  • Under 18s – please ensure you have permission from a parent or guardian to attend.
  • Adults – there is another type of ticket for you.

If you are a speaker or a member of a panel, please hold off for now as we will contact you to get you on the system by a different route.

You can get your tickets here.

A provisional running order for the two-day Conference is available here. Please note, this is subject to change, addition and refinement as we get closer to the event.

Please note, everyone is expected to agree to and abide by our Online Code of Conduct when attending the Conference.

Creating a Home Education School Clock with a Raspberry Pi and an Inky wHAT

Inky wHAT displaying the school clock

Mike: Here’s a guest post from my friend David Booth who you can find on Twitter here and on the web here. This is a great project for the current times we live in (because of the high probability of Home Schooling in the UK due to COVID-19 lockdowns) and also should come in useful for home schoolers in general.

Overview

With the rush to change everyone over to home learning, we thought it was important to retain some sort of school routine in our young kids. For that, we decided to make a clock that showed the time, but also showed a “timetable” specific to our needs. Having got Raspberry Pi’s up the wazoo in this house, and previously being lucky enough to win an Inky wHAT from a Pimoroni competition, it was obvious that I should combine these tools to create a very quick “school clock” project. All the code is available on GitHub.

What I used?

A Pi Zero. There are a plethora of online shops that sell Raspberry Pi’s. I got my Pi Zero WH from The Pi Hut for less than £14. The pre-soldered header just makes life a little easier, but you can solder that on to a normal Pi Zero W yourself if you fancy the challenge/refresher course of soldering.

An Inky wHAT: These can be bought from Pimoroni and you have a choice of colours – Black/White, Red/Black/White and Yellow/Black/White. The price varies depending on model from £45 to £52.50. As I said, I was lucky to have won one! 🙂

Other than that, all you need is an 8GB microSD card or larger, a suitable power supply for the Pi and a way of holding it all together. I used a 3D printed case from Thingiverse.

Hardware Setup

Picture of the reverse of the School Clock showing the backside of the Inky wHAT and Pi Zero

Assuming you already have a Pi Zero W with the headers already on, it is simply a matter of plugging the Raspberry Pi’s GPIO pins into the back of the Inky wHAT, inserting them both into the 3D-printed case, plugging the microSD card in (that has Raspberry Pi OS installed) and powering it on.

Software Setup

First thing to do on any new Raspberry Pi OS is to start a terminal session and update the OS:

sudo apt-get update
sudo apt-get upgrade

After the upgrade is complete, the next step is to install the software required to make the screen work. Pimoroni have created a really quick and easy one-line-installer to get the Inky wHAT set-up:

curl https://get.pimoroni.com/inky | bash

After that is complete, try running one of the example Python scripts that comes with the installer to verify all is working on the screen front. For more information, I’d recommend looking at Pimoroni’s website.

Python Code

Download the Python file from the following GitHub repository and store it in your home folder. https://github.com/worlds6440/school_clock

Make the Python file executable:

chmod +x clock.py

The code is currently set to update the clock every minute and display a new message every half hour between 8:30am and 5pm. You can obviously and easily change this by editing the contents of the get_message() method inside the clock.py file. I do intend to improve the code at some point to take its messages from a file or online location to make it easier to configure, but it’s not strictly necessary and this write-up has taken longer to do than the project itself 🙂

You can test the project now by running in the terminal:

python clock.py

To make the clock start at boot, run:

sudo crontab -e

And add the following line at the bottom:

@reboot /usr/bin/python /home/pi/clock.py &

And that’s it! Your very own School Clock for home schooling!

Display your Raspberry Pi’s video output on an Android tablet or a laptop/desktop via an HDMI dongle

Spurred on by this fantastic post by Les Pounder on Tom’s Hardware, I decided to try out a method for using a screen device with a Raspberry Pi. The trick lies in using an HDMI Video Capture dongle to turn the HDMI output of the Pi into a USB input which is picked up as a webcam on your device-with-a-screen.

I used a Raspberry Pi 400 all-in-one machine, but expect this to work with any model of Pi. Obviously, the more recent your version of Pi, the better speed you’ll get.

First of all, I sought out an HDMI-to-USB dongle. I checked with Les first to see what he’d used. This one on eBay did the job for him, but I thought: Can I get it cheaper? On Amazon, I found a similar-looking dongle for £5.99 (now £6.99) so, being a cheapskate (and having Amazon Prime), I bought one of those and it arrived soon enough.

I used an Official Raspberry Pi microHDMI to HDMI cable (knowing it was a good quality cable) and connected that to the dongle. I then used a USB-to-microUSB adapter that I had hanging around from a Raspberry Pi Zero kit that I got from The MagPi when I subscribed (although I’m sure any one of those adapter cables will work, you just need to make sure it carries the DATA line). I plugged that into my Chuwi 7″ tablet and then loaded up an app called “USB Camera Standard” from the Google Play store. I opened up the app, gave it permissions and… my tablet rebooted. Ah. That’s vexing. But, then, I wasn’t expecting a smooth ride – I fail so you don’t have to. 🙂

Had I got the wrong dongle, I asked myself? Maybe. Let’s try it with my Honor 7x mobile phone…

I plugged everything in, downloaded the same app, opened it, gave the permissions and ping! There was the Raspberry Pi desktop, albeit small. I enabled the Pixel Doubling function in the Raspberry Pi Configuration app under “Preferences” in the Pi’s menu and allowed the Pi to reboot. (This trick is on Les’ blog post here). This doubled the size of everything and I was shown what you see above. You can make the app go full-screen by clicking on the three dots at the top right. This makes the display even clearer. Just good enough for some coding/maintenance/emergency usage.

I then wondered… if all the adapter is doing is converting the HDMI output into an incoming webcam stream, can’t I just use my laptop in the same way? So, I removed the USB-to-microUSB adapter, plugged the dongle into a USB hub (because my laptop is a bit limited on ports, not for any other reason) and Windows reported that it was adding a new device. Excellent! But how to view the output? Well, my mind immediately went to Zoom which I know just displays any camera input (and because I’ve used it every single day recently!). I loaded up Zoom and… it… displayed… oh, hang on, it’s mirrored. But, that’s not a problem – you go into the Video Settings screen and uncheck the Mirror My Video box.

So, that’s the laptop screen outputting the webcam input from an HDMI-to-USB dongle from a Raspberry Pi’s HDMI output!

Yes, I know it’s all possible with a VNC server/client, but this is a great quick-to-get-setup option if you need a screen for your Pi but don’t want to lug around a monitor with a power supply!