Never quite finished?!

The good news is I now have the "proper" PCBs for my door controller and NFC reader...

I have to say they look good - proper boards, and using solder paste and oven means a very professional result.

PCB Train do a nice job, but these were on a three week lead time. Both boards work. However, in the three weeks since I ordered I have made a few design changes.

The door controller changes are very minor - instead of 3 inputs with 3 GND on the 6 pin connector I have all 6 pins connected to GPIO, where you drive some pins to GND if you want. This allows a lot more options if needed, etc. The pins all have BAV99S and 100Ω for some ESP protection, and 33pF to help reduce noise. It is a small change, and so the existing boards are more than usable. The only snag is I mis-ordered as 1.6mm not 0.8mm boards, and I have designed cases to be as small as I can to fit in a back box. I think 1.6mm will still fit, but it is annoying.

The bigger issue is the NFC board. As I say, they work. But the tuning is perhaps not spot on. The newer design boards have a loop both sides, allowing the board to be 40mm x 40mm not 42mm x 42mm. However, the newest boards are better - the main thing is they do not get hot which is a big clue (i.e. the antenna is clearly better and easier to tune), and I have them working with more range. So I would rather use the new boards. They too are also 0.8mm which saves space.

So, all in all, I decided to order some new boards - two week lead time. However I have a few dozen of these boards. As I say, they work, and I am testing with them, and may well use some, but once I get the replacements I will end up throwing these away, I am sure, which is a shame.

So, if a hackspace, or other good cause, wants either of these bare boards, to play with. The schematics and code are all on GitHub. Note, need hot air gun at least for the PN532, and fine tipped soldering iron. Let me know. Email me at pcb1@revk.uk

Long term?

These, and some other related modules, should be able to make a WiFi mesh with (not having to be always on-line) "cloud" control and management (on or off site) to work as an alarm and access system.


Battery powered

My latest project is to make something battery powered, based on an ESP32 processor. The ESP32 data sheet claims it can go down to under 1uA in a deep sleep mode. It also has an Ultra Low Power processor that can do things in deep sleep at only a few uA. It is not very clear in the datasheet for the ESP32-WROOM-32 module how low it can go - after all that has extra bits including an external flash. So it was a bit of an unknown. However, I have made something, and it works... (on GitHub)

The first board was a cock up - wrong footprint completely on a key device - kicking myself. The second version was more what I would expect - some minor errors I could work around, allowing me to prove it all works and confirm power usage. The 3rd version was great except one of the chips again had wrong footprint - but this time close enough for the device to fit without problem. I have managed to keep the device tiny - not much bigger than the ESP32-WROOM-32 itself.

The first application is actually to work with a VL53L0X ranger in the top of an oil tank, running on battery and reporting over WiFi. The next trick may be LoRa for such things.

Battery / power supply?

The first real question was whether to try and run directly from a battery, or to use a power supply?

Directly from a battery means finding a battery that is within spec to produce 3.3V. The voltage from a battery is often slightly more (when new) than stated, and depends on the battery technology. The processor will cope with voltages a bit out of range as well (3.0V to 3.6V). So a 3V battery should work. But the voltage drops as the battery runs down, and we are starting on the edge of acceptable voltages, so this could cause problems. The advantage of running directly from a battery, apart from fewer components, is the really low power modes of the ESP32 should allow a really long battery life.

With a power supply you have the advantage of using a wide range of battery, e.g. 4.5V, 9V, 12V, etc, but the big disadvantage of wasting power on the regulator itself.

I ended up using the LMR16006 from TI which is designed for battery devices, and has an idle current of 28uA when not driving much load (e.g. an ESP32 in deep sleep). It also has a shutdown mode drawing less than 1uA (see more on that later).

However, testing showed that it draws 34uA when not even connected to a load. This pretty much is explained by the 460kΩ potential divide built in to the fixed 3.3V module to drive its feedback pin. I could go for external potential divide but 460kΩ is on the top range recommended in the data sheet.

However, even 34uA is good, and can allow a battery to last years.

USB as well?

Do I need USB as well? Well, no, not really, I could have a generic programming header, but I like the USB-C connectors. They are good as a power supply when not running off battery, and make programming and debug easy. So yes, I'd like to keep the USB.

The issue is power. The USB chip (FT231X) can be powered from USB, and even work its own 3.3V I/O from that. So it can be totally off when no USB. Good.

But it is used to control EN/GPIO0 to reset and put the ESP32 in boot mode. If USB is off, the ESP32 stays in reset. Thankfully the USB chip can be configured to invert RTS and DTR if you want, so I put them through a simple transistor inverter so that when the USB is off the ESP32 is not in reset or boot mode. The result then works as expected with the debug and flashing tools in the ESP IDF.

The Tx pin to the USB when powered down was a concern, but it seems to cause no problem, and the code can turn it off immediately on start up, and in deep sleep it is not connected.

The USB chip can also feed in some useful GPIO pins, reporting when it is on (a fixed "1" on a CBUS pin), and even if it is connected to a charger not a USB device. This means the software can tell if running from battery or not, and stay awake when being used for USB debug.

How low does the ESP32-WROOM-32 go?

Well, the good news is that the ESP32-WROOM-32 does indeed use bugger all (aka 1uA) in deep sleep. This is impressive, so we are looking at under 35uA idle current for the whole board from a 9V supply when idle.

Obviously we need to wake up occasionally, but we can wake up, boot, connect to WiFi, connect to MQTT, report status, and shut down in under a second with fixed IP. Indeed, the WiFi can be in use for under half a second, which is impressive. We need to do some long term tests to confirm battery life.

Measuring the voltage?

Of course, one thing we want to measure is the battery voltage. That allows us to see if we have a low battery. It is essential for any battery based device to tell you the battery is low. The answer is a simple potential divide feeding an ADC input to the ESP32. Except that draws current! Even 1MΩ divide is 9uA at 9V, 100% of the time.

The answer is a FET, well, two FETs. I am not an electrical engineer so this needed a bit of research. One FET or transistor would not work as it had to be at the "top" of the divider. If it was at the bottom of the divider it would mean 9V going in to the ADC pin when the FET was off. But when at the top of the divider you don't have GND as a reference to drive the FET.

The answer is an N-channel FET driving a P-channel FET, all in one package. Thanks to twitter for help on this. It works! I can turn on the divider, take a reading, and turn off again. I have some resistors to ensure than when GPIOs are isolated the FET stays off anyway. Sorted.

How low can you go?

Can I do better than 35uA? Well, yes, probably. The ESP32-WROOM-32 itself goes down to 1uA or so. The regulator in shutdown goes to 1uA but as that annoying potential divider still. If I was able to shutdown and disconnect the power from the ESP32-WROOM-32, it could run off a capacitor for many seconds at 1uA.

So basically I'd need a way for the processor to turn off its own power most of the time!

The trick is ensuring that if you sleep too long, the power will come back on anyway, and indeed when first powered up.

