Monday 21 December 2020

Slack & WhatsApp controlled Christmas Tree Lights

December 2022 update: I've developed this idea further, giving the project more features, including the ability to blink lights in morse code. The original post remains below.

With the Covid-19 pandemic still dragging on, it looks like things won't be back to normal in time for Christmas.

At work there was discussion about Christmas parties, team building exercises, and other such things to try to boost morale.

I'm currently working on a project that uses WS2812 RGB LEDs (which'll no doubt wind up published here eventually), and on a whim, wondered if there existed fairy lights that use the same chip.

Turns out, there are. So obviously I had to buy some.

My Christmas tree is positioned so that is can be seen in the background when I'm on Zoom calls with work, so I thought it'd be fun if I could setup some system that would let my colleagues interact with the lights.

Once the lights arrived and I'd tested them, I got to tearing them down.

Wiring

The power supply/controller is a USB unit. I was powering it from a phone charger adapter. That also contained an infra-red receiver for the included remote. I thought about potentially working that angle, but the remote had limited options, and I wanted to offer more granular control.

From the controller to the lights was just 3 leads, which I rationalised must be +5V, Ground, and Data.

I cut the wire, figured out which was which, and connected in an Arduino. It wasn't able to provide enough current to drive the LEDs itself, to I made use of the existing charger - the charger continued to be connected to +5V and Ground, sharing the ground with the arduino's ground, and then the data line connected to the arduino.

The circuit. It works fine like this for short periods, although I later found adding a 470 Ohm resistor between arduino D12 and the first LED increased reliability over time.

 

Arduino code

I ended up using the PololuLedStrip library, and modifying the existing code for that.

Initially I'd hoped to be able to provide full RGB control, but it just seemed that the sheer amount of data being sent meant bytes were being lost, or I had to slow the data rate down to unusually slow.

Eventually I settled on using 10 preset colours, defined with numbers 0-9, being sent as a 100-character serial string - 1 character (colour) per LED. This seemed to be the best trade off of functionality and reliability.

The code can be found here.

 

The 'server'

This is a simple web server that accepts GET requests for one endpoint, and is simply there to provide a go-between for the messaging apps and the serial port.

As each LED is individually addressable, I wanted to create a format that would give users control at that level. I settled on messages with the following JSON structure

[1,"colour"]

or

[[1,2,3], "colour"]

where the numbers are the IDs of the LEDs, and the string is one of the available colours.

This would let them control either an individual LED or a series of them in an individual command.

Hooking into Slack and WhatsApp

As at work we use Slack, and we have some previous integration with it, it seemed like the obvious choice.

However, their API functionality is heavily focused on HTTP endpoints, and requires a server to interface with it. That's fine for 'proper' development, but when I'm just messing around at home, I don't really want to be dealing with opening up my home network and all that entails.

Really what I wanted was some client-side plugin functionality. There isn't an official API or interface for one, so I had to improvise.

Using the web-browser interface, and making use of Firefox's Javascript console, I added a MutationObserver to the page, and made use of the DOM to narrow in on the message elements, and get the contents of the latest message in whatever chat/channel the user was in.

The javascript for Slack can be found here.

Once retrieved, some basic checks are done to make sure that the message is in a usable format and hasn't been acted upon already, it's then passed to a local server via HTTP, where it's processed, converted to the serial format used by the arduino, and sent onward to it.

After realising how useful MutationObserver is for things like this, it was quite trivial to do the same for WhatsApp.

The finished product


Thursday 10 December 2020

Live-edge oak spotlight light fixture - part 2 - adding ambience

In my previous post, I built a hanging light fitting of live-edge oak and recessed GU10 spotlights.

There is actually more to the project.

Sometimes, spotlights can be a bit overpowering, and it's preferable to have some ambient, indirect light.

During construction, I had the idea of creating this light in a way that would allow use of the spotlights, an ambient light, or both.

To create the ambient light, I used LED strips on the reverse (upward-facing) side, to reflect light off the ceiling.

