the pimoroni scroll:bit – some observations

scroll:bit plugged into micro:bit

I’ve had the Pimoroni scroll:bit for a little while now, and I’ve managed to work with it and get it to perform a number of straight-forward activities. I’m writing some observations and comments based on my successes using the device.

The scroll:bit is purpose built for use with the BBS micro:bit, which in turn is easily used with the Raspberry Pi by communicating with the micro:bit over USB. I’ve been using it with my Raspberry Pi as a simple CPU temperature readout, as you can read in my earlier post. Working on that temperature readout utility taught me how to communicate with the micro:bit and to use the micro:bit to communicate with the scroll:bit. It’s very straightforward and easy to understand (at least for me), and it’s very nice to use Python on both the Pi as well as on the micro:bit itself.

For more detailed control of the micro:bit and the scroll:bit, I use the Mu editor. It’s available in the Raspian repo via ‘sudo apt install mu-editor’. Once installed it’s very straightforward to start and use with the micro:bit and any devices attached to the micro:bit. For example:

The Mu editor is displaying a very simple program that lights up every one of the scroll:bit’s LEDs. The Mu editor is more than just a Python editor. It is capable of fully controlling the micro:bit, allowing the programmer to directly program the Micro Python application directly to the device. For even deeper delving, the Mu editor has a REPL capability where you can work directly with the Micro Python interpreter just like you can with regular Python REPL. That comes in real handy when you’re trying to debug a single statement, or just want to try out a one-line coding trick to see how it really runs. If you’re not familiar with the Mu editor then you should install it and give it a try. It will reward you quite well with its easy to learn, powerful capabilities.

from scrollbit import set_pixel, showbrightness = 32for row in range(7):for col in range(17):set_pixel(col, row, brightness)show()

The example application was written to turn on all the LEDs on the scroll:bit while running on the micro:bit, which is what the lead image shows. There’s hardly anything to the application. I used variables in the call to set_pixel() instead of raw values so that it’s obvious what each one of those variables do. LED brightness can vary from 0 to 255; I chose a low value of 32 to keep from blowing out the taking camera with extreme contrast between the LEDs and the rest of the area. When those LEDs are set to brightness level 255 they are very, very bright.

USB is an acronym for Universal Serial Bus. With the Raspberry Pi and these even smaller boards, that bus is a powerful way to weave all the tiny computers together into interesting combinations. The Raspberry Pi touts its GPIO pins and I2C/SPI connectivity, but USB is no less powerful. I look forward to doing more with the micro:bit as well as another device I have in my tool box, Adafruit’s Circuit Playground Express. All these devices are run with ARM M0 processors. They don’t run nearly as fast as the Raspberry Pi’s CPU, but then they don’t have to.

When I look at all I have to work with between these various devices, I think back on what I had to do 40 or so years ago starting out in embedded design. I would have given my right arm for any of this and its ease of use. Instead, the company I worked for had to spend tens of thousands of dollars for very special test equipment and a lab for me to test my designs in the performance of my job. It’s all quite amazing how much you can do today, for so very little expense, and ease of use.

raspberry pi tips – renaming a usb thumb drive

One of the easiest tasks to perform on Windows and macOS is renaming a USB thumb drive. Using the file explorer on either, you select the item, open its properties, and attempt to rename the thumb drive. Works without issue on Windows and macOS, but try that on Raspbian and you’ll get the following:

Oh dear. No obvious way to run this on the graphical desktop via sudo. It’s these kinds of it-should-be-the-same-on-Raspbian-but-it-isn’t moments that tends to kill some of the enthusiasm of newcomers to the Raspberry Pi and Raspbian itself. Rather than worry about that, let’s do it from the command line. It’s real easy, and you’ll learn a bit about the command line in the process.

First, let’s open an LXTerminal and do a directory listing of where the thumb drive is located (or mounted in Unixese).

pi@raspberrypi:~ $ ls -AlFh /media/pi/total 20Kdrwxr-xr-x 3 pi pi  16K Dec 31  1969 1D2D-5A2A/drwxr-xr-x 2 pi pi 1.0K Dec 31  1969 MICROBIT/pi@raspberrypi:~ $ 

You can tell I have the micro:bit inserted, but what’s 1D2D-5A2A? That, my friend, is the name given by the OS and the USB to the USB because it has no explicit device/volume name. I want to rename that to something more human-friendly. Before I can rename it, I need to find out what the device name is. Knowing it’s volume name won’t help. But I can use the volume name it currently has to find the device name. So let’s do that right now.

pi@raspberrypi:~ $ mount | grep 1D2D-5A2A/dev/sda1 on /media/pi/1D2D-5A2A type vfat ...pi@raspberrypi:~ $ 

When you run this command on your Raspberry Pi you’ll see it produces a lot more information than what I’ve show here, which is why I’ve added the ellipsis to the results. The information we are interested in is right up front, which is the device (/dev/sda1) and the type of file system it is, which in this case is vfat. We have our information, so let’s rename it. I’m going to call it ‘green32’ because it’s a green USB thumb drive with 32GB of storage.

pi@raspberrypi:~ $ sudo mlabel -i /dev/sda1 ::green32pi@raspberrypi:~ $ sudo umount /media/pi/1D2D-5A2Api@raspberrypi:~ 

Now unplug the USB thumb drive and plug it back in again. Raspbian will rediscover it and mount it with the new name you just gave it.

pi@raspberrypi:~ $ ls -AlFh /media/pi/total 20Kdrwxr-xr-x 3 pi pi  16K Dec 31  1969 GREEN32/drwxr-xr-x 2 pi pi 1.0K Dec 31  1969 MICROBIT/pi@raspberrypi:~ $ 

The keen-eyed among you will note that even though I used ‘green32’ it is seen by Raspian as ‘GREEN32’. Just accept it and move on.

From this point you can use it just like you would before you renamed it, except it’s name is more easily readable. Being able to pick a name for your volume makes building automated tools that look for a specific file path much easier to write, especially if your detachable storage has the same name, such as BACKUP for example, across multiple external devices.