Back in 2016 I posted how there really was not enough information for anyone to vote on the referendum to leave the EU. How could members of the public make any sort of informed decision.

We are now way down the line, and things are sadly only slightly better.

I am amazed how this has polarised the country. Even people in "my bubble" can be massively Brexit still and there is no reasoning with them. And so much disinformation still exists, even now where Boris Johnson said we could ban Shark Fin Soup if we left the EU. WTF is that as an argument? Who cares about Shark Fin Soup?! From what I can tell it is either "not true, WTO rules means you can't ban it", or "true, WTO rules have an exception, but that means we can ban it now even in the EU". Still the mad sound bites of disinformation persist even three years later.

Is change good?

If you are a good businessman then change can always been good - you can always exploit it. Even when you look at war and the blitz spirit (as has been evoked regarding Brexit?!) there were "businessmen" that made money (and were illegal as black market traders). Imagine in the blitz, in an air-raid shelter and bombs dropping - we survived. But imagine if 52% of people in there voted for the bombs?

And if you know a change will happen you can be even better at exploiting it. It is coming out how some people in politics have direct personal gain linked to Brexit. Scary.

But "good" for some careful businessmen will always be "bad" for someone. That money they make comes from somewhere.

In my personal view I cannot see Brexit being good for the UK overall. It seems counter intuitive to be isolationist, and then still want to trade with the world.

Personally, I am hoping that I am finally doing well enough in business that I, and my family, can cope. But that is by no means certain, and I am scared! Even if it was the case, I would not wish the hardship that will ensue on everyone else, whether my friends, my staff (also friends), my customers (also many friends), or anyone else.


One of the huge issues is uncertainty.

A50 can be revoked, or delayed, so nobody knows for sure what will happen right up to the wire!

We cannot have this again - we need the A50 process to be 100% certain, no delays and no extensions, and no way to revoke. A country leaving EU makes one decision to do so and then has time to make it happen, and that is it. That needs to be the case even if the UK decides, again, to leave.

What we have now is hugely damaging, maybe more so than having left already!

As EU members we should change the A50 process to fix this!

We import from China!

What interested me was comments from a close friend. Smart chap. We make products that use chips that come from outside the EU, like China. The comment is that Brexit is therefore not so much of an issue, surely.

But we (UK) don't import from China, we (EU) do. So when we Brexit, we (UK) have to have the trade agreement to import those parts to UK (not EU). Is that in place? - well I don't think so, even after many years.

It is so easy for anyone, even smart people, to miss some of these obvious details. Brexit is not simple.

[I am not sure China is necessarily the best example, but assuming just because we trade with a non EU country before Brexit does not mean we, as the UK, have a trade deal to allow trade after Brexit. It needs negotiating. The government claim to have managed to negotiate several "continuation" deals already, which is a good start, but they needed negotiating, and more are needed still, they are not just what automatically happens when we Brexit, which is what people were assuming.]

Will of the people!

This is perhaps the most annoying part! We accept people can change their minds as we have a general election every few years, but somehow Brexit is a "fixed point in time" (DrWho?).

In fact that the referendum was a "poll" (as stated in the legislation). It was not a mandate. And then it was (as decided by courts) conducted outside the legal constraints for such campaigns. Had it been a mandate it would have been struck down, and was not only because it was just a poll.

As I said in my 2016 blog post, I did not know what was the right way to vote. I voted to remain, but I did not do that as an informed decision by any means.

Now, we have some clues on the issues with disentangling the UK from the EU. At best we have some good deal with EU - but such a deal means we have to abide by a lot of EU law on the way we do things with no say in such law! The alternative is not having a good deal, which is worse.

We have the crazy situation now that calls for a "people's vote" are called out as undemocratic. The idea that asking the "people" to vote on this is not democratic is, well, mental!

We also have the issue that this is "one sided". We leave, and no way we ever re-join on anything like he deal we have now. We stay, and we can vote to leave again in a few years if the EU goes OTT and we don't like it. So leaving is a "really really sure you want to do this" type of thing.

Breaking the deadlock!

I see the only way to resolve this is something that everyone can see is the (current) "will of the people", such as another referendum or a general election fought on the Brexit issue. Only then can anyone say, again, "you lost, get over it".

That will still be bad. A lot of people convinced that Brexit is right will be cross. I don't know what to say. I have yet to find a single person who can explain the benefit of leaving!

I do feel that if Brexit is cancelled, whatever government we have will need to make a big issue of "why Brexit". They need to tackle each and every one of the reasons Brexiters wanted to leave, in detail, and with actual change. Some things are simple (blue passports), and some are not so simple, but they all need addressing. I feel we can sort the underlying issues and stay in the EU. Why not?