I cut some thin strips of oak with a 45-degree angle and mounted them in a rectangle on the back - angled side outward, to help direct the light. An RGB LED strip was mounted all around this.

Control

I initially thought of using the LED driver that tends to come standard with rolls of LED strip, but as the existing wiring leads to only one switch, without some rewiring through the ceilings/walls, it would be limited to either having both the spotlights and the ambient light on, or just the spotlights on without the ambient light - it would not be possible to have the ambient light on without the spotlights.

In order to combat this, and to lay groundwork for a potential future project, I included a solid-state relay and an Arduino. The arduino would drive TIP31 transistors to drive the 3 channels for the LEDs red, green and blue, and additionally control a solid state relay which would act as the switch for the spotlights.

The idea would then be that the light switch would remain on, more like a utility switch, and then all control of the light fitting would be handed over to the Arduino.

 

Power

 

The original wiring sketch.
it's just a rough sketch,
not a proper wiring diagram.
 
The LED strips take 12V, and the microcontroller takes 5V, so a PSU is needed to bring the power down to usable levels.

For this I used an old net-book power supply. This was wired into the back of the light fitting. Caution is needed to make sure that nothing too powerful is used, as typically a houses' lighting circuit breaker is tripped at a much lower current than the mains sockets.

 

Revised to include the additional components
This would normally be plugged into a wall socket, where it's plug would have a fuse. However in order to wire this into the lighting wiring, the plug would need to be removed - obviously this introduces a safety concern. To ensure that this would still be fused, I replaced the wall switch for the light to one that includes a fuse, ensuring that the light is behind the fuse.

 

Communication

To communicate with the Arduino, I used a cheap HC-05 bluetooth to serial adapter, the same as I've used in other projects like the Bluetooth Macro keyboard app.

The arduino receives 4 bytes, followed by newline characters. These correspond to 1 byte each for the red, green and blue channels in the LED strip, and the final byte is either a simple 0 or 1 to indicate if the spotlights should be on.

For now this is sent by pairing with my phone and using a bluetooth serial terminal app from the Google play store. I'll probably create a more custom app in future, but for proving the concept, this works just fine.

 

Saturday 28 November 2020

Live-edge oak spotlight light fixture

The basic idea

The idea is that the fitting uses GU10 spotlight fittings like those typically recessed into ceilings.

However, instead of recessing them into the ceiling, they're recessed into a piece of live-edge wood, which is hung from the ceiling like a more traditional light fitting.

The woodwork

There's not much really in the way of woodwork in this project, just clean off bark and splintery bits from the live edge, preserving as much of the edge as possible.

Quite a bit of sanding was also needed to clear up the surfaces.

The end of the board I had was cleanly sawn which I thought detracted from the live edges, so I broke the corners down with a carving disc on an angle grinder.

Creating grooves for
the spotlights latches
Then measure the centre line. I started by taking the average width of the board and working from that, but there is some leeway - having both sides be live edge makes this near impossible to find a perfect centre line, but ultimately as long as it looks central to the naked eye.

The spotlight fittings are not designed to go through the thickness of the board - after all, they're intended for plasterboard ceilings. While it won't affect the functioning of the light, it means that the spring loaded clips that latch. To work around this, I used a forstner drill to thin around the edge of the spotlight holes where the latch would sit - This is easier to do before the main spotlight hole is cut out, to stop the forstner bit from slipping.

Then I cut out the holes for the spotlights by drilling a pilot hole and widening with a jigsaw.

Test fit of one of the light surrounds

Wiring the spotlights

The three spotlights are wired in parallel, split across 2 junction boxes. Having them in parallel means that if one bulb was to fail, the others could continue to function.

 

To make installing the light easier, the lead that connects from the ceiling to the wood itself included a 'kettle plug' style plug and socket, simply so that the wiring could be done on the workbench, and just plugged in at the time of installation.

 

Mounting

The ceiling roses were purchased, and have simple hooks on them for hanging the chain.

Eyelet screws were attached in the back of the wood at each corner, from which the chain was attached.

