Saturday, 8 October 2022

Apple iPod (Third Gen)

 This is my Apple iPod, I have had it since 2007.

It normally lives in a silicon skin, hence it looks a bit dusty.

It is still in working order and I still use it.

Grab Bag Computer

This is my Raspberry Pi Zero 2 Grab Bag. Add a television with an HDMI socket and either a Ethernet socket or WiFi and you have a highly portable computer system.

The bag is an Oceanic Dive Gloves bag.

Inside is a Raspberry Pi Zero 2 in an official case; an HDMI cable; a Three Port USB Hub with Ethernet, a BB Q20 micro-keyboard; a micro USB cable (red)  for power; a USB-C data cable for the keyboard; a CAT 6 ethernet cable.


Sunday, 21 August 2022

Booting using a USB



Modern computers disable booting from USB or optical drives to prevent inadvertent booting from media left in the machine.

In theory this can be switched back on by restarting the machine and hitting F2/F10 repeatedly to get into the Boot Menu.

Except Windows has an interesting trick up its electronic sleeves to make your life difficult, Fast Start.

This makes getting to the boot menu impossible (it should make the machines start faster – but only for Windows values of faster).

However, the Fast Start can be turned off.

Either search for Power Options in the task bar or Start Settings and Power Management.

Select Choose what the power buttons do.

Under the Shutdown settings section, uncheck the box next to Turn on fast Startup (recommended).

Restart the machine and hit the F2/F10 key to get to the boot menu.

There is often a Boot order option, ensure that you have the USB device before the hard drive.

Once this is set, you may think you do not have to worry about this ever again. Microsoft has other ideas – if you boot to Windows and do an update, it will switch the Fast Startup back on again and once again you will not be able to boot from USB. Just follow the instructions again.


Saturday, 9 July 2022

CircuitPython and MicroPython - – start file differences

CircuitPython and MicroPython have many similarities, but there are some major differences.

One of the most fundamental are the names of the files executed when the board is powered up.

Start up sequence

MIcroPython 

MIcroPython looks for two files in a set order in the root of its filesystem.

  • boot.py – this file is run when power is first applied to the board or when the board is reset. Probably not of interest in general unless you are modifying MicroPython.
  • main.py – this is the file that is either your program or starts your program. If it is present, it is run after the code in the boot.py file.

CircuitPython

CircuitPython looks for the following files in this order:

  • •code.txt
  • •code.py
  • •main.txt
  • •main.py.

References

https://learn.adafruit.com/getting-started-with-raspberry-pi-pico-circuitpython/micropython-or-circuitpython

https://github.com/adafruit/circuitpython#differences-from-micropython

https://docs.circuitpython.org/en/latest/README.html#differences-from-micropython


Sunday, 20 February 2022

PICO Breakout Garden Base

The Pimoroni PICO Breakout Garden Base has a socket for a Raspberry Pi PICO (available from Pimoroni with headers pre-soldered) plus four I2C sockets and two SPI sockets compatible with the Pimoroni breakout garden breakouts. Pimoroni also do a Breakout Garden to QT/QWIIC adapter.



This allows soldering free development (assuming you buy the PICO with headers attached) and reuse of the various breakouts (with other PICOs including the Explorer Base or Raspberry Pis).

There are libraries for C++, MicroPython and Circuit Python.

Installation

Hardware

Breakout Garden Base, self adhesive feet and a Raspberry Pi PICO.
The printed paws on the underside show where the self adhesive feet go.


