An open source prop: Part 1

After going to Alone: Discord LARP I ended up chatting with the organisers on social media. They had some 'hackable locks' in the game that worked OK but were really just touching a couple of pads with a wire to make a beep and change an LED.

There were several game organisers playing and chat turned to making a generic 'hackable lock' for modern/sci-fi LARPs. It's something lots of LARPs will have needed or reinvented over the years. We might use them ourselves in March.

So I'm now smashing away at code for a generic lock prop based around the old favourite of an RC522 RFID reader, WeMOS D1 mini, LEDs and a piezo sounder.

The plan is to totally open source everything, with a build guide, 3D printed case, software that is pretty flexible and can be tweaked to behave in different ways.

This has already spawned two Arduino libraries. A tap code library for taking input codes on a single button (for hacking/admin) and an RFID authorisation library. The big plan is for a Web Portal interface, probably using ESPUI again.

Churning out some libraries means the main chunk of code for the prop is much less spaghetti-like and the libraries should be eminently re-usable. I really need to do this with lots of other things I've made or started to make.

Oh and obviously the Cyberdeck prop is on hold again, with no game to use it at for a while.


Quick cyberdeck build: Part 4

Yet more messing about with the design but I think I've finally roughed out how the front panel layout will work. I think it'll look decent so I've quickly (ha!) printed one off to get a feel for what it's like in the hand.

Printing time is quite long, so iterating the design is slow even when broken down into separate modules.

I've added a button on the left, which will do 'select', allowing you to use the trackball with one thumb and click with the other as push to click trackballs are always a bit awkward.

Generally it looks like things will fit easily. In fact I think I'll do a version with two buttons on the left and a third on the right. You almost want four buttons for Android though as you've got 'select', 'back', 'home' and 'task list' so this might force me back to using the trackball to select things.

The battery shown might not be the one I finally use, it's quite old and was recovered from a dead tablet but finding something about the right size shouldn't be hard.

The space in the rear of the phone where the original battery went is going to be used for the Arduino Leonardo that turns the keyboard, mouse and buttons into USB HID devices and assuming I continue with the original plan a TP4056 charging board.

I'll then use a little micro USB breakout to conveniently mount a charging socket on one of bottom corners, although with another couple of button breakouts this will be quite cramped. Were I going totally OTT there's actually space for one of the tiny USB hub boards I have, but I think then situating the external ports for plugging stuff into the device could be hard.

There is space for a Raspberry Pi Zero W, which might be an interesting addition but the phone is actually a more capable computer for any task that doesn't explicitly require a Linux system.

I'm also going to have to face up to the fact this 'quick' build won't be ready for the LARP this weekend. I could rush it and have a version made up but it's actually a bit too physically large to act as the 'covert portable terminal' that fits what the character needs. So I'm probably going to stick some spray paint on an old Sony Ericsson Xperia X10 mini pro, which is an ancient Android handset with slide out keyboard that will work just fine as that prop.

Quick cyberdeck build: Part 3

Did I say quick build? I was obviously mistaken.

I have spent far, far too long messing about trying to get the 3D printed mounts for the trackball and keyboard, well mostly the keyboard, working to my satisfaction.

The keyboard has a kind of rounded kidney shape to it and I don't have the modelling skills to model it exactly so I've done a lot of tweak, print, repeat today.

Also, I did a little more messing with the Arduino library I wrote yesterday and submitted it for inclusion in the Library Manager.

Also, I seemed to kill the cheap clone Leonardo board I was testing with so had to dig out and solder up the headers on another. Obviously not before I wasted time wondering what was wrong. They're tough and 5V tolerant so no idea how I killed it.

Also I faffed with the idea of using a different Android phone than originally planned as it's much smaller but it only runs Android 6, which is frankly way too old and won't handle Termux.

Note to self: Do not get involved in trying to install LineageOS on the Moto G4+, it needs to stay working.

Quick cyberdeck build: Part 2

First, shave your yak.

In the cyberdeck I would like to use this little RGB illuminated trackball sold by Pimoroni. There's python support, but no Arduino library support available.

So I wrote an Arduino library for it.

That's essentially a day wasted. The code isn't consequential but instead of smacking it straight into the spaghetti code I'm going to stick on the Arduino inside the cyberdeck case it's now a library with methods for things I don't need like the onboard LEDs.

Quick cyberdeck build: Part 1

I have, for some time been nibbling at the idea of building a 'cyberdeck' prop for sci-fi LARP which is also a practical, usable device. There's been a ton of these built out of Raspberry Pi machines, but they're generally quite chunky to carry around and often seem to be display pieces more than anything.

