Getting Started with Micro Python on ESP32


I got my little game working on the Raspberry Pi yesterday, and today I got to thinking how I could make it work on something a bit, er, cheaper. It’s not so much that I begrudge paying the price for the Pi, more that I can think of more demanding things to do with the Pi than just run the game. My thoughts turned to the ultra-cheap ESP32 devices that I’ve been playing with. The only snag is that I’ve written the entire game in Python for the Raspberry Pi, and I don’t fancy re-writing it in the C++ that these devices normally run.

So, why not run Pyhon on an ESP 32 device?

This turns out to be really easy. If you’ve installed ESP32 devices as part of your Arduino development environment you will have a useful little program called on your machine. To convert a device to Micro Python you just have to plug in one of those ultra-cheap devices, find out what serial port it is connected to (in my case com4) and then use the command below to program the chip with Micro Python. --chip esp32 --port com4 --baud 460800 write_flash -z 0x1000 micropython.bin

This loads the image in the file micropython.bin into the device. To get a Python image, go to the download site and look for ESP32 devices. I used the one in the file esp32-20190714-v1.11-146-g154062d9c.bin

Above you can see what happened when I ran the command.

Above you can see what happened when I ran the command.

When you restart your ESP32 you will be able to talk Python to it via a command prompt. That’s fine, but what you really want is an IDE that lets you write and deploy Python programs.

The best one I’ve found is called Thonny. It’s works with “normal” Python nicely enough, but it also has an option you can use to point it at an embedded device:


In the options menu above I’ve told Thonny to search for a device running MicroPython and connect to that. Now, when I run a program it is deployed into the device and executes from there.

The MicroPython installation provides a tiny filesystem that can hold python programs. When you run a program it is transferred into that filesystem and runs from there. There are two special program files on the device, and The program in the file is executed when the device powers up, followed by the one in The Thonny program has an option (in the Device menu) to save the program you are editing one of these files. This makes it really easy to make your Python program run when the device is powered up. I made my game program the one and now I have my original Python program running inside a device that only cost around a fiver.

It wasn’t quite as simple as just copying the files over. The api (application programmer interface) to use GPIO ports and Neopixels are different in the two devices and I discovered that MicroPython does not provide a random.shuffle method. This meant that I had to create my own shuffling function, which wasn’t too hard.

Anyhoo, I now have my program running in Python on a tiny embedded device. Which is rather nice. I’ll put the code up on GitHub later this week.

ESP32 powered webcam for 7 pounds


In my fingers above you can see something rather amazing. It’s an ESP32 powered webcam and it is priced at a stupidly low level. Mine arrived earlier this week and I’ve found a splendid howto that gets you started. You’ll need a serial interface to program the camera as it doesn’t have a usb connection. I used the one I got with some Arduino Pro-minis a while back. A couple of tips:

  • make sure you update to the latest version of the ESP32 board. The older camera sample will not compile.

  • the device can be a bit picky about power supplies. Mine gave “brownout” warnings for a while before I connected the 5V input to a slightly beefier supply than the 3.3V I used to program it

The camera serves up a website with a wealth of controls that you can use to change the image quality. You can use it to grab stills or watch a video stream. It even supports facial recognition and it has a micro-SD slot for saving stuff to. Amazing.


For the price you really should get one of these and have a play. I’ve been looking for a quick way to get pictures into Azure for training image recognition. I think I may have just found it.

Back Lit Tracing Screen


I’ve been taking pictures of devices for a course that I’m writing. I’ve been fretting about the way that it is hard to avoid shadows underneath components and wires. I wondered if a tracing screen would be any good at eliminating dark areas on the background. You can pick them up for not much money nowadays, so I bought one.

It’s not quite what I want, as you can see above the light is a lot of points rather than even. I’m trying to find a diffusor that give a nice even spread. However, this does mean that if I ever want to trace some pictures I’ve now got the perfect device.

Music to arrive to

I’ve been thinking about satnav systems and music players and I’ve decided that what would be really wonderful is a system which linked your navigation and your car music system together so that the currently playing track ends just as you turn into your drive at home.