I think I can do this with another FET, pulling the shutdown pin to GND, driven from a GPIO pin. When no power the GPIO will go to ground, pulled by parasitic diodes if nothing else, and cause the FET to go off. Of course you still have the issue of making the shutdown pin then go high when the FET is off, with the only power being the battery, so you still need that one pull up resistor. I wonder how big we can make it? If we can make it 10MΩ we waste only 1uA on that.

The same signal driving the shutdown pin could also drive a FET switching the feedback potential divider, so we turn that off too. It may need some careful design, e.g. FET at bottom of that divide, to ensure we don't fool the regulator in to supplying too much power because its feedback is not get connected, but that should not be rocket science.

For now, I'll test using the current design, idling at 35uA, and see how it goes. But I may yet make a new version that tries to turn itself off most of the time :-)

P.S. I am such a fan of solder paste now, I can't see me ordering boards without getting a stencil as well. It is so quick and so reliable, it is quite amazing really...


NFC reader works, what next

It has been a month since I came up with this crazy idea, but the NFC reader board is working really well now. To be fair, every version I have made has worked, just some better than others. The most noticeable impact on how well it works is the inductors. Using small inductors (i.e. 0603) means it is crap - needs fob flat on then antenna to do anything. Now it works around 2cm. I have changed layout a lot, changed the antenna shape, changed component size. Lots.

I have, however, learned a lot about ESD protection, layout for RF, choosing components for RF, using KiCad, and solder paste. The solder paste has perhaps been to be the biggest change as I am no longer afraid of adding passives, which previously would have been far too annoying to hand solder and take too much space. Lots of 0603s are no issue now.

So I have a nice NFC card design, thanks a lot to John for his help. I also have a nice door control module which is tiny, and only 7mm thick. Easy to fit in a back box with other stuff.

If any hack space want to have a play with one of these NFC boards, let me know. I'd be interested in feedback. Main advantages over Elechouse are red/amber/green LEDs, tamper button, door bell input, and more ESD protection.

The boards, and 3D cases, are all on GitHub.

So what next?

Well - battery power - that's what. I have made up a new regulator for my boards rather than using the Pololu boards (they really are very good!). It has an automatic ECO mode dropping to 27uA.

Planning to work on Ultra Low Power mode on the ESP32, see how low I can get it, and run from a battery.

So now I need a board that can be low power. This means the USB chip needs to be turned off when not using USB, which is fun as it means I do not want to power its I/O pins for Tx either - and the ESP32 blurts lots of debug on Tx at start up. So a small FET is in order. Also quite fun as the FT231X USB chip works the RST and GPIO0 pins, so need them to work properly when no USB power.

P.S. Why USB?

Someone asked why do I have USB at all? I used to have boards with USB-C for power, and a header for programming, but it was actually less space and easier to just fit an FT231 to the board instead of the header, so using the USB for power and serial load/debug. The battery board is perhaps an exception as it needs a couple of extra components to let me disconnect the USB, but even so, on a board this small an extra programming header would be tricky, so I decided to stick with USB serial.


Solder paste stencil

My soldering is not bad, but there are limits, and I am reaching them with the smaller and smaller components I am trying to use. Not only are the pins small, they are under the chip. A small QFN is just about doable. So I wanted to up my skills in soldering and try solder paste. I'm impressed with the result, but it was a bit of a journey.

How to do it? Get an oven, get a proper solder stencil, and get the right solder paste. You can then wipe the paste through the stencil with a plastic card, apply components and cook. It works!

So what was so hard?

Well, it was not as simple as it sounds, so here is what happened.

Laser a stencil?

I decided to try and make a stencil myself. Basically, having a proper metal stencil made adds another £50 to the cost, and someone said they had success with a vinyl cutter. I decided to try a laser. I got a cheap one off Amazon (K4 laser generic Chinese thing). Sadly the firmware simply will not laser cut, it only raster images. It looks like I could dismantle it and re-flash with something sane, but a lot of work.

Try again

So I ordered a better laser, one that actually claims to do GRBL. Again from Amazon. The GRBL firmware loader is a windows program but works from parallels, and then it just works nicely with LaserWeb on my Mac. I'm amazed at what you can get.

So what to cut to make a stencil? Well I tried mylar and it sort of melted. I tried acetate, and it sort of burned!

So I tried some actual vinyl, and that worked surprisingly well, but is just not quite accurate enough - rough edges. It would be fine for 0603 but not QFNs. Bugger.

Oh, and all of them made some nasty smells - this is why a cheap laser is not ideal - no fans. Recommend using outside!

Cut a stencil?

Next I tried an actual vinyl cutter, as someone else had managed this. How hard could it be. I decided to try and do a bit more research, and there are some nice small cutters like Cricut and Silhouette. However I see Cricut recently stopped you cutting your own designs!!! You have to pay for designs. Wow. And I could not work out what you needed for Silhouette to work. So I went for a more generic cutter/plotter that does HPGL. Using Inkcut on my Mac worked, I can cut things...

But, not quite. For a start it took a bit to work out it uses XON/XOFF. Then I found when the serial port closes at the end of the job the printer aborts and so does not finish the job (I added a delay to fix that).

It could not cope with mylar or acetate, but did cut vinyl. However, it did not make a clean stencil! The pads were not closed and the fine pads were just a diagonal line!

The answer is that I did not quite do enough research. This is a "drag blade" cutter, so the blade point drags 0.25mm behind. This would be fine(ish) for cutting large sticky back lettering, but now when the features you are cutting are not even 0.25mm wide! There are, apparently, some s/w work arounds I could try. But for now I have given up and decided to do it properly...

Try again

Update: It looks like the Silhouette printers are going to work. Seems you have to pay £50 more for being able to load an SVG, but it will load a DXF anyway. Converting SVG to DXF is easy with inkscape and free, so why would you pay £50 more. That said, I am not sure it can cope with such detail.

Use a proper stencil?

So I ordered a proper stencil - very nice. PCB Train do a good job.

I ordered some solder paste from RS, and, well, it was a disaster. It was runny and far too much solder paste, and well, useless!

Try again

I was desparing, but encouraged by people on twitter who clearly managed to do this right, I carried on. I ordered some different solder paste, just in case.

It worked first time, clean, nice, easy to use. I am impressed.

The first board made like this actually worked - well minor issue with reset, but did then work. So now to try another.


I failed to get anything to make my own stencils, but the ones from PCB Train are impressive. One trick is they charge the same for stencils up to a certain size, so I'll be adding a number of boards that I think I have finished and ready to the artwork for next stencil order anyway. If they are the same when I order the actual boards, great,  I have a stencil already. If not, then it has not cost me to do this, but it is an incentive not to move any components if I do have further changes at all before ordering.


Almost a real RF engineer!

As you will have read, I decided to trying and tackle making an NFC reader. It is my first project in any sort of RF, so a massive learning project, but also a first in terms of trying to fit small components (e.g. QFN-40) on a PCB. The QFN-16 for the FT230X was just about doable with a soldering iron, but now I am in to solder paste and re-flow oven territory (more on a later blog).

