The Photography and Video Show

I don’t have any pictures because I need to get the film developed….

Today finds us at the Photography and Video Show in the National Exhibition Centre (NEC). I’ve not been before. It’s awesome. Loads of familiar brands plus a whole bunch of other interesting stuff. My favourite stand was the Disabled Photographers Society. They collect donations over the year and then put them all up for sale at the show. So there were lots of old cameras to root through.

A little dusty but otherwise perfect

I found the Pentax ProgramA you can see above. This dates from around 1980. I’ve no idea if it works. It was one of the first “battery only” cameras and it won’t do anything until you give it a couple of LR44 cells. I’ll find out when I get home whether or not it works.

Next year the show will be in London rather than Birmingham. I’m definitely going to try to get there though, it was great fun.

Update: I got the camera home, popped in a couple of batteries and everything seems to do what it should. So the next step is to pop a film in it.

Making "The Exchange" - an AI you an ring up

Perhaps when I’ve built it I can ask it why it doesn’t work…

I hate it when things in a project go too well. It usually means that things are due to go not very well in a short while. I’ve got my Large Language Model running on a Pi 5 and I thought I’d use this to create “The Exchange”. This will work with “The Red Telephone”. The idea is that you pick up the receiver on your telephone and dial a “3”. A robotic voice asks you to state your business. You give your question and then put the receiver down. After a decent interval “The Exchange” rings back with the answer.

To make this work the phone needs to capture audio input from the phone, use speech to text to get the question text and send this to the Large Language Model Pi 5. The Pi 5 will respond with the answer and I can use the text to speech in the red phone to deliver the answer. Sounds simple enough.

I’ve found this lovely library which can run on the Raspberry Pi Zero in the phone and convert speech to text. It’s a bit slow, but I don’t care about that because I can record the question and then use speech to text on recorded sound file after the user has rung off. So the next thing I need to do is find something I can use to record audio into the Pi. Up pops https://www.npmjs.com/package/node-record-lpcm16 and that works a treat too. At this point my spidey sense is tingling a bit because things are going too well.

So I start to build the program. I write the code that tells the user to state their question and then records their response. It’s bound to work because I’ve tested it. But of course it doesn’t. The speech playback (using eSpeak) works a treat but the audio recorder fails because it can’t find the input device. Everything works fine individually. The only time it fails is when I ask it to do what I want it to do. I get this a lot when writing software.

I do have a fix though. If I run the whole application as a super-user it works. I’ve no idea what the speech generator is doing with the sound device, but giving the sound recorder awesome system powers seems to enable it to find a sound input device and make a recording.

I’ve spent a bit more time investigating the problem. I’ve added a timeout after the speech output finishes to give it time to release resources. I’ve tried different device names rather than the default one. But nothing works.

It’s not a huge problem if the application has to run as supervisor I suppose (although I’m not a fan of this approach). And I consider “Because it works that way” a perfectly reasonable answer to the question “Why have you done it that way?”. So I’m going to pop the question on the back burner for now and carry on.

Start your node.js applications when your Raspberry Pi boots

Spring is coming…

If you’ve got an application (perhaps one that lives inside a red telephone) which you want to run when your machine boots there is a really good way to do this. You turn your application into a service. You can make your application start when the Pi boots and you can also start and stop the application from the command line.

We can use the systemd to this for us. This orchestrates the startup and management of services. To use it with a Node.js application, we create a systemd service unit file.

Start your editor of choice and create a file named redserver.service (if you’re controlling a red telephone - otherwise use a more meaningful name) within the /etc/systemd/system/ directory. This file defines a service for systemd to manage.

[Unit]
Description=Red Phone Server/home/rob/RaspberryPi-DialTelephone
After=network.target

[Service]
ExecStart=/usr/bin/node /home/rob/RaspberryPi-DialTelephone/redserver.js
WorkingDirectory=/home/rob/RaspberryPi-DialTelephone
Restart=on-failure
User=rob

[Install]
WantedBy=multi-user.target

Note that the file sets the working directory for the application and specifies the command that starts the service. You can now enable and start your service with the following commands:

sudo systemctl enable redserver
sudo systemctl start redserver

The service will now run each time the Pi boots. You can use systemctl to stop the service. This is useful if you want to debug the service - things don’t normally go well if you have two copies of the thing running…

sudo systemctl stop redserver

If you want to restart the service you just start it again.

sudo systemctl start myapp

If you ever want to disable the service completely and stop it running when the system boots you can use this:

sudo systemctl disable myapp

I’ve found this very useful. So useful that I’ve made a blog post so that I can find it again later…

Free Hull Pixelbots at March 20th Hardware Meetup

If too many folks turn up will run a draw for these

Thanks to the generosity of “Player Piano Ross” we have some Hull Pixelbots to give away at the next Hardware Meetup at the Hull Makerspace at Central Library Hull. The meetup is on Wednesday 20th March and will start at 5:30 pm and continue until around 7:00pm. We are going to spend some time doing “Robot Training” with a little obstacle course we’ll try to program our way around.