Before fitting the Raspberry Pi PICO to the Breakout Garden Base, I would recommend testing the PICO. The Blink program (that flashes the PICO's built in LED) is a good test.

The Breakout Garden Base has two rows of sockets to take the pins soldered to the Raspberry Pi PICO microcontroller. Match the orientation of the Pico with the drawing between the sockets and align the pins on the Raspberry Pi PICO with the holes in the sockets and gently and evenly apply pressure until the PICO is in place.

Software

To use the I2C and SPI sockets on the base, Pimoroni have created a custom UF2 file including the required drivers. Follow the instructions here: https://learn.pimoroni.com/tutorial/hel/getting-started-with-pico

If you find the latest Pimoroni UF2 version does not work as expected, use the Update Firmware option on Thonny to return to a vanilla flavour UF2 and reload the Blink example.

It might be that the latest version has introduced a bug in the Breakout Garden handling. Download and install an earlier version of the Pimoroni UF2.

It is very useful to add parts of the Blink example to your code when testing to show that the code is working.

There are examples for a number of the breakouts available.

1.3" SPI Colour Round LCD example in operation.

References

https://shop.pimoroni.com/products/pico-breakout-garden-base

https://shop.pimoroni.com/products/raspberry-pi-pico?variant=32402092326995

https://shop.pimoroni.com/collections/breakout-garden

https://shop.pimoroni.com/products/breakout-garden-to-qwiic-adaptor

https://en.wikipedia.org/wiki/I%C2%B2C

https://en.wikipedia.org/wiki/Serial_Peripheral_Interface

https://learn.pimoroni.com/tutorial/hel/getting-started-with-pico

https://github.com/pimoroni/pimoroni-pico/releases

https://github.com/pimoroni/pimoroni-pico/tree/main/micropython/examples




Sunday, 23 January 2022

Raspberry Pi Collection 2021

 It has been a while since I last showed off my collection of Raspberry Pi computers.

Left column:
Right column

This is not quite the full collection, the Raspberry Pi Zero with the official Raspberry Pi camera is, well not to hand.

Monday, 17 January 2022

Raspberry Pi Pico Explorer

The Raspberry Pi Pico Explorer is a plug-in board that provides a number of built-in devices including a 240x240 colour display, four buttons, a piezo buzzer, two I2S Breakout Garden sockets and sockets connected to the Pico's pins plus a small solderless breadboard.

A Raspberry Pi Pico with pre-soldered headers makes development easy without needing to solder delicate electronics.


Assembly was easy, care being taken to make sure all the pins aligned with the corresponding holes in the socket on the board.

Updating the Firmware

To use the components on the Explorer board, Pimoroni has created a custom UF2 file, including the required drivers. As of 03/01/2022 the latest version of the Pimoroni firmware (0.3.2) does not work, use version 0.3.1. This might not be the case for other boards.

Use the Update Firmware option on Thonny to return to a vanilla flavour and the Blink example if the current Pimoroni version does not work as expected. Select an earlier version of the UF2 and try again.

There is an example that measures the cpu temperature which is then displayed as text and a bar graph.
The next stage was to make use of the Breakout Garden sockets and add some breakout units. 
To provide some measurements, a BME680 environmental sensor was added to the right hand socket. In the left hand socket is a rotary encoder with a built in RGB LED.
The two sockets allow the addition of two breakouts. PIMORONI have a range of breakouts, including additional convertors that allow connection to STEMMA or Qwiic devices.

The BME680 breakout is an older model, the current version includes a built in STEMMA or Qwiic connector.
The example program was modified to get the temperature, pressure and humidity from the BME680 sensor plus the cpi temperature.

The code to set the encoder's RGB LED colour was also added.
The graph code was designed to display both the cpu temperature and the sensor temperature.

Finally a maximum and minimum sensor temperature was added to the display.

Code

Do check the indenting as Python uses the indenting to define the structure of the program.

import machine
import utime

from breakout_bme68x import BreakoutBME68X
from pimoroni_i2c import PimoroniI2C

PINS_BREAKOUT_GARDEN = {"sda": 4, "scl": 5}
PINS_PICO_EXPLORER = {"sda": 20, "scl": 21}

i2c = PimoroniI2C(**PINS_PICO_EXPLORER)

# Pico Explorer boilerplate
import picoexplorer as display
width = display.get_width()
height = display.get_height()
display_buffer = bytearray(width * height * 2)
display.init(display_buffer)

# BME68x configuration
bme = BreakoutBME68X(i2c)
#bme.configure(FILTER_COEFF_3, STANDBY_TIME_1000_MS, OVERSAMPLING_16X, OVERSAMPLING_2X, OVERSAMPLING_1X)

# reads from Pico's temp sensor and converts it into a more manageable number
sensor_temp = machine.ADC(4)
conversion_factor = 3.3 / (65535)

# Set up text areas
blockHeight = 33
textBlocks = 8
textArea=list()
for x in range(textBlocks):
    if(textBlocks>4):
        if(x<4):
            textArea.append([10,(blockHeight*x)+1,120,blockHeight])        
        else:
            textArea.append([120,(blockHeight*(x-4))+1,120,blockHeight])
    else:
        textArea.append([120,(blockHeight*x)+1,120,blockHeight])

# Set up background and text pens
background_pen = display.create_pen(0,0,0)
cpu_temp_pen = display.create_pen(255, 64, 64)
bme_temp_pen = display.create_pen(64, 255, 64)
pressure_pen = display.create_pen(64, 64, 255)
humidity_pen = display.create_pen(0, 255, 255)

# Define number of pixels for the graph points
graph_element_size = 1
graph_y_scale = 4

def drawTemp(i,cpu_temp,sensor_temp):
    diff = abs((cpu_temp*graph_element_size)-(sensor_temp*graph_element_size))
    if(diff<graph_element_size):
        display.set_pen(255,255,0)
        display.rectangle(i, height - (cpu_temp * graph_y_scale), graph_element_size,graph_element_size)
    else:
        display.set_pen(cpu_temp_pen)
        display.rectangle(i, height - (cpu_temp * graph_y_scale), graph_element_size,graph_element_size)
        display.set_pen(bme_temp_pen)
        display.rectangle(i, height - (int(sensor_temp) * graph_y_scale), graph_element_size,graph_element_size)
    
def writeInBlock(text, location, pen, paper, size):
    # Draw background to clear display area
    display.set_pen(paper)
    display.rectangle(location[0],location[1],location[2],location[3])
    # Write text in location one pixel left and down
    display.set_pen(pen)
    display.text(text, location[0]+1,location[1]+1,100,size)
    
# Initialise run variables
i = 0
count = 0
max_temp = 0
min_temp = 100

while True:
    # the following two lines do some maths to convert the number from the temp sensor into celsius
    reading = sensor_temp.read_u16() * conversion_factor
    temperature = round(27 - (reading - 0.706) / 0.001721)
    bmetemp, pressure, humidity, gas_resistance, status, gas_index, meas_index = bme.read()
    max_temp=max(max_temp,bmetemp)
    min_temp=min(min_temp,bmetemp)
    
    # Clear the display and reset counter if the graph reaches the right hand side
    if i >= (width + 1):
        i = 0
        display.set_pen(0, 0, 0)
        display.clear()

    # Draw graph element
    drawTemp(i,temperature,bmetemp)

    writeInBlock("{:.0f}".format(temperature) + "c", textArea[0],cpu_temp_pen,background_pen,4)
    writeInBlock("{:.0f}".format(bmetemp) + "c", textArea[1],bme_temp_pen,background_pen,4)
    writeInBlock("{:.0f}".format(pressure/1000) + "kPa", textArea[2],pressure_pen,background_pen,3)
    writeInBlock("{:.0f}".format(humidity)+"%", textArea[3],humidity_pen,background_pen,4)
    writeInBlock("Mx {:.0f}".format(max_temp) + "c", textArea[4],bme_temp_pen,background_pen,3)
    writeInBlock("Mn {:.0f}".format(min_temp) + "c", textArea[5],bme_temp_pen,background_pen,3)
    # time to update the display
    display.update()

    # waits for 5 seconds
    utime.sleep(1)

    # Set next graph element location
    i+=graph_element_size