I decided to give it a go, and made an NFC board, and to my (quite frankly) shock, it worked! It worked well, in fact - seemingly at least as well as the Elechouse board. I have made some tweaks with smaller components, and that also worked. Designing a PCB can be like a never ending piece of art - always one more small tweak or improvement. I am now working on a 3rd version, with even smaller components, but this time I am starting to do it properly from am RF point of view. Instead of just drawing an antenna track and hoping (which worked, to be fair), I now have an "network vector analyser" to tell me how the antenna and tuning circuit works.

The trick is to test the antenna and make component changes, or even adjust the antenna design. Apparently all sorts of things impact the tuning including any components near it, or just bits of copper track, and so on, even the case (even if plastic). But using one of these gadgets it is possible to work out if you have the tuning right, or close, and make adjustments. I am still learning, but getting there. In that image, you can see I changed the loop length a bit, and as expected the centre frequency moved.

My plan is to have a good quality, tuned, working, NFC reader design (open sourced), that I can sell. Something that is better than the standard Elechouse boards everyone uses. Apart from better RF (well, better than all the cheap copies of the Elechouse) it has red/amber/green LED and tamper switch. This makes it perfect for any sort of access control entry reader. I'm not really expecting to make much money, but would be nice to cover the costs of getting this far and learning this stuff.

I expect to make up a few of a final design, maybe next week, and offer some (free) to people like hackspaces to have a play and give me feedback. Obviously, if they are hit, I could have hundreds properly made and sell them. But this whole project was more aimed at a learning exercise in the first place, so covering my costs would be a huge win.

It almost makes me a proper RF engineer, LOL!


Solder paste, and reflow oven

I got a cheap reflow oven off Amazon. Seems to work, but I am no expert, and there is some advice on the internet about some tweaks and improvements to that model too. However, baby steps.

I also got some solder paste. I do not (yet) have a stencil. So advice on how one uses a solder paste stencil, and what paste you get, and so on, may be useful.

This does, however, pose a problem. Whilst it is very easy to put a spot of paste on the pads for the passives, there is no way in hell I could possibly put paste on each pad on the FT231XQ or USB-C connector. The pins are too fine.

So how to do it. Well, I did wonder if just putting paste over the whole row of pads and relying on surface tension may work. But the other snag is these short turnaround boards from PCB Train have no solder resist. Still, it is worth a try...

Well, not quite. That is the USB-C connector, and you can maybe just see that the end power pads have bridged. As it happens a touch with soldering iron sorted that and all the fine pads were OK. But it is clearly not reliable. Attempts to do this on a simple QFN-16 were less good. I suspect if I got exactly the right amount of paste it might work, but generally, no. And I doubt any chance with a QFN-40.

So what now?

Well, what I was doing with the hot air gun was tinning the pads manually (easy), and putting liquid flux on the chip, and then blasting it. It worked pretty reliably, but the heat was not very controlled and you end up charing the PCB.

So will that work in the over? Well, the short answer is yes! (well sort of)

I tin the find pads, flux the chip and place on tinned pads, solder paste the passives and put them on board, and then reflow. It seems to work most of the time, but occasionally I have to heat gun and push the chip down on to the board to ensure all pins connected.

Just as well, as I have just got the new NFC boards to play with. Fingers crossed.


Well, I made one

As per my earlier blog post, I wondered if I could make a NFC card reader... Well, I have!


I am in a lucky position in many ways - whilst I have a "full time job", a lot of the day to day running of A&A is handled by my management team, so I can "tinker".

This means I can try things out, do R&D pretty much as much as I like, and try and make something like this NFC reader just for the hell of it. Of course there are practical applications - I have several of the Elechouse PN532 NFC readers here because we made access control and alarm systems for the office (and even sold one) which use them. I suspect we could make, and sell, these cards. But a lot of the R&D I do is speculative (and educational) - it might sell, or might lead to something that does, maybe. Indeed, my work on NFC and DESFire cards does look like it had led to a contract that is very worthwhile, but I could not have known that at the start. The more expertise we get as a company, the more we can sell.

So, to answer the questions people have asked, mainly "why?", it is mostly because I can!

Back to the NFC reader itself

I said it may be a nice idea to try and make my own reader, much like the Elechouse reader. Well, I went ahead, a proof of concept, and it works. Yes, I am shocked too.

As a version 1 board it was not perfect. For a start, it seems the data sheet for the crystal shows the underside of the chip pin out, so if you use that as the solder pads you end up back to front. Some messy soldering and wires allowed me to work around that.

I also found soldering a QFN-20 chip hard, even with my heat gun (hence the charring), so I have ordered an oven. I'll blog on that later. I may eventually progress to solder paste masks and the like. We'll see how it goes. Even so, this is all well within the grasp of the amateur / hobbiest.

I also found the LEDs would not work - apart from ordering the wrong LEDs (diode drop was more than the supply voltage, idiot), it seems GPIO P34 does not play and I can't work out why. I have read the data sheet over and over, tried loads of config changes, and it should work, but I cannot make it work (and cannot on the Elechouse boards either), so re-done using other GPIO pins.

Version 1 board - actually works!

Version 2 board

I also decided to move to smaller 0805 components instead of 1206 - simply because of the challenge of fitting all the components on such a small board. I have made a number of value changes to more closely match the PN532 reference circuit. So that is next. I also think the Elechouse boards can overload the receiver, and it meant my Amex card would not read on my board, but a component change and it does now!

But first I need to actually test the two LEDs that should work do in fact work well enough, and test the oven when it arrives. If all goes well I'll order some version 2 boards and test.

What is wrong with other boards?

If you search for NFC readers you find two main types of things you can buy: (a) a nice plastic card reader with rubber feet to sit on your desk and connect via a USB lead to your PC, or (b) a "development board" with lots of 0.1" spaced pins to allow you to tinker, usually quite large. What you don't find is a board designed to actually be used as a component in an access control system.

To be fair, the Elechouse is pretty close - it has lots of extra pads for general tinkering but is not bad. What is lacked was LEDs for feedback and a tamper switch. That is what I have added. Just to be clear, my board is not a copy of the Elechouse, and is based on the reference circuit in the PN532 datasheet.

My board is HSU (High Speed UART) only (as that is better on a length of wire than I2C), only four wires (GND/VCC/TX/RX), and a choice of connectors on either side of the board for easy use in an access system or in a nice simple case as a device on your desk connected to a PC, if that is what you want. I'll do a 3D case design as well for both.

So I actually think my board design will be a good, usable, and even sellable board. If there is any demand I may get a few hundred properly made. But it is also nice that I am making this all open source, not just the s/w drivers, but the actual PCB layouts so you can easily order and make yourself if you want.

This is the version 2 board so far... May be real boards next week.

[P.S. I have ordered these now...]