This might be a bit tricky to arrange, but in theory the satnav knows when you’re going to arrive and could tell the music player to pick appropriate length tracks as you approach your destination.

I’m suggesting this because on the rare occasions when it happens to me I think it’s awesome. I’ve even been known to speed up or slow down slightly to make sure that it happens.

Using the Surface Go for Presentations


I didn’t plan to use my Surface Go for my presentations at the Black Marble Architecture Forum. It’s just that my Azure Function demo worked on the Go, but not on the Surface Pro that I was intending to take to Leeds. Something to do with Visual Studio needing an upgrade. But of course I didn’t have time to do that. So, I headed out to the venue, hoping that someone would have a way to get video out of the single usb c port that the Surface Go is fitted with.

Turns out that they could connect me up. The device above, from Dell, worked wonderfully. I reckon it is a perfect companion to the Go. It gives you three different kinds of video, VGA, DisplayPort and HDMI, along with USB, wired networking and a usb c port pass through. The cable is coiled niftily inside too. I plugged it into the Surface Go, got a solid video signal out into the projector and I was away.

Everything just worked. I had PowerPoint, Visual Studio Community edition and a bunch of browsers I was hopping between. Running up the Azure Function demo in Visual Studio just worked, and at a reasonable speed too. I even managed to use my old Surface Pen to remotely change the slides (although the battery in this is a bit tired, so I had to stay close to the computer).

I’d taken along my venerable old Surface wireless display adaptor that I bought years ago. It also works a treat on the Go but I didn’t need it thanks to the lovely little Dell device.

If you’re thinking of using the Surface Go as your portable presentation machine, just do it.

Tesla Testing at c4di


Good reason to be part of c4di number 493: Sometimes you get to drive a Tesla

Today was rather exciting. Tesla came to see us. I’m rubbish with names, and I didn’t write them down, but both fellows who turned up from the company were excellent, both in the talk that they gave to set the scene for the day, and also at the moment when they just said “Get in and drive it”.

So I did. I’ve already got an electric car so the smoothness and silence weren’t that much of a novelty. But the fact that I was manoeuvring a three ton car so easily was very impressive, as was the dashboard display of the vehicles around us as I nervously headed towards the A63. You could see little rendered versions of the cars and lorries in real time. This is a spin off of the self-drive technology and gives you a lot more confidence in traffic.

Dee settles in for his turn at the wheel…

Dee settles in for his turn at the wheel…

This being close to rush hour, the road was busy, reducing the opportunities for any attempts to realise the 0 to 60 potential of the car, which is apparently only five seconds or so. Dee had a go after I did, and he was a bit more lead footed than me, making the car really leap forwards. He also remembered to have a go with the automatic driving (which I rather stupidly forgot). This was very impressive. It followed the line of the road and kept the car nicely placed in the queue of stop-start traffic that we encountered on the way back to c4di.

Tesla have only been making cars for a few short years, and they’ve had to invent a lot of the technology that they are using. They have a plan, which is to start off catering for the more expensive end of the market before moving into the mainstream. As a quality car, for me the Tesla does the business. The inside was appropriately posh, comfortable and toy laden. It’s a bit on the large side for me personally, I find that the BMW i3 is just perfect for my needs just now, and I don’t really have the spare cash to spend on a toy that big. But I still rather want one.

And I’m not alone. Apparently they are selling more Teslas in the USA than they do BMW or Mercedes cars. During the talk in the morning we were told that Tesla is really just keen to get people living in a sustainable way. If that means getting other car manufacturers to make their own electric cars to compete with Tesla, they say they are OK with that. Well, all I can say is that the competition has its work cut out.

Big thanks to Tesla and c4di for setting up the day. It was awesome.

Cheap Power


I’m always on the lookout for cheap power. So I was intrigued by these phone battery packs in the pound shop in Hull. It turns out that they are actually quite usable if you need to power small electronic devices. I’m pretty sure that the advertised capacity of 1200 mAh is more than a bit optimistic, but I do know that a fully charged battery powered my “full fat” air quality sensor for well over two hours, which is good for demonstrations and the odd bit of remote sampling.