Bad EU laws?

But are there bad EU laws we don't want?

Yes, absolutely, there are laws that, in my view, go too far, or get it wrong. Not least of which was the damn cookie stuff creating those damn cookie consent warnings on every damn web site! That was technically stupid in so many ways, and I am sure many other such laws are "wrong". Sadly GDPR adds to that - mostly good - a tad bad.

The problem is that there are always wrong laws, and the UK has passed many (RIPA / IPA) that have bad things in them on both moral and technical grounds.

The EU is not immune too this, and neither is the UK. But leaving the EU means we have no say in such EU laws. We cannot fix them. It does not, however, mean we can ignore them as almost any trade deal will mean complying to standards set in such laws.

And to be fair, most of the laws are good! As a manufacturer, the hassle for CE marking is a nightmare now, but even though it is hard work and costs a lot of money it is all "good". It stops stuff catching fire, for example. The UK would mirror almost all EU safety laws as that is both sensible, and needed to sell to EU!


  • I'd like to stay in the EU, though a lot of that is because of the obvious chaos caused by leaving it at this point.
  • I'd like to see all of the underlying issues that Brexiters want addressed looked in to and sorted, as part of the EU. This is important - a lot of people are unhappy, and this needs addressing!
  • I'd like to see MEPs taken a lot more seriously by all - this is how we shape the EU to be what we want!
  • I'd always consider leaving EU in future as an option, but really only makes sense if EU starts to really fall apart.
  • I'd like to see A50 process fixed for any country planning to leave to remove any "left in limbo" effect - this is absolutely crazy!


99% of insurance claims

I have seen/heard a couple of slightly odd averts lately. Yes, I try and avoid adverts, but these seemed a tad odd.

One was an advert for a life assurance company proudly claiming that they "pay 100% of claims". The implication (though, I think, not said) is that other companies do not.

This seems a very strange claim to me. That can't mean it, surely. After all, if true, I should put in a claim. I'm not a customer, but if they pay 100% of claims it would be a way to get free money.

So I assume they mean they pay 100% of valid claims. But then that is what I would expect, what is their contract, and indeed what I would expect of every such company. Surely no life assurance company refuses to pay a valid claim, else they just get sued.

The second advert was an insurance company proudly proclaiming that they pay "99% of claims".

Again, odd. If they mean 99% of all claims, then they seem to be proud that only 1% of claims are fraudulent. I have no idea if that is good or bad compared to the industry, but I cannot see how it is a marketing statistic in any way. How is only 1% of claims being fraudulent a "selling point". Or are they saying that actually there are more than 1% that are fraudulent but they pay them anyway, thus being proud that they are being ripped off (and hence the customers that pay premiums being ripped off, ultimately). Or are they saying they don't pay all valid claims? I.e. you have a 1 in 100 chance of your (valid) claim not being paid if you go with them.

I just cannot understand the marketing point being made by either of these adverts. Crazy!


Countdown and clock changes

As I mentioned, for the Brexit clock, I had to allow for the clocks changing (something many such countdown clocks do not allow).

Basically, one of the days between now and (the current) Brexit is 25 hours long. This, in itself, is not complex.

I have tinkered with the way I do this a few times, and eventually came up with this, starting with how many whole days...

  • Work out a time for UTC midnight on target date
  • Work out a time for UTC midnight today
  • Divide time difference (as seconds) by 86400 (a day) for number of days
  • If the current local time (HH:MM:SS) is on or after the target local time (HH:MM:SS) take off one day from that total.

That is the easy bit, and means that the number of days changes at the local time (HH:MM:SS) of the target, so for Brexit, changes at 11pm local time exactly each day. What normally happens is the time part then counts down from 23:59:59 until 00:00:00 at 11pm local time the next day.

However, working out the time part is one area that took me a bit of thought. In the end I make use of the fact that linux mktime() function allows tm_mday to be any value and it adjusts.

So, what I do is :-
  • Create a date for the target date/time, local time.
  • Subtract the calculated number of days from the tm_mday part of that.
  • Work out time difference from that point to current time, and convert to hours, minutes and seconds.

The effect of that is that once the day changes, the time part goes down without a discontinuity. It means that on the day that has the clock change the clock will start counting down from 24:59:59 instead of 23:59:59.

For Brexit, that means that 11pm on Saturday 26th October 2019 it will go to from 5 days 00:00:00 to 4 days 24:59:59 and count down for 25 hours until 11pm on Sunday 27th October when it goes to 3 days 23:59:59.

Of all the ways to work this out, I think this is the best. It means days are counted to the local time on each day that matches the final target local time (so for Brexit, its counts a day at 11pm local time each day), and then that the time part counts without a discontinuity down to 00:00:00 at the same local time the next day.