Update: The V2 board work, and I have sent to an RF engineer to check if I need to make any tweaks before making the next version.


Tooth ache

I am sure we have all had tooth ache. I rarely have to see a dentist and rarely have tooth ache, but, well, I do now, and the delay in getting to actually get it fixed is painful.

Why my whole mouth

I have seen the dentist, and he has booked me in for a filling next week. It seems that it is just one tooth, with a broken filling, and that is it. So why does it feel like my whole jaw is trying to kill me, not just one tooth. I think "referred pain" is the answer, but it is hell. At least now I know it is one tooth I know that is the problem that needs attention.

Why some times and not others

OK I understand if I eat something and get something in the broken tooth on to the nerve, it will hurt, but it is far from that simple. Eating can make it worse, and cleaning my teeth can make it better, yes. But it seems it will be hours, maybe even all day, without a twinge - I can forget I have tooth ache. But then can be hours in agony - meaning I can't think, can't sleep, can't work. There is no clue to it at all.

Right now eating a meal is challenging though.

Temporary fillings

You can buy them (amazon!) and initially they appeared to work, but then not. They don't last long and come out easily. It is now the point where if I put in a temporary filling I will be in agony, so that is no good. Shame.

Pain killers

You would think pain killers would be the answer, so here is the list of what makes fuck all difference!

  • Paracetamol
  • Prescription strength co-codamol
  • Ibuprofen (seems to help a bit, maybe)
  • Bonjela
  • Infant teething granules (aka "baby crack")
  • Sensitive toothpaste

What works?

The only thing that helps, and not for very long, is literally cleaning my teeth with isopropyl alcohol. Obviously used with care although not particularly toxic.

I am, however, trying more normal ethanol ingestion as well as a method to reduce the impact of the pain.

Only a few more days...

P.S. With only 2 days to go, I think I have it - the temporary filling was a problem, but because the actual problem was not where it looked, and putting the filling in the obvious hole in my tooth just forced the broken filling in to a position which caused more pain. Now I see where the issue is, I can put a tiny bit of temporary filling around the broken filling and plug the pain mostly. The clue is that the nerve does not tell you where the pain is located, that is a serious problem!


Home automation for geeks

This is mainly about bridging some of the "trendy apply shit" and "command line forever" types of working for home automation.

Background: I have done quite a bit for home automation here at the new house. There are thousands of IoT devices (smart sockets, lights, switches, all sorts). They all come with their own app, cloud service, and feature set, but thankfully most work using ESP8266 chipset and can be "reflashed" with tasmota. Tasmota is an open source IoT application, and very flexible. It is not that tasmota is "better" than the systems that come with these devices (though it usually is), more that almost any device from almost any manufacturer can be made to work in the same way with the same config. The main one I have been using of late is the Shelly 1, which is very easy to reflash and has a relay and switch input. I do, however, have a number of my own devices, including environmental monitors. The tasmota devices can do lots of automation and send messages to each other as needed. I have, however, tried to keep it simple so a light with a Shelly 1 will have the switch connected and will work the light based on the switch even with no WiFi or Internet working!

These all work over WiFi and connect to an MQTT server. MQTT allows devices to talk to each other using a "topic" (simple text string) rather than that pesky IP addressing stuff :-) But it is very much in the school of "command line" over "GUI".

Bring on apple!

I use an iPhone, but I have not bought in to their home automation. As I say, it is more "command line" for me. That is until now. After much nagging from my son, I have managed to link my Shelly 1 and other devices, including my own environmental sensors, to my iPhone!

  • I have MQTT running on a Raspberry Pi in my loft. It is just apt install mosquitto. You may want to set up some security too.
  • I installed homebridge. There is a Raspberry Pi image even. I just followed the instructions and it worked. Again, set a password!
  • I installed the add on homebridge-tasmota plug in (just search on the plug in tab on the web config for homebridge).
  • I sent a cmnd/tasmotas/SetOption30 1 to turn on Home Assistant Discovery on all my tasmotas.
  • I added the homebridge to me "home" on my iPhone. It asked what room each device was in. It warns it is not an approved bridge :-)

It is worth pointing out it is not perfect. If devices are added afterwards they appear in the "room" where the iPhone thinks the homebridge is located. You can move them to the right room, and rename them, but it is not quite as stable - resetting things can move it back very easily. So I recommend getting on homebridge first then adding the bridge. It asked where each devices it when you do that. You can reset the bridge and re-add if needed.

As for my environmental monitors, I added the necessary home assistant discovery messages, and it works. I had to do a bit of trial and error, and reading the homebridge-tasmota plugin code, but managed to make it see Temperature, Humidity and CO2 properly. Again, it seems better if these are seen by the homebridge before adding the bridge to the iPhone.

But yes, it works. I am all GUI'd up now!


Why Three Words

In case you did not know, What Three Words is a system that assigns three words to a location in the world within a few metres.

What is the problem this is trying to solve?

Well, the issue is that people often have an exact location but need to convey that to someone else. The classic example is someone on a telephone call to Emergency services. Reading, Speaking, and Typing a latitude and longitude is very error prone. Reading, speaking an typing three common words is less so.

Does it work?

To be frank, I don't know. But the words can easily be confused with similar words. There are examples where one letter, making a word plural, can give a location a few miles away (though often misheard words will be a long way apart).

Is there a better solution?

Yes, emergency services should get out of the stone age and stop being based on phone calls. A common API to allow calls for voice and video to emergency services with supplementary data should be developed by international co-operation, and become standard on mobile phones. It could allow not only voice, and video, but location data and medical data (many phones have medical data and can even do an ECG, report pulse, temperature, blood sugar, all sorts). This would solve a lot of problems, and I am sure mobile phone operators would be on board with this.

Other ideas?

Well, the issue here is communications. Someone has a device that knows the location and is on a call to someone that needs to know it - whether emergency services, vehicle breakdown, or heck - pizza delivery! How to get that location from an app on the device to someone on the end of a call. That is what W3W does.

Here's an idea...

DTMF is standard on audio calls, and even over mobile it has out of band encoding to work reliably to/from the mobile device if needed. So how about phones (or an app you install) work out that the other party has sent a DTMF sequence. DTMF in to a mobile is rare so something simple like "20" in DTMF would be more than adequate. The phone / app pops up saying "send location?" and if you say yes it sends that as DTMF. A simple *latitude*longitude# would suffice. Maybe use some less common A-D DTMF codes to frame it instead. Of course this could be something an app can send anyway without an in call prompt if the user commands it. It needs some common standard for the DTMF sequence to use, and maybe a check digit is in order.

This would be very easy for the phone app to do. Someone just needs to write a spec. But importantly this is very easy for a call centre system like emergency service, vehicle breakdown, or anyone, to handle automatically. No special API. DTMF is really very standard.

It may be a neat way to do this for now until we have proper multi-media APIs for this.

Or, you know, another "standard"

