Posts

Showing posts from January, 2021

Pi Pico emulating an Etch-a-sketch

Image
  One Christmas, long, long ago, someone gave me an Etch-a-sketch . I was a bit of a klutz then (indeed, I still am). I never produced great works of art, but the Etch-a-sketch was a lot of fun to play with. Yesterday I wondered how easy it would be to emulate an Etch-a-sketch using the Raspberry Pi Pico. Using PySerial to link Pi and Pico I’d just finished yesterday’s article about how to link a host to the Pico using PySerial. Why not get the Pico to print out how far two potentiometer knobs were turned,  read the output on the Pi using PySerial,  and use the Turtle package on the Pi to create the display? It sounded too simple to work, so I started coding with some trepidation. The first job was to connect a couple of potentiometers to the analogue inputs of the Pico. After that I wrote a short MicroPython program which read the analogue values and printed them out. Here it is: import machine import utime pot_l = machine.ADC( 27 ) pot_r = machine.ADC( 26 ) de

Controlling a Raspberry Pi Pico remotely using PySerial

Image
Update : I'm using thie code below in another project, and found that I had not correctly fixed the reported bug. The new version passes automated tests, and I am pretty sure it works OK. I have changed the name of the class to Talker  since it can both send and receive information. Apologies to all concerned for the bug! Introduction You can use a Raspberry Pi Pico as a powerful peripheral to a host - a Raspberry Pi, a Jetson Nano, a laptop or workstation. In this article you'll see how to interact with a Pico running MicroPython or CircuitPython by writing some Python code that runs on the host. The software is easy to use. It enables you to send a Python statement to the Pico and read the results. The statement can be any valid MicroPython code. Setting up the host and the Pico For this article I've used a Raspberry Pi as the host, but any computer running Windows, Linux or Mac OS will do so long as it has Python 3.5 or later installed. In particular, you can use this t

Which Python should you install on your Raspberry Pi Pico?

Image
 The new Raspberry Pi Pico sold out soon after launch. One of the reasons it's so popular is that you can program it in Python. There are two versions of Python to consider: MicroPython and CircuitPython. Fortunately they are very easy to install or replace and they are very similar. Let's compare them so you can decide which to use. The Official guide to the Pico  (reviewed here )recommends that you install the official version of MicroPython. MicroPython has been around since 2014 , and it's been ported to quite a few boards. It was  created by Damien George, and he is responsible for the port to the Pico. If you're starting with MicroPython and  want to work your way through the Official Guide, use the official version. If you've been using MicroPython for a while you've probably heard of CircuitPython . It's based on MicroPython but  adapted by the inventive folk at Adafruit.  CircuitPython lets you run the same program on any supported board without h

Five ways to connect Raspberry Pi and Pico

Image
The Raspberry Pi and Pico are each very capable, but sometimes you'll want to connect them together. For example, if you're building a robot you may want to use the Pi for computer vision, while relying on the Pico for predictable response times.  How can you get the Pi and the Pico to talk to each other? There are several possibilities, each with their own characteristics. You can connect them with a USB lead and use Thonny to talk to the Pico. That's very easy; it just uses the MicroPython REPL to control the Pico, bit it's very limited. If you've used the REPL to turn the Pico's on-board LED on and off, you've use this option already. You can connect the Pi to the Pico via USB and use a library called PySerial to send and receive data using a Python program that you write. That's a bit harder but much more flexible. You can connect the Pi and the Pico using their TTL serial interfaces - possible in theory, though I can't see much reason to do thin

Review: Get started with MicroPython on Raspberry Pi Pico

Image
If you want to explore the Raspberry Pi Pico you'll find it really easy to get started. On the day of the announcement the Raspberry Pi  Foundation released excellent documentation.The Raspberry Pi press also published a great starter guide:  Get started with MicroPython on Raspberry Pi Pico . It's a super book. The authors are professional journalists and experienced Pi enthusiasts, and it shows! The book covers everything a beginner needs to know to start exploring Physical Computing with the Pico. A guided tour of the Pico Chapter 1 starts with a guided tour of the board. Next it explains how to solder the headers you'll need if you want to use the Pico with a breadboard. The soldering instructions are clear enough for a novice to follow. The book wisely warns younger users to make sure they are supervised by an adult. It's easy to burn yourself badly with a hot iron while you're learning. The chapter finishes with clear instructions that tell you how to install

Getting started with the Raspberry Pi pico

Image
I'm always excited when Eben Upton pulls another Raspberry Pi rabbit out of his capacious topper. Last week he announced the $4  Raspberry Pi pico . It's a unique product for several reasons, and I put an order in as soon as I saw the announcement. It's easy to get the pico going The pico's on-line documentation is superb and it's supplemented by an excellent and inexpensive book from Gareth Halfacree and Ben Everard. I did hit one minor 'gotcha'. I've been working on my main workstation which runs Linux Mint, and discovered the hard way that the Thonny Editor won't install properly if you're using Python 3.5 Python 3.5 has reached end-of-life, but it's still the default on Linux Mint 18.3. If I want to use a later version I have to set up a virtual environment. Once I did that, Thonny installed perfectly and within a couple of minutes I'd created a Hello World script and run it on the pico. If you're using a Raspberry Pi to program

Tom Gilb on Systems Enterprise Architecture

A few days ago my friend Tom Gilb asked me to comment on his new book on SEA (Systems Enterprise Architecture). I've followed Tom's work since he wrote an inspirational and iconoclastic column in Computer Weekly back in the 1980s.  Tom has always been sceptical of claims made in IT without quantified evidence. Early in SEA he tells us 'There comes a threshold of complexity in all disciplines where quantification becomes a necessary tool. The time has come for IT Enterprise Architecture to really make use of quantification, and not just talk about doing it.' He's right, and many traditional IT departments need to mend their ways, but I think Tom underestimates the extent to which the Smart Kids already practice what he preaches. They know that gives them a competitive edge, and for that reason they tend not to broadcast what they do. I'm lucky enough to know a few of them, so I get to hear a little of what they are up to and how they do it. The TDD world has alwa