Enough leeway was given on the chains so that adjustment could be made to ensure that the light hangs flat.


Friday 23 October 2020

Combination pinboard and cinema poster frame

Even before Covid-19, people were already starting to talk about "work-life balance", and it's effect on health.

When Covid made working from home the norm, maintaining that balance became even harder, especially for those whose homes are more open-plan, meaning the same rooms they go to relax could end up also being where they go to work.

This project is aimed at exactly this problem.

During the day, the frame can be opened up, to reveal a pin-board where all the usual work notes and paperwork can be pinned, but once the working day is done, the frame can slide closed, shutting the metaphorical door on office life, leaving just the poster visible, more in fitting with a relaxed home lounge look.

The 'front' (poster) frame

This frame is more akin to a traditional frame, but as it will be the sliding component, and so not directly mounted to the wall, keeping the weight low is important.

As with the back frame, the joints are mitred half-lap. The same oak is used, but much thinner (roughly half inch). A rebate is cut in to seat the glass, poster and backing board.

With weight limitation in mind, thin perspex was used in place of glass. The rest of the frame is pretty standard - a sandwich of the perspex, the poster, backing card, and then hardboard (in this case, up-cycled panels from a hollow core door) all held in place with some pins.

The 'back' (pinboard) frame

To start with, this is a standard mitred half-lap jointed frame, albeit deeper than a normal frame - about an inch. It also does not have any rebate or groove, as it's not needed.

The pin board that I'm re-purposing is another of the same style I used for the desk organiser. It's smaller than the poster frame, but this is by design to allow room for the sliding mechanism.

The two long sides are removed.

These are replaced with longer oak sides that attach it to the frame. On one side this is simply screwed into the larger frame, and on the other, small grooves are cut into the frame for it to fit into, similar to a tenon.

 

This second side leaves approximately 4 inches between the edge of that inner frame, and the edge of the main frame.

 

The rail mechanism

2 4x2" pieces of oak are drilled with a 20mm hole lengthways, and then glued in place at the top and bottom of the frame, filling this gap.

Then, the entire frame is cut lengthways, halfway through these pieces of oak, leaving 2" of it on either side. These will form the rails.

The 20mm hole is extended through the 'long side' part of the inner frame, at both ends.

The 'thin' part of the frame - the one without the pin board attached, is the part of the back frame that the front frame will mount to, and be the part that slides out.

16mm aluminium tubing was inserted through each of the channels. On the thin side of the frame, a screw was driven perpendicular to the 20mm hole, fixing the tube in place and adding some support to the glued in block.

These two tubes are then threaded through the 'fat' part of the frame.


Joining the two frames

Screws from the back frame are driven through into the front frame on the left hand side (the 'thin' side).

To prevent sagging when the frame is opened, leather loops are attached around the other end of the tubing and screwed into the back of the front frame.

This makes the sliding part of the frame counterbalance it's own weight.

The whole thing was finished with a coat of danish oil, 4 angle brackets were added and it was mounted to the wall.

 

 

Friday 11 September 2020

Boosting broadband speed with satellite co-axial cable

When I moved into this house, there was a lot of extraneous wiring. Phone line extensions that went nowhere, that kinda thing, so I ripped out everything back to the master socket by the front door.

When fibre was enabled, I had a visit from an Openreach engineer, reporting a fault detected on the line - the case was the old master socket had some corrosion, so he replaced it with a new one.

However, I want to move all my network gear to the under-stairs cupboard, and branch everything from there. As I don't use a landline, this would mostly just mean Wi-fi and a few ethernet cables.

There's a not insignificant cost to have Openreach come out and move the master socket, so I'd rather avoid that. It's also not something you can really do yourself - the master socket marks the point in the connection where the providers responsibility for the wiring ends and yours begins. If you tried to move it yourself and screwed up, there's a significant charge to that too.

Just using a phone extension lead works, but slows the broadband speed noticably.