Plus codes look pretty neat and not that hard to speak. More on the spec here. Given the common usage of using 4 characters and a location name rather than all 8 characters before the plus, this can give a pretty good location with only 4 letters rather than 3 words. Emergency services have a rough location from cell ID anyway, so this has to be better than W3W. Notable some phones (android) have this coding available without installing an app even!

Or even easier than DTMF...


Discussion: Not an Elechouse PN532 board

A company called Elechouse make a PN532 RFID reader board.

There are actually a few PN532 boards available, but the Elechouse one seems to be the most popular. Annoyingly, it seems that there are a lot of cheap copies that don't work as well. It has a number of advantages over the alternatives, mainly (I think) its compact design.

The actual circuit is basically the PN532 reference design from the datasheet.

However, there are a few niggles I have with it where I have used it in projects. My main use case was where this is the external module on an access control system, in a small case. The main issue was it lacked any feedback (e.g. LEDs). I worked around this by using its internal GPIO pins to work a red/green LED, and a tamper switch.

So I was thinking, I could make my own board. The issue for a home made board is soldering the PN532 itself, but I have been practising and am reasonably confident that with a hot air gun I can manage it. The result would be an open source PCB that can be home made. Obviously it could be properly made with pick and place and sold as well.

I am concerned over "feature creep" in such a design, and even just pondering it for a few minutes I am already seeing ways I could be improved on. Thankfully a lot of features could be "optional fit" on the PCB, basically adding no cost when not needed.

But I am in two minds over making this - it will not take too long to design and have made, but may need some tinkering to ensure I have the antenna matching right (and I may even need help with that). Before I start, I am interested in feedback, especially from anyone that may think they would like to use it themselves.

So here are my design thoughts.

  • A small square board (note the Elechouse is not actually square, but I am thinking the same sort of size, maybe 42mm x 42mm) with simple mounting holes.
  • Components can be only on one side making easier to mount (same as Elechouse).
  • Using larger (e.g. 1206) components that can more easily be hand soldered.
  • Not having the big DIP switch - I am thinking fixed HSU mode, but maybe pads for a link to make I2C mode as they use the same pins. This is to keep the profile low, and hence easier to fit in a smaller case. My testing suggested HSU is just as fast as I2C for actual card access, and much more reliable as tx/rx are driven at each end not just pulled up like I2C, so survive a long cable. So HSU is likely to be the fixed mode for this board.
  • Whilst it may have additional pads, the main 4 pins for connection are GND, VBAT, TX, RX (Note TX/RX could be I2C). The VBAT can be 3.3V to 5V but signals would be 3.3V.
  • The 4 pins for connection would probably be 0.1" header, and 2.5mm SPOX (straight or right angle) header, and 2x2 molex milli-grid in the centre of the board. Design to allow connectors to be either side of the board. This makes mounting as a reader very flexible.
  • Pad to allow a contact switch on either side of the board as a tamper contact - connected to a GPIO pin.
  • Three LEDs arranged in a corner in traffic light style, Red / Amber / Green, connected to GPIO pins. This is perhaps the most important feature as it allows feedback to a user. These can be pads for a small 1206 LED as well as through plated for standard leaded LEDs. Again, making pads both sides to allow LEDs to be either side as needed. Leaded LEDs can be more useful in a simple case design instead of light pipes.

Some possible feature creep...

  • An FTDI FT230X and 4 pins for USB lead connection, so can be used as serial to HSU mode USB device. This would allow it to work as a USB connected reader and hence for applications using a Raspberry Pi, or simply for connection to a PC for configuring cards on a security system. Given that you can so easily get an FTDI in a USB plug and serial lead, this probably really is unnecessary as that could be used with the 4 pin serial connection directly with ease.

Obviously I can include some 3D case designs too.

But I am interested in feedback - would you use such a board? Would you make one yourself if I do this (all open source)? Would you need other features? Would you take away any features I have suggested?

P.S. This is the sort of idea... Though obviously this shows multiple connectors when you would only use one. This idea is any of the connectors, switch, and LEDs could go either side as required. OK I have ordered these...

P.P.S. Err, it works. OK one of the LEDs does not, as on P34, which I just cannot get to be GPIO for some reason, and the crystal pin out was wrong, but it actually talks NFC!!!! I am gob smacked. More in a later blog.


The good, the bad, and the ugly

There are lots of different people in the world. Living in a social bubble, one does not always encounter some of the extremes. Having our dog go missing has highlighted some of the differences though.

The good

There are lots of good people:

  • People that have helped look for Lilly, walking around the area, checking under hedges, knocking on doors and asking people. Putting a lot of time in to help.
  • People that tried to catch her to return her to us.
  • People that have published details and shared details, and given us kind words of support.
  • Even the police, and now the press, that have taken it seriously.
Thank you all. Hopefully she will be returned.

The less good

There are obviously people that are more indifferent. I can understand that. I can understand that people probably have just ignored a dog wandering alone. I understand it even more during a pandemic - not just hassle to catch a dog and hand her in, but it means interacting with more people to do so. There can be other reasons for not helping, too. But either way, thank you for not being bad, though.

The bad

It seems, from reports we have had, that someone picked up Lilly, in a car, and took her away. Initially we thought this was good, as they would surely hand her over to police, vet, council, etc.

Sadly not, no sign of her. This is why the police are now treating this as a theft.

She is old, spayed, and no value to anyone else - why do this?

The ugly

There are people that actively call those that have lost pets (no doubt from a burner phone), demand money, and threaten to cut the dogs head off and put it on the gate if not paid. I am at a loss for words, sorry.


UK Cyber Security Council

There is a press release for a new UK Cyber Security Council (here).

It is not 100% clear who they are, and whilst they mention various links with government and NCSC it is not 100% clear to me how they are linked, or who the Cyber Security Alliance is exactly. The press release looks a tad shoddy with broken markdown/CMS.

So it may be important news.

Of course "Cyber Security" is important to all of us. One of the tips I can give you when it comes to cyber security is that you should be careful to ensure that contact details you publish actually belong to you. The press release includes contact details for press :-

[Screenshot, as it has since been corrected]

So, understandably, press will email press@ukcybersecurity.org.uk for more details. Good.

The problem is that if the domain ukcybersecurity.org.uk is not actually owned by UK Cyber Security Council, that could lead to loads of bogus emails to whoever owns it. Worse, if it is not owned by anyone, then some fraudster could quickly register it.

You may think it is no big deal, but it sort of is. If a fraudster can hijack even one point of contact for an organisation they can do a lot of damage. It becomes easy for them to impersonate that organisation. When it is the press contact for a new organisation they get a huge "foot in the door" as they can reply with helpful details on the organisation along with more contact details (names, email, website, phone, postal), all of which at likely to be helpfully published verbatim by the press who have made enquiries.

This then leaves a trail of misinformation on the internet and search engines for the new organisation, possibly swamping the actual accurate details, and allowing fraud to continue for years.

