Thoughts of a geek

25 May 2019

Fairy light controller

Filed under: Computers, Electronics — Tags: , , , , , — qwandor @ 12:34 pm

One of my housemates has a lot of fairy lights. Most of them were battery powered, each by a little pack of 3 AA batteries, which seemed somewhat wasteful. They are great for parties, but turning them all on and off individually is kind of a pain too, so I wanted to make them mains powered, and controlled from Google Home. And as I mentioned in a previous post, I’ve been playing with ESP8266s recently, so I built a controller based on the D1 mini board.

The first version I prototyped with a dual H-bridge board I had sitting around, using each half-H separately so it could control 4 strings of fairy lights, just twisting some wires around the battery terminals. It was a bit messy though:

First prototype, fairy light controller V1

So next I made a somewhat neater version on some stripboard, using a dual H-bridge chip I had sitting around, but with a pair of screw terminals per output rather than just a single ground connection to make it easier to use. I also added some header sockets that could be used to put a resistor in series with the output easily. This meant that rather than being quite so hacky with wires twisted around the battery terminals I could cut the battery box off entirely, unsolder the resistor from there and put it into the socket on my board, and then just connect the wires from the lights themselves to the screw terminals. This made things a bit neater:

Fairy light controller V2, H-bridge chip on stripboard

I also happened to have a bunch of power darlington transistors sitting around, so I made an open-collector output version with them. This let me add the option of using a separate power supply for driving higher voltage loads, rather than just using the same 5V USB power supply as the D1 mini. It was also a bit smaller. (The white terminal block on the left is the power supply input, and the jumper next to it connects it to the 5V from the USB power supply instead.)

Fairy light controller V3, open-collector outputs and an optional separate power supply.

This worked well and was certainly an improvement, but stripboard is still a bit messy, so I decided to make a proper PCB for it. I also found a handy chip with 7 darlington drivers, so I used that. 4 channels still seemed enough so I hooked 3 pairs up together in parallel for higher current capacity. I designed the board on EasyEDA (link at the end if you want to order some for yourself) and ordered 10 copies from JLPCB in China (PCB prototyping services are amazingly cheap these days!) along with the parts, and a few weeks later they showed up.

Fairy light controller V4, all soldered up neatly.

It was indeed neater, so I think this will be the final version. It works well, controlling the fairy lights in the living room.

On the software side, I was able to share a bunch of common code (for the web admin interface and so on) with my previous smart button project. For integration with Google Assistant and Google Home I went via Sinric, which provides a server that the board can connect to, and then can connect to the Google Smart Home API. It’s still a wee bit of a hack at the moment unfortunately, as the Sinric Google Home integration isn’t properly launched so you can only use it in developer testing mode, but other than that it works well. You can track the status of the Sinric launch on GitHub.

If you’d like to make one for yourself, you can find the schematic and PCB design here on EasyEDA ready to print, and the source code and setup instructions here on Gitlab. (See the ‘Smart switch’ / qSwitch section.) And there are a few more photos here. Let me know how you get on!

[edit] Oh, and if I know you / you live in London, I have 9 spare boards and most of the parts available, so if you’d like one let me know. You’ll just have to get your own D1 mini and terminal blocks. Happy to help get it working too.

24 December 2018

Smart homes and ESP8266s

Filed under: Computers, Electronics — Tags: , , , — qwandor @ 11:42 pm

I’ve recently been playing with a bunch of smart home stuff, based around the Google Home ecosystem. I have a Google Home, Google Home Hub and JBL Link View in various rooms, a Chromecast and Chromecast Audio, a Nest thermostat, a bunch of cheap smart light bulbs, and some Sonoff switches for the ceiling lights. It’s pretty cool: I can control the lights and music all around the house by voice, from the smart displays, or from my phone.

But there are a few things missing. As cool as voice control is, sometimes I just want to press a button and have it run some preset action, like turning all the living room lights off late at night when I’m heading up to bed (without waking up my housemates), or turning on all the fairy lights for a party (when the background noise is too loud for voice control to work reliably, and it’s a bit awkward anyway).

Happily, AliExpress has lots of ESP8266 dev boards from as little as £1.70. The ESP8266 is a little microcontroller with a WiFi stack and fairly low power requirements that makes creating WiFi-attached gadgets pretty easy. It can be programmed (among other options) in C++ with with the Arduino libraries. For a nicer development than the standard Arduino IDE I used PlatformIO, which adds a proper IDE and dependency management.