Apparently there are some that cost twice as much (that’s two pounds) which last around twice as long.

Switch Electronics in Hull

Don’t try clicking on the Add to Cart option…

Don’t try clicking on the Add to Cart option…

A while back I had the urge to own some cables that had crocodile clips on each end. They are very useful if only have two hands and you want to connect a bunch of things together. I found some in ebay at a good price, ordered them and they arrived in good time. Just what I wanted. Already found them useful.

Before I threw away the envelope I had a quick look at the accompanying slip. Turns out the company that sent them is based in Hull, around fifteen minutes from my house. I went there yesterday and bought a bunch of stuff.


Since the demise of Maplin I’ve been wondering where I’m going to get all the electronic bits and bobs that I occasionally have a need for. Buying from the internet is all very well, but it does introduce a bit of a delay into projects as you wait for them to arrive.

Well, Switch Electronics have solved all that for me. Their prices are pretty keen and they have lots of interesting components, even a special “Maker” section. If you’re based around Hull I’m sure you’ll find them very useful.

HP T6B82A Color LaserJet Pro MFP M281fdw

hp laser printer.PNG

I bought a colour laser printer many years ago. The plan was to avoid problems with ink jet cartridges where the ink evaporates and when you want to print something you find that the printer is dry. However, it was not a great success because it seemed to prefer chewing up paper to printing on it. So it ended up on the tip. I’ve still got a cyan cartridge refill for it lying around somewhere though, which serves as a memento of sorts I suppose.

Since then I’ve gone back to ink-jets. But they are a bit slow and since I’m finding more need to print things (Arduino notes for the c4di Hardware Group and HullPixelbot notes for robot builders) I thought it was time to take another look at lasers.

My needs were fairly simple. I wanted a colour printer that could print on both sides of the paper It had to work with all the devices around the house and it must not chew paper. The HP T6B82A Color LaserJet Pro MFP M281fdw (what a name) seemed to fit the bill, and it was available at a good price with the added bonus of 80 pounds cashback from HP. Which should just about pay for the first replacement toner cartridge.

Anyhoo, the printer arrived a week or so ago and so far it has been completely wonderful (he wrote - thereby damming himself and the printer for all eternity….). The print quality is great and the printer worked straight out of the box. No setup as such, just turn it on, enter the WiFi credentials on the tiny touch screen and then browse for it from Windows 10. Printing has come a long way since those days of driver disks and USB cables that weren’t in the box…

The printer will be expensive to feed in terms of toner, but I’m not going to print a huge amount. And the quality of picture printing is really impressive (at least to me). Much better than inkjets on standard paper. The printer has a scanner with a document feeder (single sided only though) and it can even be used to send faxes. Whatever they are.

If you’re after something with a bit more about it than inkjets I think it makes a really good buy.

Surface Go Review

surface go.PNG

When I finish writing a book I allow myself by buy a new computer. It's quite a thing for me. Last year, when I finished "Begin to Code with Python" I got myself an Apple iPad Pro. I was hoping to be able to use it to do proper work on the go. It has an OK keyboard and versions of most of the applications that I use. However, I found it impossible to use productively, over and above responding to emails. Simple actions such as copying values from one spreadsheet to another were taxing beyond belief. And of course, there was no way I could use it to write code. It's great for reading magazines and playing Zoo Keeper, but as a way getting something done, it sucks.

So, move forward to the latest book, the C# exam reference that has just gone to print. This time I've gone and bought myself a Surface Go. I got the bigger of the two versions available, with 128G of storage and 8G of ram. Both versions use a Pentium Gold processor, a model I've not heard of before. If the Surface Go used an Intel Atom processor I'd not have bought it. I've lost count of the number of Atom based computers that I've bought over the years. I was always tempted by the low price, but I was also always annoyed by the way that the things ran with the speed that custard flows uphill.

I'd read a few mixed reports of Surface Go performance, but enough people who I respect had said it was OK for me to take the plunge and part with cash. I needn't have worried. The Surface Go just works.  It gets there. If I compare it with my venerable, i7 powered, Surface 3 device it's like comparing the tortoise and the hare.

