Look, look at the thing!
Thing!
So this is a digital convention badge in a 3D-printed case, based around a neat display-and-microcontroller combination (and some other components) from Pimoroni. In the video you can see the main thing I coded for it:
- My character, complete with color-cycling mane and idle look-around behaviour.
- …and light reactivity. (They also have an alternate for when the battery is getting low. The backlight adjusts for both cases.)
- An easily scannable QR-code (with some human-readable text) leading to this site.
- A Windows 3.1-styled diagnostics readout screen showing the current battery voltage, brightness reading, and (automatic) backlight brightness.
- And, due to camera autofocus, a customized Brompton. Which I am trying very hard not to be a Folding Bike Enthusiast about on this page, because I have microcontrollers to talk about.
This particular build integrates a rechargable battery and, unlike the others I've seen, a charge controller so it just acts as a USB gizmo you can charge on the run with a normal phone charger, laptop port, convenient unattended Protogen, etc. No disassmbling it and fiddling with JST-PH connectors to hook a cell into a special charger every time it runs flat!
Ingredients
This is built from:
- Tufty 2040 (no accessory kit)—this is the main board, with the display and microcontroller.
- Lipo Amigo Pro—this is a passthrough battery charger, which lets you charge it without unplugging it from the device. Make sure it's the Pro!
- Galleon 400mAh battery—a dainty little hard-case battery with an integrated protection circuit and about enough charge to get through a day. It's going around your neck (and possibly on a plane), so limit the energy and layer the protection. (It's also nice and compact.)
- JST-PH 2-pin jumper cable—since the Amigo is pass-through, you need an extra patch cable. You could get a shorter one though, if you find one.
- Recycled rainbow lanyard—yeah, obviously you can source your own thing here. But you may need to adjust the loop in the case design if the clip is a different size, because I deliberately kept it quite tight to avoid it sliding about and hanging lopsided. This one has a safety breakaway which is strong enough not to pop open from the weight of the badge while moving about, but will help avoid accidentally strangling you. (And if the worst happens and you get a battery fire, panic-tugging at it will get it away from you.)
- Four M2 x 10mm machine screws. These are a bit small for hardware stores. In Ireland or nearby, try RS Online or Farnell.
- Four M2 hex nuts (RS Online, Farnell). There's material variants for these and the bolts, and they're standard (if tiny) parts, so there are plenty of suppliers around; whatever works.
(None of these are affiliate links or anything. This is a hobby and some excited lookit lookit look at the thing I made, look.)
You will also want a USB-C cable (it can be A on the other end, whatever your computer/charger can do), a long-ish, small-tipped Phillips-head (or Pozidriv) screwdriver, and some needle-nose pliers (computer repair tools should cover these). And a little bit of sticky tape.
And a 3D printer. If you don't have one of those find your local makerspace and say hello. (This isn't the hardest print in the world, but it's still a bit fine, so definitely get some help if you're not a seasoned plastic-depositor. I printed it successfully as my first-ever print, but that's because of help and guidance from other friendly smart folk, and a really fancy printer that is a bit more idiot-proof than some.)
Case
I designed a custom case (with a lot of great help from Balázs) that compactly holds this lot together. Aside from allowing for the Amigo board, it's also just two pieces, and both are relatively nice to print—you can get away without supports (although a couple tiny cutouts might sag and need filing if so).
- OnShape project
- This the native format, for a pretty nice web-base CAD system with a free tier for hobbyists. You can export from this to your format of choice, and since it has all the constraint-based sketches, it's the easiest to edit. You want the "Middle layer" and "Back" parts from the "Case" tab.
- STL files: middle, back
- These are exports of the model in the usual format for printing, if you just want it as-is without needing to sign up for OnShape (or if [an archive of] this site has outlived it).
- CAD formats: STEP, IGES (whole assembly with the modelled boards: STEP, IGES)
- These are more useful for importing into other CAD software, and still having some of the geometry intact.
- Schematic drawings: DXF middle, back
-
These don't seem to include dimensions, unfortunately, which doesn't make them super useful.
You can export from OnShape the sketches which are used to construct the modelled Tufty and Amigo PCBs (and battery), and the case, but these are not the complete model and are missing all the information on how they combine and are extruded/cut from each-other, so aren't great either. - Manual drawings: measurements, concept, design
- These are just my initial caliper measurements and design idea, for curiosity's sake!
(If for some reason you want the older version from my first print: STL middle, back. These will need some slight filing down, though!)
Things you might want to customize:
- If you want the smaller top hole of the version I show in the assembly video below, you can suppress the extra cutout in the back piece that makes it taller. You'll need to press microswitches with your fingernail, though!
- If your printer (or plastic) can't do the flexy button built into the back of the case properly, fill it in and leave a hole in its place so you can poke the power button on the Amigo with a pen. (If you're using the OnShape project, there's a suppressed feature for this already you can swap out.)
- If your print is really inflexible, it won't wrap around the Tufty
BOOT
/PWR
buttons at all. You'll have to carve the top wall away entirely around them and accept the weaker C-shape, or have it jut outwards. - If you're using a different lanyard, please check the loop fits your clip!
(If you do make derivatives, the case is under Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.)
Printing
Mine printed in about two and half hours and 14g of PLA filament on an Ultimaker S5. I am not an experienced 3D printsmith, so can't give much advice, but pay attention to:
- The case back prints from the back upward and is straightforward.
- Make sure during layout, you put the middle section the right way up so that the cutout for the power buttons is upward, otherwise you will try to print a big arch and have a bad time.
- The middle section has some very fine slicing from the other side to clear some surface-mount components that go right up to the edge. There should be enough wall that everything stays put, but some areas won't quite be on the bed. One of the support legs for the Amigo is like this, and might try to curl upward a little when it's only a few layers thick. It should sort itself out once more material is added, but watch your print! If you can't make it work, extrude it back down to the bed and file it afterwards.
- Conversely, some of these cutouts are half-mm resolution. If your printer isn't that fine, be careful during assembly you aren't crushing anything if it won't quite sit flush; you might need to file some clearance.
Lookit it go! (Also: side-on timelapse!)
Assembly
Leave the screen protector on the Tufty!
Protecting the screen during assembly is what it's for.
Resist the temptation to peel!
(Since it's nice and clear and flat, I actually suggest leaving it on to protect it while wearing it, too. Better to scuff that than the screen itself.)
Here's an under-seven-minute assembly video, or read on for words:
There's a 4K version of the assembly video on YouTube.
To assemble everything:
- Plug the jumper cable into the Tufty. It's easiest to do this while you can still pick it up.
- Put the Tufty on a nice non-scratchy surface, screen down.
-
Fit the middle section; it's tight enough it should mostly stay put. You can orient it by the inset for the USB port. It helps to pivot it down from around the
BOOT
andPWR
buttons since even the thin section of wall here is not quite enough clearance and will have to bow out just a little. Make sure you don't trap the jumper cable.- This is the fussiest part for being printed accurately (and for if there are any board revisions that move components!). If it won't go flush against the Tufty, look carefully what's catching, don't just force it!
- The most likely pinch points are the LED and the legs of the battery connector, both on the bottom edge. I made the allowance for them a little bigger in the design since my print, but these are some of the gaps I warned may "sag" a little.
- Put a loop or two in the jumper cable to take up slack. (You don't need to knot it, just convince it to curl around.)
- Use a little double-sided (or loop of) tape to stick the battery down to the Tufty—see the picture below for positioning. It'll stay put fairly well without (I didn't at first) thanks to the wire pressure, but better to not have it shift around at all, eh. Beware adding too much thickness with fancy velcro pads.
- Put a loop in the battery wire to take up some of the slack.
- Plug the battery into the Amigo's
BAT
connector. - Plug the jumper cable from the Tufty into the Amigo's
DEVICE
connector.
The Amigo is going to locate on pins in the lid like this (cables disconnected and uncurled to avoid obscuring everything and let it lie flat):
(If you haven't previously checked it's all working, do so before you bolt it together!
Hit the PWR
button on the Amigo and then the one on the Tufty and it should show the colorful menu.
Hit the PWR
button on the Amigo again to turn it back off.
Do be careful not to clonk the Amigo against the Tufty and short anything, but I, uh, did this a few times during all my prototyping and got away with it.)
- Flip the Amigo over and locate it onto the pins in the case back, like in the picture above (although you will probably have to pivot the case up due to the shortened curly wires). If they printed nicely it should hold in place with friction (and pushing the levered button cut into the case back while holding the Amigo down should nicely click the
PWR
button on it). - Close the case back down over the assembly. It will fight to twist gently from the wire tension, but they should stay inside and not get pinched.
- Drop a machine screw into a couple of opposite corners and poke them down with the screwdriver until they pin the two halves together. You might have fight past a little 3D-printing debris, but it shouldn't need much force. At this point the case should relent its fight.
- Pick the assembly up carefully and now work the screws through until they pop through the Tufty PCB. Holding it sideways against the light will help check if you need to wiggle anything for alignment.
- Pinch a nut flat against the protruding bolt held with a finger, and use the screwdriver to turn the screw until it grabs on. Don't tighten it fully yet. This is just the easiest way to get them on.
- Repeat for the other corner, then repeat the process to insert the bolts and nuts for the other two corners.
-
Hold each nut in turn (remember, work from opposite corners) sideways with the needle-nose pliers so it can't just spin, then tighten until comfortably firm. Don't go crazy, you have a fair bit of mechanical advantage here.
- Looking horizontally across the surface of the screen, and comparing it with the Tufty PCB, will let you see if you're overtightening and bending it.
- Clip on the lanyard, you're done!
Power it on (see below) and give it a try! You might want to check if the nuts need retighening every so often, especially as things settle after initial construction, or after a lot of activity. I don't really recommend trying to glue them; you won't have a good way to disassemble it again.
Care and feeding
The flexible button built into the rear of the case turns the power supply from the battery to the Tufty on and off. While it's on, a bright white LED glows out through the case (don't worry, it doesn't come out the front/sides, just the part that's against your shirt). The Tufty, slightly unfortunately, also has its own power button, which is exposed through a slot on the top. Slip your fingernail in and aim for the button on the left.
To turn the badge on:
- Press the button built into the rear of the case so that it glows white from within.
- Press power button of the Tufty through the top slot (closest to the corner).
To turn the badge off:
- Press the button built into the rear of the case so that it goes dark.
You don't need to turn the Tufty board itself off; cutting power to it is enough. (It's a microcontroller; there's no Linux to shut down here.)
The USB socket on the bottom, partway through the thickness of the case, is the one on the Amigo, for charging the battery. While the battery is charging, a red charge LED should glow out through the slots on the back. Charging fully seems to take about two hours (this seems about right for the 400 mAh/200 mA math), after which the light goes out. The Tufty won't know about the charge state while charging—it sees the "full charge" supply voltage.
Experimentally, a full charge lasts about 10 hours running my script, which is doing dynamic display brightness and constantly color-cycling. After that it drops into "low power mode" (3.1v, the shutoff is at 3.0v) and cuts out about half-an-hour later. A simpler script that does less work might last longer.
The USB socket on the side, direcly on the Tufty board, is for programming the microcontroller. Using this doesn't involve the battery part of the badge, so the Amigo can be left turned off (no white LED). (Or it could be charging the battery at the same time, if you plugged in both sockets!)
If you're brave, the "fast charge" on the Amigo should be safe to enable, since the battery has its own protection circuit—see its product page. I haven't tried, so don't know if it'd offer a speedup (in theory, it might about double it).
You can also turn on the badge while it's charging, but it'll slow down the charge. (There's a really helpful review comment on the Amigo that has no URL to link, but basically the charge limiting covers the battery and the device.) Charging it while wearing it is also probably not a great idea.
Software
First and foremost: follow Pimoroni's own Getting Started with Tufty 2040 to get the software environment set up. In particular you should make sure you follow the instructions to update the custom MicroPython to at least version 1.20.6 (for PNG and fixed fixed-width font support). This guide also sets you up with Thonny to upload files to the Tufty from your computer. You should also copy over the updated main.py if you have an old version, since I fixed some upstream memory issues.
Remember to use the side USB port to connect your Tufty for programming!
You should totally try writing your own badge script! Simple, self-contained, interactive projects are some of the most immediately rewarding things to tinker with, and provide a great way to personalize your badge beyond just uploading a custom graphic. The examples (which should also have flashed onto your Tufty with the MicroPython update) have some great pointers.
(To realistically set expectations though, especially if you're reading this while thinking if you want to try to buy and build one of these, the PicoGraphics library cannot really drive arbitrary graphics to the screen fast enough to do full-screen animation. You would probably have to use C++, or the techniques I've used like palette-cycling.)
If you leave main.py
alone, other .py
files you save to the Tufty will appear in the startup menu for you to select from.
This is a great way to be able to switch between entirely different scripts while wearing it, away from a computer.
(Tip: adjust selected_item
, target_scroll_position
, and target_scroll_position
in main.py
to change which one is selected on power-on.)
My badge script
That said, here's a slightly stripped-down version of mine on GitHub under a copyleft license (or a local ZIP). It provides:
- A reworked structure so you can add arbitrarily many screens to cycle through, and they can have their own update logic.
- Automatic brightness control based on ambient light and low-battery status.
- A status screen with some basic min/max history of observed battery voltage, light level, and backlight brightness.
- A brightness cap to extend battery life (use the down/up arrows in the status screen).
- A true battery time remaining estimate, based on real discharge measurements (for the Galleon, but you can measure a different battery if you change the build).
- A lossless palettized RLE-compressed image loading routine (and desktop-side Python script to generate them), so you can use something other than JPEG.
- Palette-cycling, for some old-school 256-color-graphics "animation" (for which you need the lossless pallettized images).
You'll have to provide your own art though! 😺
But can it run DOOM…?
Ha.
Watch this space.
See also
The Mastodon post where I announced this! Maybe it has some discussion or something. Don't ask me, I'm a static webpage.
(There's also a horrible birdsite post, if that's still up.)
Other builds
- Les Pounder designed a case (Printables; Tom's Hardware article about it) for a bigger battery, without the charging board, and with a front piece. There's a remixed version that builds in the AAA-battery holder, which might be appealing to you if you'd rather not have to deal with the extra board and LiPo cell (e.g. if you're super worried about airport security or want to swap out for fresh batteries quickly).
- There are some cases on Thingiverse. I only found these afterwards, chatting with Pimoroni support about design drawings and measuring things with calipers.
If you looked at all this and thought "man, I hate colour, but I love battery life and radio signals", Pimoroni also do a couple of e-ink badge boards, one with wifi. Note you can't just substitute those in for the Tufty here though, you'll need a different case.
Tail of the page
Pimoroni also have a solution to the "can I just drive an individually-addressible LED strip off USB power and a programmable microcontroller and not have to care about logic-level shifting" in the Plasma 2040, which is something I'd wanted for a while. Go check that out if you want to be luminous. (I haven't built mine into anything yet, so it's just been camoflaged as christmas lights for now.)
Also I have an room environment sensing and logging project using a full-fat Raspberry Pi and some slottable Pimoroni expansion boards. (They make a lot of cool things that scratch the "I really don't want to get hardcore into electronics, I have enough hobbies already" itch. Support small businesses who make cool things.)
Seriously though, Bromptons are great, they're tremendously elegant folding bikes and hugely maneuverable in city and even light countryside environments, and…