Fortunately for the UK Cyber Security Council the domain they published in the press release (ukcybersecurity.org.uk), the domain that was not theirs, and was not anyone's, has been registered not by a fraudster but by someone that decided it would be prudent to register in order to stop a fraudster doing so. It took a while to stop laughing at the irony first, but now, yes, the UK Cyber Security Council are welcome to ukcybersecurity.org.uk. They can email me at press@ukcybersecurity.org.uk for more information (be nice). Do follow me on twitter.

Of course it is also a sensible cyber security move to register related domains as well, so as to avoid some types of fraud happening. You cannot register every possible alternative, obviously. One issue though is not having an actual web site when you "launch". I am sure you can guess what happens if you try to go the the UK Cyber Security Council's actual domain (ukcybersecuritycouncil.org.uk) as a web site? That's right, not even a bland holding page or perhaps a copy of the press release. Indeed, having no web site on your actual domain makes you look fake, and the fraudsters look legit.

As to whether the UK Cyber Security Council is an organisation you should consider talking to when it comes to advice on cyber security - well, I'll leave that one up to you...

P.S. thanks to Spy Blog on Twitter for pointing this out. He tweeted what looks like their Twitter account so that they could fix this quickly.

Best comment I have seen so far, proper LOL at the last line!


  • Someone has created PGP keys for press and security addresses at this domain (obviously no idea who).
  • Various people have registered the related domains and set up web sites, e.g. ukcybersecuritycouncil.uk, because the UK Cyber Security Council did not think of protecting the obvious alternatives in advance.
  • Someone from an omarketing.com email, implying they were from UK Cyber Security Council, sent an email to a rather odd contact for me (not as above) asking that I delete this post "as stated". Whilst I'm happy to delete the domain if that press release is fixed, or transfer it to UK Cyber Security Council, I don't see any reason I would remove this blog post.
  • Looks like late Sunday they have fixed that press release at last, although the bad markup on the page has not been fixed.
  • Some actual press enquiries asking me about it all (i.e. they have seen this blog), and some reports on this fiasco. Thanks - nice to be called "one of the good guys".
  • Oddly, one news article was removed. It was reposted elsewhere, and we don't know why it was removed by the host site, but seems strange.
  • Someone called saying the UK Cyber Security Council would like the domain. They called A&A press office number saying that they had been trying to email admin at my Mastodon instance, neither of which contacts make a lot of sense, especially when I said how to contact me in this blog post!
  • I have given the domain to them now (i.e. set the Registrant), just waiting for them to let me know what Tag they want it on at Nominet.
  • Domain has now been retagged to their ISP. No doubt they will eventually get around to setting new name servers.
  • Fri 9th, finally it is on their DNS now. Handed over.

Wow, instead of pointing to the same site, or having a simple redirect, they actually pointed it to a site redirection service thing somehow, which, of course, does not work with https. Yay for "cyber security".


Selling a house

Why does it take so damn long?!

Anyway, some small progress last week, the buyer's solicitors had some questions. I really had tried hard to avoid questions, and made sure I had included all of the paperwork and everything, but no, they had questions.

All about the conservatory, which is a recent replacement of a conservatory put in probably 20 years ago. This means that even if the original conservatory did not meet planning exceptions, the fact it is over 4 years means that is moot, and the new conservatory is a like for like replacement so exempt anyway. But no, they wanted to check EVERY SINGLE RULE on it being a permitted development.

This included things like "Is it sited at ground level", and are the sides / roof mostly transparent. All the details but one could be confirmed just by looking at the estate agent pictures / details.

The only one that was not "obvious" was whether there was heating or not - seems it needs no heating or separately controlled heating. It has none.

Oh, and they asked if we had to pay anything for the "access way" to the house, when their searches should have confirmed that the house is directly on the public highway, so, d'uh!

I swear they only ask questions, especially ones to which they already have all the answers, just to justify their fees.

Fingers crossed that it won't take long now.


Environmental sensors (now in colour)

I made these ages ago, but they have moved on a little. I may add more "air quality" type stuff in future, but for now they are temperature, humidity and CO₂. I have updated for a colour display.

The new house has coax cabling in place, which is no use to me, so I have redeployed as 12V DC supply so I can install these on existing single gang back boxes.

The main thing is that they are all on GitHub. This includes the code, PCB, and 3D case designs. This includes linux code to log the MQTT to a database. It also can send MQTT for controlling heating and ventilation based on temperature and CO₂ levels, which I am using with tasmota flashed relays (Shelly).

The PCB is now all KiCad, so easy to get printed properly.

The 3D case design has been fun - I made code to generate an SCAD model from the KiCad PCB layout so ensuring all connectors, and spacing for all components is always accurate. That was fun! I have included simple boxes with USB-C socket and also one gang face place boxes, with and without OLED or CO₂ sensor.

So have fun.

P.S. I have updated the repository Documentation to have detailed step by step instructions with pictures for building these.


The trick to soldering these buggers (QFN16)

As I mentioned, I have been using an FT230X USB serial chip, and using it in the QFN16 package. There is an option of an SSOP20, which would be a lot easier to solder but takes more space. However, I think I have the trick of soldering the QFN16 sussed.

My first attempt was fine point soldering iron into the edge of the chip, that worked but is really fiddly.

My second attempt involved a hot air gun, a very hot one, in fact this Weller hot air gun.

Not cheap, but works well. It should not be hard to get one of these. Indeed, I got one a few weeks ago from RS - I ordered and as normal it arrived next day. Sadly, a week later it died (heat but no fan). So sent back.

Ordering another should have been as easy, and RS listed 32 in stock, but when I ordered nothing arrived. Indeed, my order showed as on back order for shipping 1st June. Yet the product page insisted 32 in stock for next working day delivery. WTF?

So cancelled RS and ordered from Farnell. Again, a normally very reliable supplier. They too had in stock for same day dispatch.

Again nothing arrived, and they contacted us and said they had cancelled the order, and refunded the card! Why? well as a "first order" and "the type of product" for "security reasons" they needed us to pay by bank transfer, not the Amex card I normally use, and ignoring that we have been buying from them for 12 years. WTF?

We paid by fast payment immediately, and they said accounts had gone home (this was 3pm Friday). They said they would ship Monday. Nothing. Finally arrived Wednesday even though the web site says not shipped at all.

What is wrong with people? "heat gun" is not a real "gun". Arrrg

Anyway, how to solder the QFN16...

Step 1: Tin the pads and the centre pad, being careful not to short any pins.

Step 2: Heat the board to melt the solder.

Step 3: Put a drop of liquid flux on the chip pads.

Step 4: Place chip on melted tinned pads and keep heating a bit - it should snap in to place nicely.

Step 5: It can be useful to do the USB-C connector at the same time thought that helps if you also tin the connector first.

That was it - works perfectly.

Note, whilst waiting for the Weller, I tried a more "normal" hot air gun and it blows way too hard and sent the chip flying long before any solder melted.