The Surface Pro 3, like the hare, sets of in a blaze of speed, and then, a few seconds later the fan comes on, the case gets hot, and things slow down to a much more sedentary level. Then a couple of hours after that the batteries go flat and everything stops.

The Surface Go tortoise sets of at a somewhat more sedate pace and maintains that until it gets there. There are no fans, nothing gets hot and nothing slows down. And the battery seems to go on for a lot longer. If you remember the story, you'll remember that the tortoise was the race winner. Enough said.

I've not bought and commissioned a new Windows computer for a very long time. The Surface Go "out of box" experience was very slick, involved Cortana, and had me working and connected to my Office 365 account in about ten minutes. Microsoft Office is already installed andI didn't need to copy all my files onto the small hard disk, just the ones I wanted to have with me all the time. All the rest will be automatically fetched when needed. Of course, there were updates, but these weren't too onerous.

The device arrived in Windows 10 "S" mode. This isn’t a separate version of Windows, its more like a safety catch that, when set, stops you from running anything other than programs from the Windows Store. However, this is easy to remove and in no time I was installing Visual Studio 2017, Visual Studio Code, Python, GitHub, the Arduino SDK and few other tools of the trade. All worked fine. Visual Studio 2017 is a beast of a program and, sure enough, large projects take a little while to load (around twice the time they do on my Surface Pro 3) but once they are open you can work on your code with a commendable lack of slowdown. I'm not going to use it with Lightroom or Photoshop because that's not what I got it for. Although, in a pinch, I reckon it could deliver if I was patient.

The Surface Go uses Windows Hello face recognition to log me in and while it isn’t quite as good as the one fitted to the iPhone X, it is properly useable. The screen is lovely. The sound is OK, within the limitations of speakers as small as they have to be to fit in such a tiny device. Battery like is OK too, nothing like the promised 9 hours, but good enough to remove any battery anxiety during a working day. It's also possible to charge the Go via its USB C socket, so I'm able to use my portable battery pack to top up the charge when out and about.

The keyboard is a smaller version of the lovely type cover on the Surface 3. I've just about got used to the smaller keys and I can type at good speed using it. If you're thinking of buying a Surface Go I'd strongly suggest you get the keyboard, along with an Office 365 subscription that gives you the use of the Office suite of programs and removes the need to have all your files on the device all of the time. I've paired my old Surface 3 pen with the Surface Go and discovered that the drawing and text entry experience is very, very, good. I reckon it's easily on a par with the Apple pencil on the iPad Pro.

I find that the Surface Go is a device that for me brings a bit of joy when you use it. The quality of manufacture and finish is the equal of much more expensive devices. Everything about it feels just right. It is the perfect size to take with you everywhere and has enough processing grunt to allow you to be useful when you get there. They say that the best camera is the one that you have with you at the time. By that yardstick the Surface Go is the best computer.

It's not that good for games though. Fortnite runs jerkily (although slightly better than on my Surface Pro 3). Graphically simpler games, for example Minecraft, run rather nicely. If the lack of Fortnite is making you think you need a more graphically powerful (and expensive) device like an iPad Pro my advice would be to get a Nintendo Switch with the price difference.

I think this is pretty much the perfect student device. Plenty of battery life, a workable processor, and access to proper productivity. You also get premium finish and the ability to be used as a tablet. And a genuinely pleasant user experience. It's a really nice feeling to have a tiny machine with you that you know can be used to turn out some proper work. If you're thinking about getting a little portable computer you really should take a look at the Surface Go. The girl in PC World was saying that they're selling quite a few Surface devices these days. I can see why.  

Smart Meter Time

Suitably redacted....

Suitably redacted....

I've probably missed a trick here. I got a message a while back offering a smart meter for my electricity and I said yes. I didn't know that the energy companies were still installing the "old new technology" smart meters. According to what I'd read a while back, by this time everyone would be getting the new type, but for some reason (perhaps because it makes it harder to change energy suppliers without losing meter "smartness") the old-new meters are still being rolled out. And I've ended up with one.