My first approach was a stand-alone button. This can be battery powered, and stays in a low-power standby state (or entirely off, with a little extra support circuitry) until it is reset, at which point it starts up, connects to WiFi, sends a command, and goes back into standby (or powers down). This works well, though I didn’t get as far as finding a nice way to package it up. Without making custom hardware it’s a little bulky, with the battery and everything.

An ESP8266 dev board connected to a Li-ion battery.
An ESP8266 dev board connected to a rechargable battery.

So I tried a different approach. The Sonoff RF Bridge is widely available on AliExpress and elsewhere for under £10. It contains an ESP8285 (basically the same as the ESP8266 but with built-in flash) and a 433MHz remote transmitter and receiver controlled by a separate microcontroller, connected over the serial port with a documented protocol. With the stock firmware it can clone your existing remotes to control whatever devices you may have controlled by 433 MHz remotes, which was not very useful to me. However, the firmware can easily be replaced by simply opening the case (4 screws) and soldering on a 4 pin serial header to the labelled row of holes on the PCB. AliExpress also has lots of nice wall-mounted 433MHz RF buttons that look like normal light switches and can last a long time on a small battery.

With that in mind, I built some replacement firmware for the Sonoff RF Bridge, that lets you pair it with many such buttons, and associate each one with a different command to send. This works really well! I have the RF bridge sitting plugged into USB power somewhere out of the way, connected to my WiFi, and waiting for signals from the buttons I now have mounted around the house to send commands.

A Sonoff RF Bridge connected to USB power.
My RF Bridge glowing happily in the corner.

What I haven’t mentioned so far is how I send commands. Google Home doesn’t yet have a proper API to connect buttons like this, but what there is an API for is sending Google Assistant commands from other devices. These can be either voice or text; of course in this case I went with text. So when one of the buttons is pressed, I can send an arbitrary Google Assistant command, like “turn off the living room lights”. It takes a couple of seconds to respond, but otherwise works pretty well.

If you’d like to try either of the above, you can get the source code here, along with some more documentation of how to set it up. Once you’ve flashed it onto your device there’s a web interface which should make it easy to connect to your WiFi, authenticate your Google account and set up whatever commands you want.

If you do try it, please let me know if it’s useful! Or if you have any trouble getting it working or find any bugs, let me know too.

Next up (and in the same repository above, if you can’t wait), how I control lots of fairy lights. Until then, have fun, and Merry Christmas!

4 October 2010

More requests

Filed under: Computers, Electronics, Me, music, thequotebook — Tags: , , , , , — qwandor @ 2:34 am

Continuing on from my last post, here are some more topics people requested me to write about.

xyzzy and Craig both want me to write about working at Google. Hmm. Well it is a fairly good place to work. We get free breakfast, lunch and dinner in the office, Monday–Friday, plus there are microkitchens around the place with snacks and drinks. The food is pretty good too. Typically at lunch in the main cafeteria there will be 2 or 3 choices of meat (at various times we have had roast duck, roast beef or lamb, lamb cutlets, beef steak, various kinds of sausages, sausages wrapped in bacon, chicken, turkey, I think there was even kangaroo steak one time), some choice of fish or other seafood, vegetarian dishes, roast and/or boiled potatoes, rice, a range of cooked vegetables, various salads, sushi, a couple of flavours of soup, bread of various sorts, crackers and cheeses, a hot pudding, cakes or cupcakes or other cold desserts, fruit, and a range of drinks. There is a machine to squeeze oranges into juice which is fun to watch. There is not nearly so much selection for dinner unfortunately, and not so many people stay for it. Breakfast is pretty good though. If you happen to be in London, come for lunch! We get to have up to two social guests to eat at the office each month.

Food aside, the work has been fairly decent. It does take a while to get used to all the systems and technologies, as Google have a lot of internally-developed tools and systems that nobody else uses, and have had to put a lot of work into making everything scale bigger than pretty much anyone else. Writing a web application that could cope with being used by everyone on the Internet, many simultaneously, from all over the world, does pose some challenges over just designing something for a few hundred people. I still have a lot to learn. Unfortunately nothing I have worked on so far has been launched yet, and it is unlikely that any substantial part of it will be launched publicly until sometime next year.

