Posts

Showing posts from August, 2022

How to write reliable tests for Python MQTT applications

More and more IoT applications use MQTT. It's a simple and very useful messaging framework which runs on small boards like the Raspberry Pi Pico as well as systems running under Linux, MacOS and Windows. I recently decided to add some extra functionality to Lazydoro using MQTT. The code seemed to work when run manually but I had a lot of trouble getting my automated tests working. It took quite a while to understand the problem, but the fix was simple. Intermittently failing tests are bad In the end-to-end test that was causing the problem, the code simulated the start of a pomodoro session and then checked that the correct MQTT message had been  sent. The test usually failed but sometimes passed. When I manually ran a separate client that subscribed to the message stream I could see that the right messages were being sent. Intermittently failing (or passing) tests are a nuisance. They do nothing to build confidence that the application under test is working reliably, and they are

How can you make your Pico/Pico W project portable?

Image
In this article you'll learn how to solder the Pimoroni Lipo Shim for Raspberry Pi Pico/Pico W and use it to power your project from a single LiPo battery. You'll also discover a problem, and a solution, if you want to check the battery level remotely. Some Pico W projects need to work anywhere. Wi-Fi takes care of the connectivity, but the projects need battery power to make them truly portable. If you're building a portable project you'll find the Pimoroni Lipo Shim for Pico is a great solution. Here's how to attach and use it. Powering the Pico While you're writing the software for your Pico or Pico are you'll be using a USB cable to linking it to your host. Once your hardware and software are working you may want to free the Pico from its umbilical cord. The Pico can be powered from a battery; it's very adaptable, working off an input voltage that can range from 1.8 to 5.5 volts. The Pimoroni Lipo Shim for Pico takes advantage of t

Raspberry Pi PicoW projects on Tom's Hardware PiCast

Image
A few days ago I was asked to present some of my Raspberry Pi Pico W projects on the PiCast from Tom's Hardware . Editor Avram Piltch ( @geekinchief ) was the super-friendly host as usual, and Les Pounder ( @biglesp ) told us about his Pico W-based webserver. Raspberry Pi expert  Ash Hill  added to the fun. Ash edits Tom's hardware's monthly Best Raspberry Pi Projects feature - always worth a read. Pico W projects a-plenty I had to dig out an extra USB hub to drive all the projects I showed! Missed it? Don't worry! You can watch a recording on YouTube :

Connect the Raspberry Pi Pico to an OLED using Grove breakouts

Image
In this short article you'll learn how to make and use a compact, inexpensive adapter that will allow you to connect a Raspberry Pi Pico/PicoW to Grove I2C peripherals. With a Grove to Stemma QT/Kwiic adapter cable, you can also connect your Pico/PicoW to Adafruit and Sparkfun I2C devices. You'll laso learn a useful hack that lets you connect the 2mm spaced Grove adapters to a 0.1" spaced (2.54mm) pcb. Grow with Grove Regular readers will know I love breakout boards. One of the projects that I've been working on is a Raspberry Pi Locator. It reads updates from the @rpilocator RSS feed, and it tells you when and where Raspberry Pi stock is available. The Pico W will sound a buzzer when there's stock around, but it would be great if it could tell you which stores had the Pis. On OLED display would keep things compact, and I thought I'd hook one up. Seeed studios have a great range of Grove breakouts with an easy-to-use connection system, and I knew

Simple, repeatable deployments in a MicroPython environment

Have you ever suffered from "It works on my machine"? Most of us have, as users (well, it doesn't work on mine!") or as developers ("what have I done wrong this time?".  The cause is almost always down to something that's on the developer's machine that they have forgotten about, but make use of. That something doesn't get included in the installation process, so users may not have it installed. There's a great way to avoid that. Testing an installation process if you have an OS If the software you're developing runs under an Operating System, run the installation in a freshly-created virtual machine. That will ensure that you start without  somethings installed. You'll only have the software that's specified in your installation process. If that works, you're in good shape. What about installing MicroPython software on devices like the Raspberry Pi Pico? Testing an installation process for MicroPython projects A comparabl