Showing posts with label PIMORONI. Show all posts
Showing posts with label PIMORONI. Show all posts

Sunday, 29 December 2024

Pimoroni Plasma 2350

Raspberry Pi recently released the RP2350 microcontroller. There was a shortage of the corresponding Pico 2 development board, but other board manufacturers certainly filled the gap.

One of them was Pimoroni with a number of interesting offerings.

One of them is the Plasma 2350 Neopixel strip controller.

I already had a set of the RGB LED Star Wire 66 Neopixel strips, so I just bought the board.

The board is fully assembled and just requires the use of a jeweller's type screwdriver to attach the wires from the NeoPixel strip to the board using the terminal block. One thing to note is that unlike the Plasma Stick 2040W, the Plasma 2350 has a four connector terminal block. As you can see, the connections to use are 5V, Dat[a] and negative.

The board has one QWIC/STEMMA I2C connector, an on-board NeoPixel, three buttons (reset, boot and user button) and a connector labelled SP/CE. The latter is an SPI connector standard allowing higher speed connections to the board (such as WIFI).

What it does not have is WIFI or Bluetooth onboard (a later variant does but does not have the SP/CE connector, a Raspberry Pi RM2 Wireless module is directly wired to the board.)

Code

So to use the board and the LED string, some code is required.
This is the code for the main.py file.
The plasma2040 module in plasma works with the Pasma 2350.
The user interface is very simple. Pressing the User Button A cycles through the available light options.
The specific display uses Pythons' polymorphism to handle the basic operations. The method update() updates the display and is triggered (in this case) every half a second.
The light_show_base class (and its subtypes) determine what happens during the update. That code is in a separate file.

main.py

import plasma
from light_show_base import RGBElement, light_show_base, light_show_static_seven, light_show_static_seven_reverse, light_show_alternate
from plasma import plasma2040
from time import sleep
from pimoroni import RGBLED
# Set how many LEDs you have
NUM_LEDS = 66

led = RGBLED(16, 17, 18) 

# WS2812 / NeoPixel™ LEDs
led_strip = plasma.WS2812(NUM_LEDS, 0, 0, plasma2040.DAT)

# Start updating the LED strip
led_strip.start()

display = light_show_base(led_strip, NUM_LEDS, led)
a_button = machine.Pin(12, machine.Pin.IN, machine.Pin.PULL_UP)

selected_pattern = 0

while True:
    display.update()
    if a_button.value() == 0:
        selected_pattern = selected_pattern + 1
        if selected_pattern > 5:
            selected_pattern = 0

        if selected_pattern == 0:
            display = light_show_base(led_strip, NUM_LEDS, led)
        elif selected_pattern == 1:
            display = light_show_static_seven(led_strip, NUM_LEDS, led)
        elif selected_pattern == 2:
            display = light_show_static_seven_reverse(led_strip, NUM_LEDS, led)
        elif selected_pattern == 3:
            display = light_show_alternate(led_strip, NUM_LEDS, led, RGBElement(255,0,0), RGBElement(0,255,0))
        elif selected_pattern == 4:
            display = light_show_alternate(led_strip, NUM_LEDS, led, RGBElement(0,0,255), RGBElement(255,255,0))
        elif selected_pattern == 5:
            display = light_show_alternate(led_strip, NUM_LEDS, led, RGBElement(0,255,0), RGBElement(255,255,255))
        print(selected_pattern)

    sleep(0.5)
    

light_show_base.py

The file contains two main classes: RGBElement and light_show_base.
There are also subclasses of class light_show_base, inheriting from light_show_base.
class RGBElement:
    def __init__(self,red, green,blue):
        self.red = red
        self.green = green
        self.blue = blue
    def __str__(self): 
        return f"{self.red} {self.green} {self.blue}"
        