It seems typical of the way that things are presently working in this country that an initiative that is supposed to bring us to the forefront of energy management has been sabotaged right from the start by short sighted decision making driven by commercial interests. Not that I'm particularly worried. The way I see it, if I'm in the 9 million who've got the old meters there's a lot of incentive for companies to make us happy in the future.

I reckon it's quite possible that the potential of the second generation of meters will never be realised because nobody will bother implementing the back end services to make them work. They'll just claim that there aren't enough of them out there to make it worthwhile. Yes, that is very cynical. And probably right. And anyway, the firmware in my meter is upgradeable......

Anyhoo, the meter is now in place and beaming my electricity usage to a remarkably cheap looking device that lets me see what happens when I use the kettle. It is supposed to motivate me to save power, but the first thing I wanted to find out was how far into the red I could send the readout by turning things on.....

Apple Homepod Review


One of the nice things about being a writer is that every now and then you get a note saying that a bunch of people have bought copies of your book and, as a result, you've got some money to spend. It doesn't happen to me as much as I would like, but it did happen last week. 

And so, of course, I used some of it to buy myself an Apple HomePod. What with there being one for sale second hand in a local shop, and me having come into a bit of cash, it seemed like fate was actually willing me to get one. 

I'm glad I did. I've got a couple of Amazon Echo devices and I thought that their sound quality was OK. But the HomePod blows them, and just about anything else I've got, away in terms of sound quality. It's far, far, better than the speaker and sub-woofer setup I have in my working room and has therefore completely replaced it. There is a lot more bass present than there has any right to be. It's actually quite startling.

Some reviewers have talked about the impressively wide sound stage that the speaker manages to create using its assortment of drivers and cunning calibration. I've not noticed this much to be honest. The output sounds like it is coming out of a speaker. But what output....

The setup was a breeze. I just held my phone close to the HomePod the first time I powered it on, tapped Yes to confirm access and away we went. It did such a good job of finding the best tracks in my music collection that I let it do that for around eight hours before I actually asked it to play anything specific. 

Voice control is not as great as it could be. It doesn't understand the artist name "Boz Scaggs" at all. I had to ask for the album by name from my library in the end. And saying "Hey Siri" is not how I like to start any kind of conversation. And when I do every single Apple device in the room pricks up its ears. The computer generated voice of the device is not a refined as Alexa from Amazon. I've gone for the Australian female voice as this sounds the least strange to me. Or perhaps I can't actually tell whether its strange or not. 

I've not used the HomePod for much more than playing music. I will tell me the weather and If I get some remotely controlled kit it should be able to control it. I've got an Apple Music subscription, which makes it a proper free-standing device. Otherwise I'd have to use my phone to get the audio source and play it over Airplay. I've not tried the HomePod as a speakerphone yet. It works in this role, but not in a way that you'll find particularly useful. 

From a software point of view it is a bit limited at the moment. There is a serious shortage of third party skill and, unlike the Amazon Echo, I can't use it to listen to the radio, which is a shame. 

However, it is what I thought it would be when I bought it. It is a super, super, speaker with some indifferent network features and a whole ton of room for improvement. I just hope enough people engage with the product to make Apple fulfil its true potential. Until then I'll be very happy listening to the amazing sounds it makes. 

A Dashboard Camera for 10 quid. What could go wrong?

One of my New Years resolutions should have been "I must stop buying cheap and useless gadgets".  But since I haven't made that resolution, and I found myself in the local grocers looking at the bits and bobs on offer, I ended up buying a little dashboard camera for a tenner. 

It comes with a mounting for your windscreen, a power connector and even a little lithium battery so it can be used away from the car (I want to attach it to a Hull Pixelbot). 

It works really well. The camera is reasonable quality, the controls a bit clanky, there's some HF whistle (which I can't hear) when it's switched on. But overall a win. 

Except for one tiny flaw that I've yet to resolve. You need to add an SD card which is used to store the video. When I take the card out of the camera and try to use it in my computer the files on it are not recognised. I hope it isn't using "write only memory" technology. 