Obviously even better if you have a solder paste mask and solder paste, but this works too.

I have since redone the layout slightly to make the pads slightly longer, and make it a lot clearer when adjacent pins are joined together, as the track layout allows such tracks and vias to be very close to each other and so solder bridge easily (no solder resist on these boards) which looks bad until you realise they are joined under the chip! Making that clear outside the chip will help avoid problems.


The MK Grid Plus rabbit hole

MK is a good brand of switches and sockets and they are always good quality and solid, so when looking fo some new light switches, they seem like a good choice, albeit not the cheapest.

But I want some switches that are "retractive", i.e. just push switches not rocker, as they control a Shelly / tasmota smart switch module and not directly connected to a light.

MK do some of these, and they actually do modular switches, so I can mix and match what I need and where. In some cases a "two way and off" retractive switch to work a dimmer is ideal, and others a single retractive switch, and in some cases one of each on the same face plate.

Sadly it seems that almost nobody has the whole range on their web site, and the whole range is huge. They have a load of styles. There are catalogues from MK that list just one style, for example. The problem is, at the start, you don't necessarily realise what is possible, nor what is available from suppliers. Just to be clear, Screwfix is first port of call as it is a 4 minute walk from my front door. As per comments, it seems https://www.gil-lec.co.uk/ stock a good range as do https://www.tradesparky.com/

  • K4885PWHI: A Grid plus retractive module, as sold by the likes of Screwfix, yay. It has "press" on it, but OK. Good start.
  • K3701 : A grid plus "frame" for it, single gang, one switch, also sold by Screwfix, yay.
  • K3631WHI: A Grid plus front plate, single gang, also sold by Screwfix.

This is a good start, I now have a working retractive light switch, and can confirm that in a deep back box there is space for the switch and a Shelly 2.5 and a Wago. Working nicely.

It proves the solution fits, and works, so now to consider if I want to change other light switches in the house, as I make things "smart". But I need to make small changes to the way things work - my wife is not going to allow me to change one switch at a time from the brushed steel light switches we have everywhere to a plain white switch like this. I am not even sure the "press" label is going to go down well.

  • K4885WHI: Ooh, they do a retractive that does not say "press". (they also do one with a door bell symbol, but no need for that).
  • K3491ALM: Oooh, they do a metal faceplate.

But hang on, the metal faceplate is an enamelled aluminium, somewhat "industrial" to pass the wife test...

  • K3431BSS: ooh, they do a brushed steel front plate. This is much closer to what we have now.

At this point I think I have something that may be close enough to what we have now. The switch is white, but no "press" on it, and the front plate is brushed steel. But not sure. If this is the best MK do it will do, so I ordered a few.

Then I discovered they have a range of other front plates, arrrg. And there are Grid plus, and Euro modules as well. Complicated. It looks like "Aspect" may be what I want... They are available in something like 13 different finishes, including brushed stainless steel. They are also screwless.

One of the best documents showing the different styles is a technical document from MK. Logic Plus is traditional plain white with visible screws, Aspect is rounded raised screwless in a wide variety of finishes, Edge is flush to wall - with screws - with a wide range of finishes, Albany is a heavier/thicker angled boarder and industrial looking with visible screws in a smaller variety of finishes, Metalclad Plus is white or enamelled grey metal - very industrial style. So, let's look at Aspect in Brushed Steel finish I think...

  • K24331BSS: A front plate - comes with frame - screwless, brushed stainless steel. Good.
  • K4885BSSB: A retractive switch, no "press", with black surround. (they also do white)

OK I think we may finally be getting there. It looks like I have found switches that are :-

  • Screwless.
  • Brushed stainless steel front plate finish.
  • Retractive.
  • Brushed stainless steel switch finish with black surround.

I think that will meet with approval and be close enough to what we have to allow changing one switch at a time without looking wrong. Fingers crossed.

Took a month to arrive, but wife approved :-)

What is also fun is that MK have a really big range of modules. Including coloured indicators and a buzzer module! No, I have yet to find a use for these. They have loads of switches with pre printed labels, so it you make up one of their large grids of switches, you can have them clearly labeled.


  • Price.
  • Complexity of options.
  • The push switch takes noticeable force to press (though they do have two springs, and removing one makes them feel a lot more "normal", but probably not an approved modification).
  • The buzzer module is just high pitched and quite quiet - not good at all.

P.S. WARNING! other manufacturers make grid switches which are not interchangeable with these, and sometimes when searching the MK part number they come up, and "look" right - bastards!

And to add to the fun there are Euro modules, which are actually very simple 25mm x 50mm or 50mm x 50mm rectangular modules. I have seen these for networking before. For now. I'm going for MK Grid Plus.


Hobby PCBs

Milling PCBs

As some of you may know, from previous blog posts, I got quite good at milling PCBs. Basically, if you want to make small circuits at home, one option is a milling machine.

It does have some key advantages - the main one being time. You can have an idea in the morning, and design a circuit, layout a PCB, mill it, and have it soldered and working by lunch time. You can do several iterations of a board during a day. Another advantage is the cost - just the cost of the copper clad board, and the occasional new drill bit.

However, there are limitations. The main issue is that is it single sided - whilst a double sided milled board can just about be done, it is hard to align and the holes are not plated, so need links. The accuracy is an issue too - using a USB-C connector was just at the limit of possible, mainly as I only needed to connect two of the smaller pins (CC1/CC2), and even then - the more detail you try and do, the harder it is to get right first time.

So, moving on - what else is there? What I am doing is not quite hobby, it is more R&D, so I need slightly better than just milled board. The answer is getting fast turnaround PCBs professionally made. The nice thing is that double sided and plated through hole now becomes the norm.


But before I could get boards made, I needed a new way to design them. For milling boards I was using inkscape to lay out the milling path. That was not going to cut it when someone wants Gerber files. So I asked Twitter, and several people suggested KiCad - a free package that was available to run on my Mac.

It is nice, I have to say. It does the schematic, and then one button and you are in to PCB layout. It has design rule checks at each stage. The PCB layout is nice - I worked out that I prefer the "push" mode where running a new track which pushes the existing ones out of the way. It has limitations, but makes it easy. The other trick I did not realise initially is I can redraw an existing track in a new direction and it will remove the original part I have now bypassed, allowing more major track moves than "push" can handle, and making it easy to do cosmetic tidy up at the end.

It also does a lovely 3D view, and it seems that not only does its built in library have 3D models for lots of things, most components have them available as standard now. Even complex modules like the Pololu D24V5F3 regulator has one. I was able to add new parts at schematic, footprint, and 3D model without any real problems.

And, of course, it will simply make Gerber files and Excelon drill files, at the click of a button.

It is also rather nice being able to design for double sided with fine tracks - it makes it way easier to track boards and allows me to make a much smaller board.


So, I sent the Gerbers to PCBTrain. And two days later, they arrive. they look good.

They look nice. They are their quick turnaround product, which is copper with silver, and no solder resist or silk screen, but they work.