class light_show_base:
    def __init__(self, led_strip, num_leds, rgb_led):
        # Device specific settings
        self.led_strip = led_strip
        self.rgb_led = rgb_led
        self.num_leds = num_leds
        
        # Chosen colour
        self.current_colour = 0
        
        # Base set of colours
        self.white = RGBElement(255,255,255)
        self.yellow = RGBElement(255,255,0)
        self.magenta = RGBElement(255,0,255)
        self.red = RGBElement(255,0,0)
        self.cyan = RGBElement(0,255,255)
        self.green = RGBElement(0,255,0)
        self.blue = RGBElement(0,0,255)
        self.black = RGBElement(0,0,0)
  
        # List of colours
        self.colours = [
            self.white,
            self.yellow,
            self.magenta,
            self.red,
            self.cyan,
            self.green,
            self.blue,
            self.black
            ] 

            
    def update(self):
        if self.current_colour == len(self.colours) - 1:
            self.current_colour = 0
        else:
            self.current_colour = self.current_colour + 1

        rgb_colour = self.colours[self.current_colour]
        self.rgb_led.set_rgb(rgb_colour.red, rgb_colour.green, rgb_colour.blue)
        for i in range(self.num_leds):
            self.led_strip.set_rgb(i, rgb_colour.green,rgb_colour.red, rgb_colour.blue)
        
class light_show_static_seven(light_show_base):
    def __init__(self, led_strip, num_leds, rgb_led):
        super().__init__(led_strip, num_leds, rgb_led)
        self.colour_strip = []
        ix = 0
        for i in range(self.num_leds):
            self.colour_strip.append(self.colours[ix])
            if ix == len(self.colours) - 1:
                ix = 0
            else:
                ix = ix +1
                
    def change_colours(self):
        last_colour = self.colour_strip[1]
        for i in range(self.num_leds):
            if i > 1:
                self.colour_strip[i - 1] = self.colour_strip[i]
        self.colour_strip[self.num_leds - 1] = last_colour
            
    def update(self):
        for i in range(self.num_leds):
            rgb_colour = self.colour_strip[i]           
            self.led_strip.set_rgb(i, rgb_colour.green,rgb_colour.red, rgb_colour.blue)
        rgb_colour = self.colour_strip[1] 
        self.rgb_led.set_rgb(rgb_colour.red, rgb_colour.green, rgb_colour.blue)

        self.change_colours()

class light_show_static_seven_reverse(light_show_static_seven):
    def __init__(self, led_strip, num_leds, rgb_led):
        super().__init__(led_strip, num_leds, rgb_led)

    def change_colours(self):
        last_colour = self.colour_strip[self.num_leds-1] 
        for i in range(self.num_leds-1):
            ix = self.num_leds - i
            print(ix)
            if ix < self.num_leds-1: 
                self.colour_strip[ix + 1] = self.colour_strip[ix]
        self.colour_strip[1] = last_colour            
        
class light_show_alternate(light_show_base):
     def __init__(self, led_strip, num_leds, rgb_led, led_one, led_two):
        super().__init__(led_strip, num_leds, rgb_led)
        self.led_one = led_one
        self.led_two = led_two

     def change_colours(self):
        temp = self.led_one
        self.led_one = self.led_two
        self.led_two = temp


     def update(self):
        led_one = self.led_one
        led_two = self.led_two
        self.rgb_led.set_rgb(led_one.red, led_one.green, led_one.blue)
        for i in range(self.num_leds/2):
            self.led_strip.set_rgb(i * 2, led_one.green,led_one.red, led_one.blue)
            self.led_strip.set_rgb(i * 2+1, led_two.green,led_two.red, led_two.blue)
        self.change_colours()

References


Saturday, 27 January 2024

Raspberry PI 5 with NVME Base and SSD

 Pimoroni have recently released a base to interface a Raspberry Pi 5 to a Solid State Drive.

Components

Raspberry Pi 5 with 8GB of RAM.

A Raspberry Pi 5 Active Cooler (fan and heat sink).


The Active Cooler comes complete with pre-fitted heat sink pads.
A 500GB SSD. 

The Pimoroni NVME base.
The NVME pack contains the base plate itself, a pack of crews and nuts, a ribbon cable and some self-adhesive feet.
Of course you need a power supply.