The Ring Doorbell and WiFi problems

ring doorbell.PNG

Some time back I got a Ring doorbell. It's an internet connected door chime that contains a camera and motion sensor. When someone rings your doorbell (or stands on your doorstep if you've turned on the motion sensor) your phone (or your Apple watch) goes ping to alert you. 

The doorbell also contains a speaker and a microphone, so you can have a conversation with the person at your door. And for a small sum you can have videos of all your visitors stored in the cloud for later review. 

It works really well. I knew I was onto a winner when number one wife used it to accept delivery of a rug while we were away in Leeds.

Then today, right in the middle of a conference call, I heard someone hammering on the door. I shot downstairs, retrieved the package and started to wonder why my lovely doorbell hadn't told me there was someone on the doorstep. Both it and the sounder in the house had fallen off the network. 

This illustrates a problem with these lovely, connected appliances. They're as good as their connectivity. Wah. So I started digging. And the solution is a bit disturbing. 

My WiFi router has been set to automatically select the quietest WiFi channel. When I reset it on Monday the router had gone and picked channel 13. 

This was a rather stupid choice as far as the Ring doorbell is concerned, as it only supports channels up to number 11. The result was that the doorbell fell off the network. Unfortunately, because nobody had pressed my doorbell (or, at least nobody I'd heard had pressed my doorbell) I had no way of knowing things were broken.

The doorbell "phones home" once a day, and I guess after a while I'd get a message that something was broken, but until then I'd be missing callers.

The rather important moral to this story is that if you have a connected appliance like this, check, your router settings to make sure that it is using a fixed channel in the range 1-11. If you allow the router to pick a channel in the range 1-13 there is a chance that a bunch of your networked devices might suddenly stop working.

Of course once I'd picked a likely channel I then had to boil a jug of water in the microwave oven to make sure that it didn't interfere with WiFi reception in the kitchen. For me it turns out that channel 4 fails when I'm heating things up, but channel 11 works fine. 

Properly Broken Device

26432885109_c06215d956_z (1).jpg

Last week I wrote about "The Broken Device Dilemma", when something you hardly use breaks. Do you try and fix it, or do you throw it away? Of course, if you're me you try and fix it. It's all about the journey. Right?

Anyhoo, my lovely little Sony audio player failed. The battery refused to accept any charge.  It was as if the cable was broken. Of course, being Sony, it's a special cable, not a standard usb one. The good news is that replacements are very cheap, so I got one. 

It didn't work. 

However, playing with the device left me thinking that the battery was broken. This happens with Lithium Ion batteries. So, it was onto eBay to source a battery. I managed to find one, ordered it and it arrived today. Fitting it was great fun. Number one son found the service manual and I had a happy half hour this evening undoing sticky fixers and soldering the replacement battery in. 

It worked. Yay!

The player woke up and played some music at me. Great stuff. But it did seem to get very warm. And then the WiFi stopped working. And then the battery failed. And now it behaves just like it did at the start of this story. Oh well. It looks like something in the player has failed and is taking so much power that that the charging circuit can't keep up. So I think it is properly broken. 

Oh well. Now I have to ask myself the question "If a device you hardly use breaks, to you replace it?....."

Remote Harmony

harmony remotes.JPG

Today I spent a little while sorting out the remote control for the telly. I bought this fancy Harmony Remote a while ago in a second hand shop and I think it has turned out to be quite a bargain. I've used Harmony remote controls for a very long time and I've round that they work very well, within the limitations of a totally open loop control system, where the remote just pumps out an infra-red message and has no way of knowing if it has been received or not.

Anyhoo, configuring the remotes is something I don't do often enough to be able to remember all the steps involved. But I do know that I'll have to download a program and then plug the remote control into the computer. I'm using a version of Windows that is several on from the one for which the program was created. I'm installing a USB driver that was written ages ago. I'm using TVs and devices that are comparatively recent. And yet it all worked. The Logitech servers even remembered the settings from last time (because I'd put my Logitech username and password into Password Padlock). Now I can turn on the TV with a single touch.Very impressive.