I even got good at soldering things like the USB-C connector.

The trick was lots of flux, and a good soldering iron. Tinning the pads first and then just heating the pin to fix it. It takes a bit of practice :-)

Tiny ESP32-WROOM-32 board

My first project to test the whole process was a minimal usable ESP32-WROOM-32 board. The idea was a board with USB-C or DC power, several GPIO on a connector, and built in serial for programming. The challenge was to make a small as possible. I think it came out well.

The result is tiny. But with 5 GPIO pins it is very flexible for all sorts of IoT applications. There is no way I could have made this on a single sided or milled board.

I also made each GPIO have pads for a pull up resistor, or, if powering something from the connector, a zero ohm link. This works well for things like a DS18B20, but could be connected to all sorts of things like an RFID reader, a GPS module, or whatever. It has enough pins that this module could run my ASR33 teletype, and be a lot smaller and neater than the node-mcu board I am using now (so that may happen).

One nasty hack was the USB connector I am using is through hole - as that makes it a lot more robust (their is nothing more annoying with these than pulling the connector off the pads by mistake). To do this I ended up with holes going through 4 of the GPIO pads on the ESP32 module. But it has a lot of GPIO, and they default to input, so no problem, as long as the software knows not to use them. Obviously I had to tell the schematic that they were grounded too.

Another trick was the the Pololu module was not fitted using pins. I could use pins and clip them short, but as it happens, with the through plated holes, just solder down the holes secures it nicely. I only use 3 of the 4 pins, as that would have put a pin through the ESP module pads too, and not in a good way this time. I did have to remember to put a pad under the 4th pin else it ended up on a GND fill which would have been bad.

The end result really is quite small.

FTDI FT230X USB/Serial

The final new bit for me was building in serial for programming. Previously I had made designs using a 4 pin SPOX connector which connected to a serial/USB lead. This takes quite a bit of board space. So I investigated serial USB chips. FTDI seem to be the king of serial USB, and they do a small 16 pin QFN-16 package module, the FT320X. I checked some videos of people soldering QFN packages by hand, and figured I'd be able to.

It is a nice small chip, connects to USB, and provides serial with Tx, Rx, RTS, and CTS as well as 4 configurable CBUS pins. It even has a 3.3V regulator, though sadly not enough to run the ESP32 - that would have been awesome!

There is one small downside - it needs a few passives. That is a pain on a small hand soldered board, and where I am trying to make it tiny (just for fun), so I built without the passives. This will mean the USB is not properly impedance matched. But it is good enough for programming in my tests, and that is all the serial lead is actually for. So what the hell? OK, yes, it annoys me to cut corners even on a fun board and I may try to at least squeeze the 27R series resistors at some point. I am not normally one to cut corners.

However, the small size, and passives, were not the only issue. I decided to connect RTS to the EN (reset) pin on the ESP32. This is a common trick and the tools, like the ESP IDF flash tool, pull RTS low and then high to reset. It is risky in a way as a "normal" serial port will make RTS low when ready for the ESP to send data, but it seems the common tools do not, so it works. What I was unsure of until I tested is that this pin stays high when otherwise idle, and when connected just to power and not a USB driver, and so on. It does. It works. Yay!

However, to program an ESP you need to put in to boot mode, and this means pulling GPIO0 low during reset. Most boards have a button for this which you have to hold when programming. Apparently some do a trick with DTR, including the ESP IDF flashing tools.

Snag! There is no DTR on the FT230X. What is extra weird is that DTR is not one of the CBUS pin modes, so you can't even create a DTR. This seems an oversight as other FTDi chips have DTR, DSR, DCD, and RI, so why are they not options on CBUS pins? Why does this matter? - well a normal serial driver will be able to control RTS and DTR as they are standard pins. To control special pins like CBUS on the FTDI needs code written specifically for the FTDI, not just any serial connection. So not using DTR makes it "special".

I considered just adding a button, but a bit more research has led me to use CBUS0. The problem then is how do you use CBUS0? It has multiple functions (not DTR, sadly), which can be configured.


The answer is that you programme the EEPROM in the FTDI chip. This lets you set a manufacturer, description, serial number, PID/VID, and a load of settings. One such setting is what each CBUS pin does. One of the options is a GPIO. So that is all I have to do - zap the EEPROM with the right data.

Snag! There is a tool, ftdi_eeprom, that is simple to install on a Mac. But it only lets you set a few things from a config file, and not CBUS functions. And even though it will read the EEPROM to file, it won't just write a file to the EEPROM - it insists on "building" it from your config, even bits you might have deliberately set in the file, like CBUS functions. Arrrg!

So I ended up making a tools, ftdizap, which allows me to simpley set certain (well, any) settings in the EEPROM. I also made it work the CBUS pins when set to GPIPO mode so it can control the output on the CBUS pins directly as a command line tool.

This means I can flash by using ftdizap to set CBUS0 low, then running make flash, then setting CBUS0 high and resetting with RTS low/high. It works on my Mac and on my linux machine. So, simples. A minor tweak to the make file, and I can simple make and flash new code in one go - no button pressing. The make monitor also works, leaving RTS high, allowing debug.

I also set the other CBUS pins to various modes and connected to GPIO on the ESP32. This allows the code to tell if in a "charger" mode, or if simply "not connected to a USB host", or if "put in to USB sleep mode". All of which could be useful in some circumstances.

What next

I already have another board design - this one slightly more useful. It is a small board the same size as a 1.5" RGB OLED display modules (commonly on Amazon). It fits all the necessary components between the board and the display, including a USB-C socket, and the FT230X. It has an 8 way SPOX socket so providing 7 GPIO pins. It has pads for DC power alternative to USB power. It also has pads to allow an SCD30 CO₂ module to be fitted to the back to make a complete environmental monitor. The pull up resistors on the GPIO allow it to be set up for a DS18B20, and the choice of SPOX sockets allows for a 3 pin SPOX plug connected to a DS18B20 to go in to the 8 pin SPOX socket nicely. It should make for a very flexible board.

As you can see KiCad does a nice rendering of what it will look like.


Yes, the code, and the boards, are all on my GitHub. Just bear in mind that they are likely to have several updates over the next few days.


Selling a house (week 1).

I had planned to post more details of the house itself here. It has taken a month with workmen doing a lot more than I had planned to make the place perfect (including new lawn, new kitchen floor, several new carpets, and lots of generic decorating). The end result is rather nice.

It went on the market on Sunday, and within hours we had viewing requests. Viewings on Tuesday and an offer on Wednesday, so just waiting for estate agent and solicitors to do their thing now.

Of course there is no guarantee that this will not fall through somehow, so do take a look :-)


At this point it is all down to how quickly solicitors, mortgage lenders, surveyors, and so on, can act. Unlike when I was buying a place, I ensured my solicitor had all of the necessary paperwork right away. I am trying to ensure we are in no way the critical path here. We'll see how long it takes.