Yes, I put far too much thought in to this.


Brexit countdown clock

Having made the environmental sensor, I have now cut down the design to just the processor and OLED display so I can make other things.

One example is a Brexit clock. I have put the code and PCB and 3D case on GitHub (here). It may need regular code updates, obviously :-)

It did raise one issue though. Most of the Brexit clocks I see, like Sky News's (here) seem to be an hour out. Brexit is at 11pm but they show days plus time that would be midnight.

Now, I know why... Someone is being lazy and simply dividing time of Brexit minus time now by 86400 and ignoring the clock change. One of the days between now and Brexit is 25 hours long, but that does not stop it being "one day".

My clock gets it right, obviously.

There are other uses for the app - and as I am taking one of my grandsons on a his first cruise, I thought he may like this...

He heard the phones in the suite have a button labeled "pizza" :-)
He is already packing!

P.S. This is why I have a milling machine and a 3D printer! I came up with the idea over coffee this morning at around 9am. I had to design a new PCB and a new case, mill the PCB, 3D print the case, and assemble it all, as well as make the code. I had a working version by around noon. My grandson is going to love this, I am sure!


Environmental sensor

For my latest little R&D project I have made a new environmental sensor. These should help us see how good the air quality is in the office, and as usual, I have published this as an open source project for anyone else to make the same.

This proved to be a bit of a challenge, as always. I have already managed to get my head around the ESP32 and the Espressif ESP-IDF now, and have a set of  MQTT based tools as a base (here).


I used an ESP32-WROOM-32 again, as they are really nice. I also used an SCD30 CO₂ sensor, which is the most expensive bit at around £40 from RS. I got a nice 128x128 OLED display from Amazon, and a DS18B20 temperature sensor.

One challenge was space - I decided to make the the PCB the same size as the OLED PCB and sandwich the CO₂ sensor in between. This was definitely a challenge to get connectors to fit!

I also decided to try the Molex SPOX connectors as they seem relatively cheap and easy to use.

The other aspect which is especially challenging is power. Most of the bits I have done to date have been alarm and access control and so use 12V on screw terminals. As it happens the unit (pictured above) takes 12V which is in the wall for the door control. But for use in bedrooms I need power to these and so I went for a micro USB. This is simply because that is a really easy and readily available and cheap way to provide a device with power.

The challenge itself is that the connectors have tiny tiny 0.635mm spaced contacts, and are also mechanically crap and come off the board. I ended up getting some connectors that I could superglue to the PCB, and thankfully the power contract are the end, so even though milling and soldering at 0.635mm pitch is just about possible (surprisingly) I can avoid this by actually only soldering the end pins for power. I decided to make the 3D printed case design fit tightly around the connector as well for extra mechanical support, except that means removing from the case pulls the connector off the PCB!

In short, some interesting new hardware challenges.


There are a lot of libraries around for ESP32 and ESP-IDF already, which is nice - but perhaps not as many as for the ESP8266/Arduino based environment.

That said, these are simple enough devices, so actually I ended up doing the I₂C interface for the CO₂ monitor myself using the ESP-IDF directly.

I used a library for the DS18B20 though, and it seems they have been quite clever using the IR remote control hardware to make the one wire bus work using DMA. Impressive. I decided to use a DS18B20 as (a) it allows the thermometer to be positioned where you want, (b) it is away from the components that could get slightly warm, and (c) it seems way more accurate than the one built in to the SCD30 CO₂ sensor. However, the code is happy to use the SCD30 if you don't want to use a DS18B20. Similarly, the code is happy to work without a display, but I am quite pleased with the display, to be honest.

For the display, there is a good Adafruit GFX library, but I ended up doing it myself. The commands for the SSD1327 OLED controller are simple enough, and only a few lines of code to send a whole frame buffer over I₂C. As such, I decided to make some 16 grey level renders of my existing font designs. There is also a logo (configurable).

I found the CO₂ reading was liable to change quite quickly. This is great, except just standing looking at it caused it to change a lot due to your breath. So I ended up damping the reading (biased average with last reading) to remove spikes.

I also decided to round the values for reporting on MQTT so that it is not flooding with updates every second. Configurable rounding, preset to CO₂ at multiples of 10ppm, RH at whole percent, and Temp at 0.1℃. I also added some hysteresis to the reporting.

Obviously I have my air-con control code working with it - just had to tell it a different topic to watch for on MQTT, but I added logging of CO₂ and R/H as well just for fun.

And finally I added settings so it can send MQTT to turn a fan on or off based on CO₂ levels.

It is interesting to see how CO₂ changes during the day.