Working at a global company with tens of thousands of employees is certainly rather different to working at a small place with between 10 and 20. The ratio of actual developers to support roles (legal, HR, recruitment, management, sales, facilities, and probably many others that I do not even know about) seems to be quite a bit lower. I am not too sure what differences can be attributed to differences between England and NZ as I have only worked at the one company over here. I guess there are more big companies over here though, being a bigger country. I do find that there is not so much chance to chat with my colleagues about anything outside work, though that may be at least partly due to the fact that I knew about half of the guys at Innaworks already before I started working there, though university and Interface.

As for what skills I use from my studies, the data structures, algorithms and complexity stuff was certainly important in passing the interviews and getting the job, though so far at least it has not been all that important day to day.

I think that answers most of Craig’s questions. xyzzy also wanted to know about “some project you’ve embarked upon in your spare time! your take on what really matters in life!”. Unfortunately I have not been working on any terribly exciting projects in my spare time since I moved here. I did just recently order a Bus Pirate, in the hopes of hooking some sort of I2C devices up to my computer and having a play. That has not yet arrived yet though. It is also not clear whether there are proper drivers for it to let it work with the usual Linux I2C infrastructure, or just userland stuff.

I have made a number of updates to theQuotebook in the last month or so, most notably finally getting the new style ready to launch. I am working on a new feature to allow quotes to be added by email, and Twitter support may also follow if I can work out a good way to design it and find a suitable Twitter username that is not already taken.

I also did some work on a web-based client for Fridge a while ago. It is implemented using GWT, and talks directly to the XML-RPC API that the other clients use, so it supports all the same features, including Interfridge. You can try it out if you have an account on the Memphis fridge or any peered fridge.

So what really matters in life? Probably not Slayer. God, I think, though I am not sure quite how. People seem to be fairly important. I wish I got to spend more time interacting with people constructively, perhaps sociably as well. Finding good community and good friends is hard. Knowledge is also important I think. Do more maths, people. And some science if you like.

Before I stop for the now, Richard asked me (twice!) to write about Slayer, so I guess I should do that. Richard seems to be a little bit obsessed with Slayer, though I am sure he would assure you it is purely in an ironic way. I am afraid I do not now much at all about them, so I will be looking up what I can. last.fm informs me that Slayer are “a thrash metal band from US, formed in 1981 … credited as one of the ‘Big Four’ thrash metal bands, along with Metallica, Anthrax, and Megadeth”. They seem to choose deliberately controversial topics for their songs, which is not uncommon among such bands. I am pretty sure Metallica are better. Perhaps you can tell us more, Richard?

I think that will do for today. Next up: books, culture and language if I can think of anything to write about them, and probably not a vat of hot chocolate.

3 February 2009

Sun?

Filed under: Computers, Electronics, Humourous — Tags: , , , , — qwandor @ 10:05 am

From an article in the ACM TechNews, talking about silicon photonics for optical interconnects:

Sun engineer Ashok Krishnamoorthy says his company prefers to not have the light source on the chip, or even in the data center, because cooling is a problem.

Er, what? Taking the company name a bit too literally, perhaps… d-:

23 May 2007

Microsoft remote control car

Filed under: Electronics, Humourous, Interface, University — qwandor @ 10:48 am

Last week, one of VUW’s resident Microsofties (a ‘Microsoft student partner’) spoke at Interface‘s weekly meeting. At the end of the presentation, he gave away a few freebies. I got a rather cool (apart from the Microsoft branding) mini remote-control car. Ironically, when I got home, put batteries into it and tried it, it did not work — the steering worked fine, but it would not go forwards or backwards.

Fortunately, unlike Microsoft’s software products, it did not have a restrictive license agreement to prevent me from fixing it, so I took it apart and got it working.

27 June 2006

IR receiver

Filed under: Electronics — qwandor @ 4:49 pm

I have recently built an infrared remote control receiver for my computer. There are photos and more information on the relevant page of my website.

10 February 2006

LaserTag update

Filed under: Electronics — qwandor @ 3:50 pm

I have made quite a few improvements to my lasertag system since my last post about it. Among other things, I have added an ammo. indicator LED, found a better box, and designed and built a ‘target’ unit intended to stand at a team base. For more information (and photos), see the relevant page on my website.

17 January 2006

LaserTag

Filed under: Electronics — qwandor @ 9:04 pm

I have recently been working on making a lasertag game, using laser diodes from laser pointers, toy guns, PIC16F628A microcontrollers and various other parts, electronic and otherwise. For photos and more information, see the relevant page on my website.

Suggestions are welcome, but I make no guarantee of following them.

Blog at WordPress.com.