The cheapest way to stick a fully featured computer with a screen in a prop is to re-use an old mobile phone and I happen to have a Motorola Moto G4+ which I replaced a few years back. It's still a very usable Android device and mostly I retired it due to charging/battery issues.

After soldering up a connector to the old battery tails it works fine with any old LiPo, within reason.

For it to not just be a phone in a case, it needs a keypad and other connections so I started messing around with an M5 Stack card keyboard I have.

The action is pretty nasty but I persevered and ended up with a 3D printable holder and levers to which I tried to add keycaps.

This does just about work but was still very disappointing and even with a lot of finishing work was always going to be nasty to use and probably not very robust.

The staggered triangular keycaps were a deliberate Blake's 7-esque choice that don't really work without a surround of some kind.

With a game that could benefit from me having a 'cyberdeck' happening in a week I dusted off the idea again and suddenly remembered I have some old Xbox360 chatpads in a box.

These were bought with similar ideas in mind several years ago and I've done nothing with them. These are significantly better than the M5 stack keyboard and are also illuminated in use.

Information on hacking these into other devices is generally very old and often a sea of dead/obsolete links, but I quickly found this video that gives you just enough information to make it work. The example Arduino sketch worked immediately which I call a win.

It's now been tried with the phone and in the dark the illumination works very nicely. That's the keyboard sorted, but I would also like to add the tiny I2C trackball I've got kicking around. Then it needs a case designing and printing. When I started down this road a couple of months ago I made a surround that holds the phone tightly so I just need to do the same for the keyboard and other gubbins.

After fitting the trackball there should still be some pins over on the Arduino. So I might wire them up to some LEDs for blinkenlights, or perhaps to have some extra buttons.

Mixing my ESP-Now mesh, ESPUI and physical objects in a LARP experience

As I've mentioned before, all the stuff I work on tends to be to make props for Live Action Role Playing (LARP) events. LARP comes in many flavours but the variant I'm involved in has people solving problems and fighting skirmishes with Lasertag weapons as part of a collaborative story, usually with a science fiction element.

With the arrival of the pandemic, almost all LARP except that which was conducted via video chat went on hiatus, including a game we'd been planning for a couple of years.

However things kicked off again for us on the weekend of 3-5 September 2021 with an 'anthology event' that consisted of several short games. After a chat with one of the game organisers I agreed to set up some stuff to round their Cyberpunk themed game out.

We play on exclusively outdoor sites, almost always with no access to mains power or permanent Internet service so everything needs to be self-sufficient for the duration of the game. Also with only a couple of hours of setup time available it needed to go out quick and dirty right beforehand.

I put together several elements that got included in the game, spread across three different locations on the site.


When to use send callbacks in ESP-Now

Long time no post, I've been kind of away from microcontroller project work recently. Having picked up coding again I've come across an interesting issue with ESP-Now on ESP8266.

It's not really an issue as such, but might catch you out.

Most of the time, when you send ESP-Now packets with...

esp_now_send(uint8 *da, uint8 *data, uint8 len);
...there's a temptation to assume they will always be sent.

However packets are not sent until the core gets around to it.

If your code does some slow blocking work after asking for the packet to be sent, the core will abandon sending the packet silently. You should instead register a callback function with... 

esp_now_register_send_cb(esp_now_send_cb_t cb);
...and only continue with other activity, especially slow blocking activity, once that occurs.

My code was registering callbacks but as all it seemed they did was confirm a send I didn't really need confirming, the functions were stub ones where I'd commented out everything of note.

Most of the time this won't catch you out, but the timeout before the core abandons sending is rather short. A very dirty workaround might be to delay/yield for a short while after sending, but flagging the send as successful or not in the callback is the better option.

I had been struggling with unexplained packet drops in certain parts of my big ESP application and waiting for the send callbacks has eliminated these. A less I/O heavy application would probably never experience them.

ESP-Now BATMAN Real-time clock

I'm still slowly adding features to my retro computer terminal props and one of the things they lacked was a real-time clock.

So far I've been using 'mesh time' a millisecond uptime value that syncs across the mesh network.

I've now added the option for one or more nodes in the mesh network to share real-time clock information. This leverages the built in libraries for time that are included in the ESP8266/ESP32 SDK. It's just an offset from the mesh uptime with some simple logic to pick a preferred real-time source. Much like the mesh uptime it's not millisecond accurate, but good enough for human scale time, eg. the timestamps on chat messages. It also shares timezone information to correctly handle daylight saving.

At the moment I'm testing with SNTP (which is supported directly in the SDK) but my plan is it can take any RTC source. My code just checks "is the time set?" before sharing time so this should be trivial. this could include manually setting the clock from a watch, but I suspect it would drift fairly quickly. I'll attach some GPS modules onto a couple of my nodes for a time source in the field.