Overall I am very pleased with it. It is all on GitHub (here) with PCB milling, 3D printed case design, and code. Have fun.

P.S. The OLED displays are made of glass, and very very very easy to accidentally break. Especially if the 3D case design is a fraction out!

P.P.S. I have one by my bed, and it is quite bright, so I now have an MQTT contrast command tied in to the sleep tracking stuff so when I get in to bed it goes dim :-)


Front door locks, at last

Even though I have had electronic door locks for something like 30 years, since well before I was married, my wife, for some reason, wanted a "normal" front door for the house. First units were made from a cassette player head (Sony Walkman, I think) and read mag cards (bank cards).

This is crazy (IMHO, but obviously I am "wrong"). For a long time it was a typical double glazing unit, but she then got a custom made wooden door. Nice!

Even though custom made, she was not keen on me insisting on electronic locks. I am not sure why.

Anyway, I did manage to get good euro profile actual locks, hard to pick, etc, and you need a 3D printer to make a fake key! Yeh, I know!!

The problem is we got some keys, and could get more, but with 5 kids and their various family you run out, especially if any are staying with you or visiting enough to have a key.

The end result was rather annoying for me. In practice the house is never empty, but having a key in a box outside the door is not a good security measure! Not quite a key under the mat, but damn close!

So finally I got a locking spindle.

I fitted it and routed wires in the mechanism to the hinge, etc.

The mechanical lock still works, obviously.

Unless deadlocked (as I say, never nobody here), the door can be opened by using the handle inside. Yes, that too is multi-point locking, but you just turn the handle.

Now the outside handle also works, if 12V is applied to the locking spindle. Suitable amounts of super glue, etc, make it hard to dismantle and operate otherwise. The door supplier has just used a split spindle which could easily be opened with a screw driver and replaced - crazy!

But this little device was simple, and around £60. There are options for a completely new multi-point locking strip with motors in it, but they are a lot more work and cost. This was surprisingly simple.

I already had a card reader on the wall near the front door, now an NFC reader using an ESP32 (inside) to check cards. That simply set the alarm, previously, but now can be used to "engage" the locking spindle.

End result is that I can now easily allow some access at some times of day, using DESFire cards, or even just bank cards, if and when I like, and no keys in a box outside. We have someone staying with us for a few days, and they were suitably gobsmacked that I just enabled their bank card to work the front door for a few days!

I am surprised more locks are not like this to be honest. The tech is way better now, but still, it has always been so much better than simple mechanical keys.

PCB milling

The new CNC machine is working well, so I thought it worth explaining a bit more on the PCB milling. I am getting pretty good at it now.


I 3D printed a support for the PCBs, holding them a couple of mm off the bed. This allows me to drill through the PCB and mill around the outline. Designs on thingiverse.


I previously mentioned milling bits, and there are lots you can buy from Amazon and the like. However, the best one I have found so far is one from RS components (part 382002). It is not cheap (£40), but don't be fooled - it works, and works, and works. I did manage to finally blunt one after a lot of PCBs, but really it is very good. The small end means it does not snap off easily either.

I am using a 0.5mm drill to make holes, and a 1mm drill to mill around the edges.

Design rules

I am now milling for the finer pitch used by the ESP32-WROOM-32 SoC modules. So I have to be able to mail quite fine tracks with 1.27mm spacing.

What I have found is that, with that bit, the simplest rule is to ensure isolation tracks are at least 1mm apart. This is quite easy, using inkscape, I just set the tracks to 1mm wide and see if any over lap. I have a layer for the parts, a layer for the drilled holes, a layer for the edge mill, and a layer for the isolation tracks. I can then simply save each layer as EPS and convert to an NC G code file.

Faster milling

I also updated my code to take the EPS output from inkscape and make a mill file. It now sorts the lines, and makes paths with a much more optimal routing. On GitHub.


Pololu D24V5F3

These are really nice power supply modules from Pololu..

They run from anything up to 36V and regulate down to a nice 3.3V. They cope if I reverse the polarity. They are tiny (0.4″ × 0.5″). They just work.

They cost a few dollars, and actually cost more than the ESP32-WROOM-32 (at current pre-brexit style exchange rates), but they really just work, and I am using them everywhere.

What I did not work out, when ordering a 100 of them, is that they are so recyclable! I am changing controllers from ESP8266 to ESP32, but the power modules can be easily desoldered and re-used. I have so many I am thinking of listing them on Amazon.

I whole heartedly recommend them, very nice, work well, don't get fried when you cock up.

TOTSCO - the top level - ordering

This should give you some idea of the issues with a simple matter of providing a broadband service. Bear in mind the broadband service may h...