Unfortunately, due to the age of the phone system and it's various evolutions over the years, finding decent, up to date information is not as easy as it should be.
I manged to put together a DIY solution that boosted my broadband speed by approx 50% (~14 Mb download speed with regular phone extension, to ~21 Mb using my solution)

This was done by combining a few other ideas and sources of information.
This is what worked for me. Your results may vary, and usual "don't try this at home" warnings apply.

Moving the master socket without moving it

I found this guide which shows a master socket with 'A' and 'B' connections, which it states, you can run to another socket using CAT5 network cable, which will have a similar effect to moving the master socket, as it bypasses a lot of the filtering of the sockets, and CAT5, being twisted-pair cable, has better shielding qualities than regular phone extension.

But unfortunately, my master socket is the newer type 'NTE5C' socket, so it doesn't have the same connections.. It does have a similar A and B connector, but it's on the provider side of the socket, and is in use, so I don't want to mess around with that.

It give me an idea though. Even if that route is out of the question, a lot of the interference comes from the cabling used. If I were to create a phone extension lead from CAT5, it should still be an improvement to a regular phone line. 

Looking up how to install a telephone extension on the NTE5C type of master socket led me to this video which shows using the front panel to connect an extension using pins 2, 3, and 5.


Pins 2 and 5, according to the first article, are the equivalents of A & B.