Assembling the Raspberry Pi 5 with the active cooler

Take the Raspberry Pi 5 out of the box (remember to earth your self before opening the box).
Take the Active Cooler out of its box and check the power cable.
Remove the cap from the fan socket.

Remove the backing paper from the heat sink.
Check the operation of the spring-loaded attachment pins.

Align the pins with the relevant holes in the Raspberry Pi board.
When they are aligned, push the pins through the cooler board until they are attached to the Raspberry Pi board. Ensure alignment before releasing the pins so the heat sink material adheres to the required components. 

This is definitely not something to do when it is very warm as it makes the heat sink material very sticky.

Plug the cooler power lead into the Raspberry Pi board.

Create the OS SD card

The latest installer allows you to select the hardware, in this case a Raspberry Pi 5, as well as the operating system.

The NVME base requires 64-bit Raspberry Pi OS.

Select the 64bit Raspberry Pi OS.

Image the SD card.

Once the OS is ready, slot the SD card in and boot.

Finish the set up for the OS including a full update..

Building the NVME base

Once the Raspberry Pi is updated, shut it down and remove the power supply.
Place the Raspberry Pi 5 and the contents of the NVME pack on your work space.
Check the components:
  • • NVMe Base PCB with M.2 Slot (M-Key)
  • • 'PCIe Pipe' Flat Flex Cable
  • • 4x Rubber feet
  • • M2 bolt and 2x nuts for SSD mounting
  • • 4x 7mm M2.5 standoffs for base mounting
  • • 8x short M2.5 bolts for base mounting 
  • • 4x long M2.5 bolts for 'pass-through' mounting with a HAT
The pack is suppllied with a number of spares, just in case.

Fit the short M2.5 bolts through the base and add the stand-offs.


Carefully remove the SSD from the packaging. In this case, there are instructions in the box showing how to remove the SSD (you use one of the finger holes and rotate it out of the plastic carrier). 

Take the M2 bolt and fit to the base for the size of SSD. Fix in place with one of the nuts.

Take the SSD drive and slot into into the slot on the board. Ensure the SSD in aligned properly and square to the connector. Fix in place with the second nut.

Take the Raspberry Pi board. Gently lift the cover on the PCIE connector.

