Posts

Showing posts with the label CircuitPython

Lazydoro migrates to the Pi

Image
In the previous blog post I described cushadoro and its successor, lazydoro Mk 1. That was the first version of lazydoro, implementedin CircuitPython and based on the Adafruit Trinket M0. Today I'll describe the next stage of the project, a Raspberry Pi-based version. I made real progress but, as you'll see, lazydoro was still not quite good enough. Lazydoro needed unit tests At the point were we left the project the Python code had become a little complicated. I thought I ought to do more automated testing. It's possible to do that on CircuitMpython devices like the Trinket M0, but it's a lot easier if you canuse the standard Python libraries, including Python's unittest and mock frameworks. I decided to migrate the project to a Raspberry Pi. Moving to the Raspberry Pi Explorer HAT prototype At the time I migrated the project I had just fallen in love with Pimoroni's brilliant Explorer HAT pro . The HAT has loads of useful peripherals, an...

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 ...

Muliplexing I2C with the Adafruit TCA9548A multiplexer

Image
I want to attach multiple VL53L0X Time-of-flight sensors to a single I2C bus. It looks as if that should be easy, but it's not. One solution involves disabling the sensors and then enabling them one at  a time to change their address. It's workable, but fiddly. If you only have two sensors you could use different I2C buses, but I eventually want to run 8 sensors, so that won't work. The TCA9548A I2C multiplexer There is another approach that is easy to implement and works out of the box. The TCA9548A is an I2C device that acts a little like a telephone exchange. You can use it to route I2C transactions to one of eight separate I2C busses. That allows you to have eight devices with the same I2C address, one on each bus. I did a first experiment using an Adafruit CircuitPython m4 feather. That worked well, and I've just confirmed that it works just as well with a Raspberry Pi. Since I'm using Adafruit's CircuitPython libraries, the same code run...

Adafruit Clue - love at first sight

Image
My Adafruit Clue has just arrived, and I am delighted with it. The Clue is a small single board computer that has the same format and connectors as the BBC micro:bit . It's more expensive than the micro:bit but it's a much, much more capable device. micro:bit Pros and Cons  I still love the micro:bit. It invites you to interact with it as soon as you power it on and it's introduced a huge audience to the pleasures of programming. There are a range of programming options for the micro:bit, including micropython, and it's easy to program using the free mu editor.  However, it has some frustrating limitations. The micro:bit's 5x5 LED display is cute, but scarcely high-resolution. There are a few on-board sensors - an accelerometer and a magnetometer - and you can coax the processor chip into telling you how hot it is. It has a couple of buttons, and it supports radio communication with other micro:bits. But that's all. It also has quite limi...