Accentuate the negative
/Finally tested negative for Covid today. Celebrated by going out for a coffee and bun. Very nice.
Rob Miles on the web. Also available in Real Life (tm)
Finally tested negative for Covid today. Celebrated by going out for a coffee and bun. Very nice.
A while back I ordered an awesome little laser rangefinder. It arrived last week and I’ve found an excellent holder for it which I can use on my 3D printed camera. I printed the holder this morning and above you can see my fully tricked out camera. It has a viewfinder, level and now a range finder. It might only be able to take one picture at a time, but it certainly looks the part.
I spent a big chunk of today trying to work out why my software was putting two entries into the database whenever a device connected to the system. I’m adding logging so that I can detect if a device is resetting more than it should. After commenting out lumps of code and generally getting very confused I eventually worked out that as well as the test code running on my PC there was of course also a version of my system running in the cloud. So it was responding to device messages and writing to the database alongside the code running on my machine. I think I need separate development and test databases……
Last week I made it very easy to load Connected Little Boxes firmware into a device. Today I spent some time making it easy to configure the device too.
The form on the left shows how you configure the connection to the neopixels. The values have been pulled from the device over a serial connection. The user can edit them and then save them back into the device and test it.
I’m going to make a bunch of videos explaining how this all works and then deploy the server for anyone to have a go. Should be fun.
I was hoping that by now I might be clear of this nasty Covid thing, but a test today put paid to any hopes in that direction. Oh well. Back to the coding.
This is one of my “I’m putting something into the blog so that I can find it in a couple of years when I need to do this again” posts. I’m doing some work on the Connected Little Boxes website and I've been deploying the latest version. This one automatically configures a device by downloading setting information from the cloud. Code running inside the browser gets the settings from the server and then sends them into the device. To make this work the code in the browser needs to know the url of the server based data source. When I’m developing the program this will be on the localhost (my pc) and when the code is deployed the data source is the server in the cloud.
I’ve put this information in an environment variable. I have a local .env file that holds the local address. I’ve then put the deployed host address in the environment variable in the cloud. This works a treat, but I do have one problem. How do I get the value of this environment variable into the JavaScript code running in the browser? I’m using an Express web page to hold the web page source and I can embed JavaScript into the HTML but I don’t seem to be able to embed JavaScript elements into the <script> parts of the page. Probably because doing this kind if thing might disrupt the space-time continuum. So, I’ve done this… Below you can see the statement that renders the createDevice.ejs page. I pass this statement the HOST_ADDRESS environment variable that I want to feed into the JavaScript code in the createDevice.ejs page:
res.render("createDevice.ejs", { name: res.user.name, host: process.env.HOST_ADDRESS });
When the page is loaded the name and host variables are loaded with values supplied to the render method. Now, I pick those up inside the HTML and pass them into the page initialise function:
<body onload= "doStart('<%= host %>');" >
The HTML above specifies that a function called dostart will be called, and supplied with the value of host as a parameter. This is the environment variable that I want to use as the base url for my server requests.
function doStart(host) {
console.log("starting");
hostAddress = host;
settingsURL = hostAddress + "createDevice/networkSettings.json"
selectStage(stages.ConnectUSB);
}
Above is the doStart function. It sets hostAddress with the base url for all requests and then uses this value to build the settingsURL that is used to fetch settings information from the host. It works a treat. When I run the application on my local PC the url is set to the local host and when it runs in the cloud the address is set to the cloud location. There is probably a much easier way of doing this which I don’t know about, but I’m still quite pleased with making this work myself.
This has been a weird week. What with having a visitor who, thanks to the “Magic of Covid” I’m not allowed to be in the same room as. Anyhoo, one way we have found to get around this is to play video games. The game “Left 4 Dead” was suggested as a way we could get together and play games without mixing too much, and so it has turned out. The game came out in 2009 and so it runs handily on most everything, including the Steamdeck and my rather elderly PC.
We’ve been having a great time running round shooting zombies and working our way through the levels. We’re playing in a team of 4 with two computer powered players and it works a treat. Your teammates are helpful and not at all silly. The dialogue is nicely done and the environments are large and challenging. There is lot of fun to be had in older games and you can pick this up for around 8 pounds on Steam. Well worth it for zombie slaying fun.
A while back I made a MicroWriter keyboard which lets you input text by entering chords on six input keys. It worked very well, but it emulated a wired keyboard. Now that the Raspberry Pi PICO can now talk Bluetooth I’ve started working on a wireless version. I’m going to have a go at designing my own PCB for it. I’ve bought some sockets for the keys. And some keys.
My original keyboard code is written in Circuit Python but there is no Python support for Bluetooth on the PICO just yet. My plan is to convert the code to C++. This shouldn’t be too hard. Most of the work is in the character decoding arrays.
I’ve invested in another camera. Well, I say invested. I won’t find out whether or not it was an investment until I try to sell it again. Which, given the quality of the pictures it produces is not going to be any time soon. It’s a Kiev 60 which takes medium format images on 120 roll film. I can develop the pictures at home (as I did the one above).
I think they had two production lines in the factory. One made tanks and the other the Kiev 60. And sometimes they got the parts mixed up. It is a huge device and somewhat heavy. Everything works (which is something of a rarity for this particular brand) and the combination of large negative size and old-school lens design makes for some lovely out of focus effects. I’m going to enjoy carrying this around and taking some pictures over summer. But I may need to get in some weight lifting training first.
The worst kind of bug is the one which is not there. I spent a big chunk of today trying to figure out why MQTT settings weren’t being transferred correctly from the server into my embedded device. The idea is that you plug a brand new ESP8266 or ESP32 powered device your computer, visit the Connected Little Boxes website and all the firmware and settings are loaded into the device automagically. It was working fine with test messages, but not when I tried to use it to actually connect a device.
I built more complex tests, added diagnostics and still the system didn’t work. I was getting more and more confused until I realised one of the messages that I was sending had the wrong thing in it. In other words the transport mechanism was fine but because of a formatting error the setting wouldn’t work in the device. Silly me.
I’m not too unhappy though. The code is now a lot more tested than it was, and it has some diagnostic output which will be useful at some point. And it does indeed work now. The only thing you have to do is enter your WiFi credentials into the webpage so that the device can connect to the network. The device is configured and then added to the list of devices that you own. The next step is to add configuration pages for the internal device interfaces so that owners can make them into lights, buttons, dials, inputs, displays or whatever.
The new kitchen bin arrived today. The old one broke and the type of replacement was the subject of some heated discussion. At one stage I said “But I’m not sure any of these will do exactly what we want” to which the reply was “But at the moment we don’t have a bin”. Fair point. It is always important to remember that with some things, including bins, the perfect is the enemy of the good.
We got the new bin out of the box and put it in the kitchen. It’s perfect.
Last week I discovered that ChatGPT can write “In the style of Rob Miles”. I’m not sure if it will do this for everyone. The internet creates bubbles of personalisation so that our searches find the kinds of things that we like, and perhaps ChatGPT does that too. Perhaps if you ask for something “in the style of Rob Miles” you’ll get the version that fits with your interests. Even so, ChatGPT knows about a version of me.
ChatGPT knows me because I’ve been blogging and posting stuff for over 20 years. There’s a lot of Rob on the internet. Although I must admit that all those years ago when I decided to put up a blog post every day I didn’t think that it would be a step on the road to creating a computerised copy.
It is a tiny bit worrying. Do I need to exist any more, now that there is a freely available version online? People have been known to pay me to write things “in the style of Rob Miles” but now anyone can do it. Where will this lead? Folks might get ChatGPT to write horrible things in my style. Even worse, they might get paid instead of me. When I put my blog up I don’t remember ticking a box that said “I allow companies obsessed with shareholder value to mine this data and use it to create machines that can imitate me.” Oh well. Welcome to the modern world. It is a form of immortality I suppose. At least until ChatGPT finds a better Rob Miles
Number one wife has just tested positive for Covid. Now there’s even more of it about. But at least we can now sit together and compare symptoms.
Today all I’ve felt like doing is sitting and reading. I’m revisiting a series of books I first read years ago, and I’m enjoying them just as much second time round. They are by Jasper Fforde. They are about a time travelling crime fighter who can also go and live in books. She’s called Thursday Next (all the character names are fantastic) and she lives in a parallel reality (I probably should have mentioned that first).
Anyhoo, the books are a riot and incredibly clever. If you are missing Douglas Adams or Harry Harrison you really should take a look. You can find the first episode here. Jasper Fford also has a splendid website (all hand coded by the author in HTML - respect) which you can find here.
I had lots of plans for the next week or so. None of which included catching Covid. But there you are. Apparently there is a lot of it about at the moment. I’m the only person in the family who has tested positive so far, which means that I’m confined to upstairs and can only eat things which can be slid under the door. Fortunately I like pizza. The good news is that I’m getting a lot of code written at the moment.
This month’s edition of HackSpace magazine is now out. It’s in the shops, or you can find it here. It’s contains a review wot I wrote of Spintronics. I’ve also made it into their Toys & Games item with TagJousts.
The magazine is, as always, a great read. There is nothing else on the market which has such a broad coverage of interesting stuff, from detailed descriptions of hardware and software projects to 3D printed guitars.
Yesterday I took my 3D printed camera around to see Ian and attempted to take his portrait. As you do. I’m still working on my focussing technique, and so what I ended up with was a slightly blurred Ian but a remarkably sharp windowsill behind him. Look at the detail on that M&Ms bag…
I don’t know what kind of a day you’ve had. Me, I’m just happy that my picture of a duck came out.
I’ve made a tiny video about the videos I’ve made about Begin to Code: Building Apps and Games for the Cloud. This one gives you a look at the kind of things that we do.
Good grief. That is truly scary. I’ll get my coat…..
Rob Miles is technology author and educator who spent many years as a lecturer in Computer Science at the University of Hull. He is also a Microsoft Developer Technologies MVP. He is into technology, teaching and photography. He is the author of the World Famous C# Yellow Book and almost as handsome as he thinks he is.