So, what if I put in a telephone extension using that connector like in the video, but instead used better cable as per the article? In theory, the speed should improve due to the increase in cable quality, but would lose a bit because a microfilter would be required (because it's not been pre-filtered.)

I also thought, if CAT5 beats regular phone cable because it's twisted pair gives it some shielding, then wouldn't something more shielded so even better? I had a usable length of co-axial cable, the type used by satellite dishes and antennas.

This is a single copper core with a mesh-like shield all the way around it. These would provide the connections to pins 2 & 5 (I used the core for pin 2, the shield for 5, but I don't think it'd matter which way round).

The article does recommend solid core wire, which the core of the coaxial is, but the shielding is not, so I guess there may be some performance trade off there.

This was wired to a regular phone socket under the stairs, in which there's a microfilter and the router.

Initially the speed fluctuated a bit, but once it bedded in, it settled on a speed (as reported by the router) of approximately 21Mb, which is up from the approximately 14Mb that was achieved with the same length of regular phone extension cable.

I'd be tempted to experiment further (ideally with something with twin solid cores and shielded.), as there's still a bit of room for improvement - at the master socket directly, the router could get 26Mb - but for now it's fast enough.


Friday 21 August 2020

Straight razor from table saw blade

So a while back I replaced the table saw blade in the workshop and got the idea in my head to try and make a straight razor out of it.

I sketched out a quick design and then cut it from some scraps of redwood (the same stuff I used in the ring box project - not sure if that's the correct species, but it's wood, and it's a red-ish colour, so close enough.) on the bandsaw. Fortunately I had two scraps the same thickness, so I needn't worry about the thickness of each of the scales (sides) being identical.

The blade itself was sketched out in marker on the old table saw blade and cut out with an angle grinder. Once the rough shape was done, a mix of bench grinder and rotary grinding tools were used to refine the shape.

The gap between the 2 scales of the handle was padded out using some brass sheet, cut to match the shape of the scales, whilst including cut out space both for the blade to fold in to, and to allow the tang to rotate into when the blade is opened.

This, and the scales were both epoxied together, and then two holes were drilled and brass pins added, for additional strength and their own aesthetic quality.

The third brass pin provides the hinge that the blade will pivot from to make the opening and closing mechanism.

Before the blade and handle were put together, it was easier to finish each part separately.

In the case of the handle, this meant sanding to round off the edges and make it more comfortable to hold, and a wipe out with danish oil.

In the case of the blade this meant a lot of grinding, sharpening and honing to get it to a sharp enough edge to cut hairs. With hindsight although it probably isn't the best steel to use for a blade, it is sharp enough to shave with - it just requires frequent honing.

But, at the end of the day it works, I'm pleased with how it's turned out, and I learnt a bit more about blade making and the dark arts of sharpening and honing along the way. I also now totally get why some people fall into this particular niche rather than just more general metalworking... I'm actually quite tempted to go find some better steel and make another already.

Saturday 8 August 2020

Tattoo Machine for Leatherwork

This is the fifth of my 'Lockdown Projects' - Projects made during the Coronavirus lockdown, which I limited to one week, and only using materials I had to hand.
 
Before I start this write up I just want to emphasize this tattoo gun is not intended for use on anything other than leather. Using it for anything else risks a number of heath issues.
 
With that out of the way, I’ve been intrigued by the idea of using tattooing as a way of patterning leather. A quick search shows that it’s not an uncommon practice – particularly it would seem, for leather boots.
 
The theory goes that given that leather is essentially just skin, it would tattoo in the similar way to a person.
 
After seeing a home-made tattoo gun in an episode of Orange is the New Black years ago, I’ve had the idea in the back of my head to build one and try it.
 
During lockdown, it seemed like a thematic fit to finally hack one together.
The body of the machine is from a mechanical pencil. 
 
The main needle mechanism is a sewing needle, with an empty metal pen refill, and a hook made of a bent paperclip. These bits are epoxied together for sturdiness.
The motor was taken from a handheld fan. A button provided the connection between the needle mechanism and the motor.
 
The bracket was a small bit of metal from the junk bin - that was probably once part of a printer or something similar I’d previously dismantled.
 
The motor and bracket were fixed together with cable ties and a final cable tie tensions the mechanism so that there’s less rattle and wobble in the needle.
 
 
Initially I used 2xAA batteries for a power supply, but after a bit of testing, it needed more power, so I replaced that with a USB connector.
 
Obviously I didn’t have any tattoo ink to hand, so I just used leather dye to test.
 


Monday 22 June 2020

Context-sensitive macro keypad

I've been doing quite a bit of 3D work recently for both 3D printing and VR software development.

The main software that I use for 3D work are OpenSCAD and Blender.

One annoyance I have is that the short cut keys each use for standard things such as scale, rotate, move, etc. are all different, which makes switching between applications more awkward than it need be.

So my latest electronics project is to create universal short cut keys - a physical keypad that has single button presses for those functions, but then translates them into the relevant keyboard/mouse presses dependent on which application has focus at the time.

The hardware
As we're still under lockdown due to COVID-19, I'm restricted to using only components and tools I have got at home, like with the USB Switch project.

The keypad itself is this mechanical key switch tester.



Unfortunately the eighth switch was lost some time ago. I'll leave the gap there as potential room for expansion in future though.

The controller is an Arduino Pro Micro. I thought about using a different microcontroller, however the real sticking point was my lack of a spare USB to serial adapter.

The Pro Micro helps keep the overall form factor nice and compact, whilst keeping the programming side of things straightforward.

I picked out some LEDs to backlight the keys as there was spacing for them, and the keycaps are translucent. I tried to find all different colours, but my inventory didn't allow for that, so there's a couple of duplications.

The rest of the hardware is just some diodes and resistors, a bit of perfboard and some scavenged wires.

The hardware is wired up like so:
Quite simply, there's two matrices, one for the switches, and one for the LEDs. Because of the missing key, one column in each only has three connections.


The case is just some plastic container that would otherwise have been trash. It wasn't a perfect fit so required some Dremel-based customisation.

The Firmware

The Arduino will stay set up as a USB to Serial device rather than as a keyboard because there needs to be bi-directional communication - the Arduino needs to also receive input from the application in order to control the lights.

This post was a useful resource when putting together the matrices.

The full source is available in the project on GitHub.

The Software
The software is a java desktop app that communicates with the Arduino using jSerialComm. It controls which keys are 'set' and indicates this with the LEDs.

The interfacing with the other applications comes from a thread that uses system calls to the 'xdotool' linux command, reading in the output of that command which is the name of the current window that has focus. There's room here to make the application multi-platform, by implementing a similar Windows command in something like AutoHotKey.

If the window matches the defined rule set, the relevant keys are highlighted and a thread monitors serial input. If that key is pressed, java built-in Robot class sends the relevant commands to the application.

As with the firmware, the source is available on GitHub. It's in a pretty simplistic state at the moment due to the one-week time limit I've placed on these lockdown projects, but there's room to expand and improve in future.

Tuesday 26 May 2020

Tray Stand / Foldable Table

While lockdown has prevented me from being able to get back to many woodworking projects this year, I did manage to cut a few offcuts to size and sand them in order to fashion a stand for a bamboo tray. The idea being for it to be a temporary table or drinks stand in our small patch of outside space.

The construction is a simple X-frame, with horizontal bars at each of the four points - 2 to support the tray, 2 to act as feet. These are joined to the X-frame using a 3D-printed bracket - the SCAD file for this is up on GitHub.

In order to stop the frame from spreading out and collapsing under the weight of the tray and it's contents, the feet were joined with some denim fabric, courtesy of an old pair of jeans. This allows the stand to be folded up, but providing plenty of rigidity during use.

Sewing things other than leather is a pretty new thing to me, my only prior sewing-related project being the lanyard I made a while back. So I'm the first to admit it's not the neatest work, but it does the job, so can't complain.

With the benefit of hindsight, the hinges allowed a bit too much flexibility, allowing the cross-bars to roll. The fabric on the feet alleviates this at the bottom. On the top, the base of the tray has a small lip which helps latch onto the cross-bars - whilst they still roll, it's impact is minimised and the tray/table works fine.

Thursday 30 April 2020

Yarn slack winder

This is another of the lockdown projects where I'm trying to keep myself occupied during the Covid-19 lockdown by challenging myself to a project per week, using only materials from my workshop junk bin.


Background
I don't crochet or knit, but my partner does, and I often end up watching TV whilst having been delegated to idly unwinding a ball of wool.

So, apparently, when crocheting or knitting, it's important to make sure that there's some slack between the workpiece and the ball of yarn. This usually means stopping every so often to pull more yarn from the ball. It can lead to inconsistent tension in the workpiece, making the work uneven.

This gave me an idea to create a yarn dispenser that could be hands-free, and unwind small amounts at a time, to maintain slack.

The OpenSCAD model
The design

The basic principle is to repurpose two rubber rollers (grey) from a printer. The bottom one is attached to a motor, which is housed in the case (red), and supported at the other wide by a support (yellow).
The top roller is attached to two mounts (blue) and is free-rolling.

The two mounts will be attached to their respective parts of the case by screws, where the tightness can be adjusted to allow more or less gap between the rollers, to vary the grip depending on the thickness/density of the yarn.
 
The yarn will be sandwiched between the two rollers, so that when the motor is activated by a foot pedal, it is pulled between the rollers.

To keep the two sides of the frame separate, they were mounted to a small piece of scrap acrylic I found. It's not a perfect size, but it's functional enough for this prototype.

The 3D printed models are pretty basic, but should anyone want to use them, they're up on GitHub.



The electronics

The motor is some generic DC motor that, like most things in the junk bin, was probably pulled from an old printer.

Most of the circuit for this was was salvaged from the old Smoke Machine project.

The SN754410 was de-soldered so that it would function in a more conventional way, powered from a 9v wall wart, and a TS7805 regular to provide 5v.


The circuit. The SW1 switch allows the direction of the motor to be easily switched. SW2 is the foot pedal that will be pressed to feed the yarn.

The electronics were built into an old business card box, similar to the USB KVM Switch.

With the circuit hot glued in place, a piece of a disposable pen was glued to the button to extend it's reach, so that it would sit slightly higher than the top of the box lid. This means the the circuit enclosure also doubles up as the foot pedal - pushing down on the lid pushes on the pen, and in turn presses the switch.

Finished product
In initial testing, it was discovered that the yarn would veer off to the side of the rollers and become tangled. As a quick-fix solution, I used a scrap of leather, punched a guide hole in the middle and tacked it to the input side of the rollers.