Take the ribbon cable. The image ill face outwards when fully assembled and the Pi end is the smaller (so the text is the right way up when the NVME base is at the bottom.

Hold the cable in place (copper side towards the centre of the board) and push down the latches.

Turn the Pi upside down and bring the NVME base in.

On the NVME board, flip up the connector. Fit the ribbon cable. Once it is correcly aligned, flip the latch down.

Now screw the two boards together carefully.


Turn the Pi - NVME board sandwich (with its SSD filling) upside down.
Apply the self adhesive feet. The left hand end is easy as they can go in the top and bottom corners. The right hand ones can go just in-board of the screws.

Software installation

Switch on your Raspberry Pi.

Log in as normal (you should have already configured the SD card earlier).

The Raspberry Pi needs to have the latest updates including firmware. The normal update should  work, but you can force the update via  sudo raspi-config. Update the firmware using sudo epi-eeprom-update.

You can format the the SSD using the Raspberry Pi Imager. It should allow you to import the settings from the SDD card (locale, WiFi etc).

Once that has completed run sudo raspi-config in a terminal window.

Go to the Advanced section and change the boot order to boot from the SSD.

Reboot.

The Raspberry Pi will boot from the SSD.

Shut down, and carefully remove the SD card and put it in a safe place.

References

Raspberry Pi 5

https://shop.pimoroni.com/products/raspberry-pi-5?variant=41044580171859

Raspberry Pi 5 Active cooler

https://shop.pimoroni.com/products/raspberry-pi-5-active-cooler

NVME Base

https://shop.pimoroni.com/products/nvme-base?variant=41219587178579

Assembling the NVME Base video

https://www.youtube.com/watch?v=odG7FbptgWQ


Sunday, 24 December 2023

PIMORONI PicoVision dual RP2040

 PIMORONI have released a clever board that combines a Pico W with a second RP2040 chip and supporting electronics complete with an HDMI shaped output, a 3.5mm headphone socket and a micro-SD card reader.

It is available on its own or as part of a complete box set.

I bought the complete box set.

The Pico Vision uses a complete Pico-W board as the main microcontroller, which is attached to the Pico Vision board.
The second RP2040 acts as a GPU.
One of the clever items in the box is a USB splitter cable which allows a USB device to be plugged into the board while the socket is also powering the board.

Now to actually use it.

Tuesday, 29 August 2023

Cosmic Unicorn

 Pimoroni's Cosmic Unicorn is one of their range of Pico W Aboard products and comprises a 32 x 32 smart RGB LED matrix. 

There is a complete Pico W attached to the back of the board. The use of a complete Pico W means that you can use the existing certification of the board, which means you can bring Wifi powered products to market quicker as you do not need to get your product certified, it is all off the shelf.
There are four general purpose buttons, a pair of volume up/down buttons, a pair of brightness buttons, a Sleep button and a Reset button (to save wear and tear on the USB socket). There are two STEMMA/QWIIC sockets for I2C breakout board and a speaker.

There is a hanger at the op, four holes in the corners and two holes to take a stand.

Out of the box there is a simple demo application. It suggests you press one of the four buttons (but does not tell you where they are or what they do). The four options were a fire simulator, a supercomputer style display, a rainbow and a calendar (requiring WiFi credentials).

This was a simple UI upgrade, listing the options and tracing the location of the relevant button.
As you might of noticed the options displayed do not reflect that list, but include a clock.

Pimoroni have developed a graphics library that works across a range of display devices. 
The original work on the clock was for an Inky Frame eInk display board. As this seven colour display takes thirty seconds to update the display, the development took place on a LCD Display Pack.

It was very easy to port the code to the Cosmic Unicorn.

Integrating it into the supplied program required some minor changes - which will be detailed later.
Three of the original effects are still available.
The fire effect display.


Wednesday, 7 June 2023

Ending the drought - Raspberry Pi 4 4GB

It has been a while since Raspberry Pis have been available (the last one I bought was the end of 2021).

So when Pimoroni had a Raspberry Pi 4 4GB available, I bought one, a power supply and a (black) heat sink case.

The case comes complete with heatsink pads (and some spares).
The case is secured with allen bolts
Using a scalpel, I removed the protective covers from one side of each pad and applied them to the raised areas on the top cover. Once in place the other covers were removed (again using a scalpel).
The top and bottom of the case (with the Raspberry Pi in the middle) was then assembled and screwed together with the allen bolts.



Thursday, 5 January 2023

Interrupt driven buttons on the Raspberry Pi Pico

There are two ways to detect the operation of buttons - polling and interrupt.

Polling involves checking the status of the button, which has to occur each time and can be missed if the program is busy elsewhere. It does have the benefit of conceptual simplicity.

Interrupts requires the program to be literally interrupted when the button is pressed, and code to be executed and then the program resumes its normal course. There are a number of complexities created by this method, especially if the task is complicated (things can be in the process of being changed when the interrupt occurs and so the results may not be predicted). There are additional complexities involved in the Micropython implementation (see the documentation here)

The PIMORONI Inky Pack (described here) is fitted with three buttons.


The objective is the display details of which button has been pressed.

Each button is attached to a GPIO pin (pins 12-14 on the Inky Pack) and can be created as a simple Pin object using the following code (this is for the button A on the Inky Pack).

pin1 = Pin(12,Pin.IN,Pin.PULL_UP)

To use interrupts, set the trigger and the callback handler function.

pin1.irq(trigger=Pin.IRQ_FALLING, handler=callback)

The callback function 
def callback(pin):

Supplies the Pin object to the code in the function.

Though the Pin object requires the pin id (in this case 12), it is not (currently 05/01/2023) possible to obtain the pin id from the Pin object directly.

However it is possible to check the equivalence of the supplied Pin against known pins:

def callback(pin):
    if(pin == pin1):
        print("Pin 1")

This means the same callback function can be used for all three pins, the equivalence check defines which pin is calling the callback function.

By using the code below, the following text is printed to the REPL console after the three buttons are pressed within the ten second cycle time of the loop and button B is pressed in the next loop.

cycle
Pin 1
Pin 2
Pin 3
cycle
Pin 2

Code

from machine import Pin
import time

# Set pins to the three buttons on the Inky Pack
pin1 = Pin(12,Pin.IN,Pin.PULL_UP)
pin2 = Pin(13,Pin.IN,Pin.PULL_UP)
pin3 = Pin(14,Pin.IN,Pin.PULL_UP)

# Define callback function for the interrupt
def callback(pin):
    if(pin == pin1):
        print("Pin 1")
    if(pin == pin2):
        print("Pin 2")
    if(pin == pin3):
        print("Pin 3")

# Set interrupt trigger and callback handler
pin1.irq(trigger=Pin.IRQ_FALLING, handler=callback)
pin2.irq(trigger=Pin.IRQ_FALLING, handler=callback)
pin3.irq(trigger=Pin.IRQ_FALLING, handler=callback)

# Infinite loop, every ten seconds it prints cycle.
while True:
    time.sleep(10)
    print("cycle")

References



Tuesday, 20 December 2022

PIMORONI Inky Pack with Raspberry Pi Pico W

 The PIMORONI Inky Pack is compact 296x128 pixel mono E Ink pack.

It has a socket for a Pico or Picow W, plus a Reset button.
The use of the the Inky Pack and a Raspberry Pi Pico W allows information to be obtained from outside sources and displayed on the Inky Pack. The E-Ink display only needs power when changing the display. Once changed, the display remains even when the power is removed (you may notice that there is no power cable in the photographs).

These are test runs with the data source being the BBC Weather RSS feed.

PIMORONI Plasma Stick 2040 W Christmas Lights

 So having played around with the Plasma Stick 2040 and run a web server on it, it was time to use it for Christmas lights

Initially the idea was to use the PICO W as an Access Point and control it via a web interface. This would make it independent of any local access point. Unfortunately there were some issues which I was unable to resolve before I needed to use the lights in the field. So to be able to change the lights a Rotary Encoder was plugged into the QWIIC socket via a Breakout Garden to QWIIC converter and a QWIIC cable.

For Christmas tree lights of course, the existing web server could have been used, time waits for no developer so it was used "as is".

In addition there is a Pimoroni Snowflake Solo on the tree.





Sunday, 20 November 2022

Enclosures - featuring PIMORONI's IP66 Waterproof Plastic Enclosure

 All this marvellous technology is fine in the comfort of a warm and dry home or office, however what do you do when you want to keep the kit safe and dry (or at least out of the way of fingers or paws).

PIMORONI have just added three IP66 waterproof enclosures to their growing list of products.

Note - IP66 is waterproof, not immersion proof. You can put the enclosure in the garden and it will be safe in the rain, but not actually put it it in water.

This one has external dimensions of 125 x 125 x 75mm, with a clear plastic lids.

There is ample room for a PIMORONI Enviro board (and battery pack).
Or Raspberry Pi Zero with a PHAT.
Or both.
There is room to take a standard Raspberry Pi (in this case a 4 in a heat sink case) plus space for batteries etc.
The lid is secured by four plastic screws, they have a retainer that should stop them falling out when unscrewed.
The bottom of the case has mounting holes to assist in securing the contents.

There are also holeds on the rear face to add fixings.

Now these are not the only source of enclosures, the folowing two were bought from the late and lamented Maplins. Similar IP65+ enclosures can be found in DIY shops.
This is about the same size as a standard light switch or socket box. 
It will take a Raspberry Pi Zero, there is still room for  a battery pack.

The box comes with a gasket that fits into the lid.

This box is slightly larger ad will take an Enviro board.
It will take a full size Raspberry Pi, but probably not a suitable power supply, so it will need an external power source.
However it will not allow anything to be plugged into the USB sockets.
More space for battery.


Comparison of the three boxes.