The long term aim is to swap out the existing Arduino Uno controllers on the robots and replace them with Raspberry Pi Picos. This will let us run Python on the devices and program them over Wi-Fi. For the session on the 20th we’ll be using Python-ish and connecting our robots over RS232. I’m going to bring a few original pixelbots including Crystal Masie and Captain Black. It would be lovely to see you there. Bring your laptop, some AA batteries and a winning smile.

And you might get a free robot of your own.

Running a Large Language Model on a Raspberry Pi 5

I never said it was perfect

I found this article which describes how you can get a something a bit like ChatGPT running on a Raspberry Pi. You need the latest Raspberry Pi 5, and it also needs the largest one with 8Gb of memory but it does work. It’s a bit slow and not very accurate, but it is fun to chat with. I think it is very useful to show slightly broken versions of the technology to folks so that they start to understand their limitations.

I’m now very tempted to make an “exchange” for the Red Phone which runs this engine and rings you back with answers to questions.

Finding Serial Ports in Python on the Raspberry Pi

Nothing to do with the post. But another picture I like

One of the more annoying quirks of using usb serial ports is that they move about a bit. The precise port that you get when you plug the same device into your computer is subject to change. This can be annoying; particularly if you want to make something that just works. With all that in mind I present this:

def get_port(self, portNames):
result = None
for portName in portNames:
    try:
        print("Connecting to " + portName)
        result = serial.Serial(portName, 115200)
        print("    Connected")
        return result
    except :
        print("    Connect failed to " + portName)
return result

The get_port function is given a list of ports that might have something behind them. It then works through the list trying each one and returns either a port that worked or None.

ports = ["/dev/ttyACM0","/dev/ttyACM1","/dev/ttyACM2"]
serial_port = self.get_port(ports)

You call it as shown above. The ports variable contains a list of addresses. When the function completes it will either have a useable port or None. I’ve found it quite useful.

Musical Meetup Fun

We had a fair amount of hardware to play with

We had a lovely meetup this evening, greatly enlivened by some newcomers keen to learn stuff. The theme was musical and so we had a few devices to play with including my Chocolate Synthbox, a Synthstrom Deluge, an Organelle, a Norns Shield and Tenori-On. Much fun was had, with plenty of clicks, beeps and musical-ish sounds beating out.

We had some wonderful chats about ChatGPT, air quality, how a piano works (and how to mechanise it), lithophanes, HueForge and of course robots.

There was so much interest in Hull Pixelbots that we’ve decided to get together and build a bunch. We’ll be meeting up in two weeks (20th March) at 5:30pm in Hull MakerSpace and having a go. I’ll be publishing a shopping of list of parts soon. If you want to go on the mailing list for the Meetup send an email to addmetothelist@hullpixelbot.com

Dead Mouse

I don’t think it was my mending that broke it

My mouse has broken. I’ve had it ages. It’s a Microsoft Sculpt Comfort mouse and I really like it. Everything works but the scroll wheel. This has happened before so I took it apart and cleaned it. And it is still broken. This is a big thing. I’ve had it for ages. It came with a keyboard/mouse pack from which the keyboard has long gone. I’m now making do with a flat mouse and looking at horribly expensive “new-old” stock.

Pro tip. If you find a keyboard or a mouse that you really like you should buy a couple of them and pop one away for the future….

Speaker Wisdom at DDD North

This picture has nothing to do with the subject of this post. I just like how it came out.

One of the best bits of DDD yesterday was getting together with some students to talk about plans for the future. Boss had organised a bunch of speakers to have a word with a bunch of students. For me it was great to hear folks echoing what I used to tell students all those years ago. All of the speakers had great stories and I chipped in occasionally too. But I think all the advice can really be summed up very simply:

Do stuff and tell people about it.

People who might fancy hiring you will expect you to have completed your studies successfully. But if the only “war stories” that you have to tell are about your assessments you will find yourself at a disadvantage. You need to have other things you have made, done or failed at to talk about. And they don’t necessarily have to be in software. You should form a policy of finding things to do and ways in which you can use them to your advantage. If you take care of that you might find that your future will take care of itself.

Talking ChatGPT at DDD North 2024

A great audience here in black and white

Did my talk at DDD 2024 this morning. After a brief panic where it turned out that my HDMI adapter wouldn’t talk to the video system I managed to get everything working (thanks Warren for lending a working adapter). The audience was great and we had a splendid discussion afterwards. You can find the slide deck here.

Musical Hardware Meetup March 6th

I’ll be keeping the lid on though

Our monthly hardware meetup for March will be on Wednesday 6th March in the MakerSpace at the top of Hull Central Library. We start around 5:30 pm and then go on until 7:00 pm or so. We theme the meetups, the March one is all about music. I’ll bring along the MIDI CheeseBox, Crackers Controller and Chocolate Synth along with a few more conventional devices. If you’ve got something you want to show off or talk about, feel free to bring it along.

No need to sign in or anything, just turn up and take part. It would be lovely to see you.

Robot Power Adapter

Very useful if you kept buying 12v power adapters instead of 5V power adapters….

One of our students showed me a useful gadget today. You can plug a 12 supply into it and get out 5v, 3.3v and the 12v going in. The two onboard regulators aren’t good for particularly high currents at around 800ma each, but this is a terribly useful controller if you are building a robot and want 12 for the motors and then the other voltages for your onboard devices.