Day 2 of Electromagnetic Fields - Starting with Furby Hacking

Good morning...

Shower Ninja Level Zero: Stand fully clothed in a shower booth and press the water button "just to see if it works". Then wonder why all the clothes you're wearing are now soaking wet. And have nothing to put wet clothes into. Oh well; the good news is that the shower was clean and the water was nice and warm. 

After breakfast it was time for some more sessions, starting with "Attacking Websites for Educational Purposes Only". The exploit that was explained was specific only to an elderly version of the PHPBB bulletin system that was released for a short time a while back, but the talk did bring home how vulnerable a site can be.

Then it was time to attack something a bit more cuddly, with a fantastic session on Furby hacking. From modest beginnings, intercepting Bluetooth messages containing firmware updates, the speaker ended up showing how to take complete control of the device, downloading sound and graphics into the hapless cuddly toy. It was so impressive that, not surprisingly, I've gone and bought a Furby device to play with. Such are the perils of connected sessions and Amazon's Buy it Now button. 

Next up was a really good talk on podcasting. I've never podcasted, despite apparently having "The perfect face for radio". However, after this talk, that set out why you would do it and why it is such a good idea, I'm strongly tempted to give it a go. 

Building the badge al-fresco

By now the emf badge had been released and it was back to the tent for a bit of assembly and testing.  I had a plan to connect an Air Quality sensor to the badge for no particular reason, and in an uncharacteristic piece of forward planning I'd actually 3D printed a case for the badge and attached a sensor and a rechargeable battery to it. Now all I had to do was connect up the wiring and write the code. This meant that session attendance had to take a bit of a back seat, although I did manage to catch part of an awesome session about converting photographs to poetry and another which went into scary levels of detail about how easy it is to hack RFID car keys. 

It turned out that the bar was a good place to set up base camp and start developing

After gatecrashing an Arduino session and hijacking a soldering iron for a few minutes I got the cabling wired up to connect the sensor to the badge and then my software worked first time. 

I always get nervous when that happens. My theory, which has been validated many times, is that any given project requires a "pound of flesh" of effort, and if it seems to be going easily that's because there's something nasty lurking round the corner. It turns out that my nervousness was well founded. Although I could get values from the sensor and display them, when I tried to turn the program into an application to publish in the app store for the badge it all went horribly wrong. I was sure it was something stupid that I'd done, but it was very hard to work out what. So, after a while I gave up and went for a wander down to the Hackaday tent where they were showing off hacks. There was a chap there with an amazing barrel organ made using laser cut panels. I also got to have a really good chat with the man behind the RC2014 project

After tea (pizzas this time) we headed for a special showing of Hackers, a deeply silly movie from 1995 that was one of the first on-screen portrayals of hacking. It was great fun and lovely to be part of a huge audience that shouted "Hack the Planet" at every opportunity. The presentation was followed by a question and answer session with the director of the film who gamely entered into the spirit of the thing, even down to judging the best hacker costume. Style tip: the more LEDS the better....

A message for our times. 

After that we took some pictures of the fun and games going on in the Null Sector, and took a walk around the camp. There are various "villages" set out for particular interest groups. You could spend your entire time at the event just going round and seeing what they are doing. 

Hardware hacking by moonlight

Across the camp

Day 1 of Electromagnetic Fields

I’ve not done any camping for over thirty years. After my previous experiences with horizontal rain, sleeping bags frozen solid and forgetting the tin opener, I reckoned it would take something rather special to get me under canvas again.

Home for the next three days...

Turns out that EMF is something special. Electromagnetic Fields is a techie festival in a field. And it is awesome. There are technical tracks, there are crafting tracks, there are things that have been done “just because we were told they were impossible”. You have to stay the night in a tent, but it turns out that in good weather and with working toilets and showers, camping is actually quite fun. Particularly if you have mains power in your tent.

They had these "Tardis" devices all over camp supplying power...

We arrived on site bright and early and picked a spot that looked sensible. Pro tip number one: Lay your power cable from the supply before you pitch your tent, otherwise you’ll find that your wire is six feet too short and have to move everything. However, with that hiccup out of the way, and having made the decision that the fact our tent looked like a “lean to” owing to some curious asymmetry in its inner workings was not going to significantly impact on its integrity, we established base camp and had a look around.

It was around two minutes before I heard someone say to me “You’re Rob Miles aren’t you”. Turns out that I am, and that the techie world has a good quotient of Hull University Computer Science graduates you are out there doing good things and remember the tall bloke who talked a lot about C#. Rather more surprisingly was that the second person to say this, thirty seconds later, was also called “Rob Miles” and was giving a talk in the afternoon. Which of course I was going to attend. I just hoped he’d maintain the integrity of the brand.

The camp is huge, with three large stages for talks, four hardware labs for, well, hardware, and a bunch of other places to go and do stuff. There are themed areas around the site, with different makerspaces and interest groups all over the place.

The best instructions you can get at the start of any event

The first session was the opening one, which brought home the complexity and difficulty of creating a very well-connected village in the middle of a field. Everybody in the emf organisation does it for the hell of it, and it seemed like this year the setup had been more hellish that usual, with failing tent suppliers, hillsides and all manner of other things turning up to cause hassle. Not that we’ve noticed much not working; the only real disappointment being that the badge; a very interesting piece of technology that we all get to play with, is not ready just yet.

Anyhoo, after the opening talk the session tracks started. The great thing about emf is that at any given time there are two or three sessions that look really interesting. The bad thing about emf is that at any given time there are two or three sessions that look really interesting, and you can only go to one.

After a brief look at the Air Quality Sensor workshop being run by Southampton University (and someone else going “You’re Rob Miles aren’t you”) we caught a lecture on a tele-presence robot by Libby Miller. It was a great talk, emphasising the ease with which you can create a something that works well for remote interaction and guaranteeing a peak in sales of a certain Ikea lamp which was used as the basis of the device. I’d love to build one. The instructions are here if you fancy making one to: https://github.com/libbymiller/libbybot_eleven

After that, a change of pace with a session with the fascinating title “101 Hacks for Late Soviet Water Towers”. The presenter of this session certainly leads an interesting life, which involves buying a water tower in Latvia by mistake for five euros and then finding out that you can save your five pound membership fee of the British Water Tower Appreciation Society (http://bwtas.blogspot.com/) if you actually own a water tower.  Which almost makes it a profitable option, assuming you want to join the society as cheaply as possible. The tower is very tall (higher than a Space Shuttle) and not likely to fall down any time soon, which is good. It needed a door to make it harder for people to climb to the top and fall off, and doesn’t actually hold water at the moment, but it all made for a very enjoyable story told in a very engaging way.

 After a burger lunch (very nice) it was time for my namesake to talk about the dangers of Artificial Intelligence. If we make a device that is clever enough to be useful, will it also be clever enough to be dangerous? It was a timely talk, what with the rapid advances in the field and the tendency of humanity to rush into technology without thinking about the consequences.

Then it was time for some hard-core hardware, in the form of a very detailed description of the creation of silicon devices that contain more than just transistors. It turns out that we can put all kinds of sensors directly onto the silicon and even make them small enough to be swallowed and take pictures during their journey through our system.

Next came a description of algorithmic light displays. I've been doing these since my discovery of Neopixel technology and my wedding lights of many years ago. However, the speaker was operating in a slightly different league, with huge displays containing hundreds of lights. There was some very interesting content about gamma correction and the proper use of randomness. Very interesting.

By now my brain was pretty much full for the day, but there was just enough space to take in a description of the project that is recreating one of the first ever stored program computers, the EDSAC project

After that it was dark, which made it a perfect for tying some Light Painting/Light Writing. Everyone else turned up with proper camera on huge tripods. I just had my tiny Sony camera and a table top tripod. However, after literally shaky start, when I fell over onto the grass after setting up the camera, I got some pictures that I'm not too unhappy with. 

We got some nice looking results with some tiny lights on strings. But then a chap turned up who just happened to have hundreds of leds on a pole. Electromagnetic Fields is that kind of place. And the pictures got even more fun. 

After that it really was time for bed. So, after picking our way through guy ropes and power cables we found our way to our tent and turned in, the best kind of happy-exhausted and with the prospect of even more fun and games tomorrow. 

Surface Go Review

When I finish writing a book I allow myself by buy a new computer. It's quite a thing for me. Last year, when I finished "Begin to Code with Python" I got myself an Apple iPad Pro. I was hoping to be able to use it to do proper work on the go. It has an OK keyboard and versions of most of the applications that I use. However, I found it impossible to use productively, over and above responding to emails. Simple actions such as copying values from one spreadsheet to another were taxing beyond belief. And of course, there was no way I could use it to write code. It's great for reading magazines and playing Zoo Keeper, but as a way getting something done, it sucks.

So, move forward to the latest book, the C# exam reference that has just gone to print. This time I've gone and bought myself a Surface Go. I got the bigger of the two versions available, with 128G of storage and 8G of ram. Both versions use a Pentium Gold processor, a model I've not heard of before. If the Surface Go used an Intel Atom processor I'd not have bought it. I've lost count of the number of Atom based computers that I've bought over the years. I was always tempted by the low price, but I was also always annoyed by the way that the things ran with the speed that custard flows uphill.

I'd read a few mixed reports of Surface Go performance, but enough people who I respect had said it was OK for me to take the plunge and part with cash. I needn't have worried. The Surface Go just works.  It gets there. If I compare it with my venerable, i7 powered, Surface 3 device it's like comparing the tortoise and the hare.

The Surface Pro 3, like the hare, sets of in a blaze of speed, and then, a few seconds later the fan comes on, the case gets hot, and things slow down to a much more sedentary level. Then a couple of hours after that the batteries go flat and everything stops.

The Surface Go tortoise sets of at a somewhat more sedate pace and maintains that until it gets there. There are no fans, nothing gets hot and nothing slows down. And the battery seems to go on for a lot longer. If you remember the story, you'll remember that the tortoise was the race winner. Enough said.

I've not bought and commissioned a new Windows computer for a very long time. The Surface Go "out of box" experience was very slick, involved Cortana, and had me working and connected to my Office 365 account in about ten minutes. Microsoft Office is already installed andI didn't need to copy all my files onto the small hard disk, just the ones I wanted to have with me all the time. All the rest will be automatically fetched when needed. Of course, there were updates, but these weren't too onerous.

The device arrived in Windows 10 "S" mode. This isn’t a separate version of Windows, its more like a safety catch that, when set, stops you from running anything other than programs from the Windows Store. However, this is easy to remove and in no time I was installing Visual Studio 2017, Visual Studio Code, Python, GitHub, the Arduino SDK and few other tools of the trade. All worked fine. Visual Studio 2017 is a beast of a program and, sure enough, large projects take a little while to load (around twice the time they do on my Surface Pro 3) but once they are open you can work on your code with a commendable lack of slowdown. I'm not going to use it with Lightroom or Photoshop because that's not what I got it for. Although, in a pinch, I reckon it could deliver if I was patient.

The Surface Go uses Windows Hello face recognition to log me in and while it isn’t quite as good as the one fitted to the iPhone X, it is properly useable. The screen is lovely. The sound is OK, within the limitations of speakers as small as they have to be to fit in such a tiny device. Battery like is OK too, nothing like the promised 9 hours, but good enough to remove any battery anxiety during a working day. It's also possible to charge the Go via its USB C socket, so I'm able to use my portable battery pack to top up the charge when out and about.

The keyboard is a smaller version of the lovely type cover on the Surface 3. I've just about got used to the smaller keys and I can type at good speed using it. If you're thinking of buying a Surface Go I'd strongly suggest you get the keyboard, along with an Office 365 subscription that gives you the use of the Office suite of programs and removes the need to have all your files on the device all of the time. I've paired my old Surface 3 pen with the Surface Go and discovered that the drawing and text entry experience is very, very, good. I reckon it's easily on a par with the Apple pencil on the iPad Pro.

I find that the Surface Go is a device that for me brings a bit of joy when you use it. The quality of manufacture and finish is the equal of much more expensive devices. Everything about it feels just right. It is the perfect size to take with you everywhere and has enough processing grunt to allow you to be useful when you get there. They say that the best camera is the one that you have with you at the time. By that yardstick the Surface Go is the best computer.

It's not that good for games though. Fortnite runs jerkily (although slightly better than on my Surface Pro 3). Graphically simpler games, for example Minecraft, run rather nicely. If the lack of Fortnite is making you think you need a more graphically powerful (and expensive) device like an iPad Pro my advice would be to get a Nintendo Switch with the price difference.

I think this is pretty much the perfect student device. Plenty of battery life, a workable processor, and access to proper productivity. You also get premium finish and the ability to be used as a tablet. And a genuinely pleasant user experience. It's a really nice feeling to have a tiny machine with you that you know can be used to turn out some proper work. If you're thinking about getting a little portable computer you really should take a look at the Surface Go. The girl in PC World was saying that they're selling quite a few Surface devices these days. I can see why.  

Making a lightbox

Yesterday I had a bit of a cold. Today I seem to have got all of it. So I feel rubbish; what better time to do something silly. I've decided to make a letter light for number one grandchild. See if you can use your skill and judgement to work out her name from the above picture. 

I found a really nice design on Thingiverse for letter boxes, but I would have had to stick them all together and make a box to put them in and so on and so on. No fun. So I've written a little Python program that runs inside FreeCad to grab the STL designs, convert them into FreeCad shapes, stick them all together, create a backplane for the light box and then a plinth to put them in. I've even added a hole for the power socket and wall mounting holes. 

I've discovered that I can just handle a six letter word if I print diagonally on Una my Ultimaker original - still doing a sterling job after six years. The light boxes are 30mm in size and a perfect fit for some waterproof neopixels that I had lying around. 

I'm printing out the bits and fitting them together at the moment. I'm going to make a modification that lets you make a box with multiple lines and then when it's all working well I'll put the code up on GitHub.  

Air Quality Sensor Version 1.0

If you think that all I've done over the last week is work on my Air Quality sensor you'd be wrong. But I have been quite busy with it. I've now got a proper menu system with messages and numeric input. Plus a box. The box has been particularly fun to design, especially as the Heltec micro controller, in common with lots of similar devices, doesn't seem to provide any way that it can be fitted into a case. I've ended up making a little clamp that holds it in position. I'm not happy with this, but then again I'm not crazy about my looks either - but what are you going to do? 

To say that the case is printed version 1.0 it has gone together quite well. I'm using the "dead cockroach" assembly technique, where you regard the chip as a dead cockroach lying on its back and connect the wires to the upturned legs. There are no components other than the devices that I'm wiring together. The only tricky bit is that the clock and the temperature sensor share the same SDA and SCL lines and so I've had to make up some custom cables. But it's all working, and now I have a box with all my sensors and whatnot that I can start to to build software for. 

This is the ugly truth about what's in the box. We'll gloss over the way that the wires for the RTC are too short to allow it to be fitted onto its mounting post, and the wire for the sensor is far too long......

The next step is to add a "WiFi Setup" mode that can be used to get the device onto the internet and then we can start pushing readings into the cloud. You can track the project on GitHub here. Bear in mind that this is a work in progress, and so nothing is fixed. This is all part of the Connected Humber Monitaire project, you can find out more here

Building an Air Quality Sensor

I've been having proper fun today. I started with one of my tiny Heltec embedded controllers and an urge to connect it to an air quality sensor and a temperature/air pressure/humidity sensor. 

It wasn't easy, but it was possible. Biggest problem was that the temperature sensor uses an i2c connection to the Heltec device, and so does the lovely little OLED panel that you can see above showing numbers.

Turns out the way to make it work is to create another Wire instance and then use that for the temperature sensor. Anyhoo, it works. If you want to see the code you can find it here.

I've written everything using message pumps and state machines so that it should be possible to have all this working together without something getting stuck. 

Hull Meetups is becoming Connected Humber

Things are changing, but not changing. The c4di Hardware Group is turning into Connected Humber. We'll be meeting up at exactly the same time, in exactly the same place, doing pretty much the same things. Only more so.

We're going to turn the group into a Community Interest Company CIC, which will make it possible for us to do even more interesting things, and give us a recognisable presence when dealing with companies and local bodies. 

For existing members the biggest change is that you can now find out about meetups and what we are doing by using the Connected Humber website. We'll be bidding fond farewell to the Meetup site that we've used in the past and we have a Slack channel for members of the group. Ping me a message if you want an invite, or turn up to the meetup this Thursday (16th August). 

We've lots of community activities planned, starting with a project to build a network of Air Quality sensors that we plan to deploy around the area. Exciting times. 

Enter the Humber Care Tech Challenge. Now.

The Humber Care Tech Challenge is in just around a month. We had the Visioning day last week and we've now got 98 ideas for projects for you to explore. I've been through them and broken them into categories to make it really easy to identify challenges and ideas to explore.

Last week I discovered, to my great delight, that we'll have Principle ICT Business Analysts from East Riding of Yorkshire Council along with developers from Amazon present at the event to help you build your solutions. I'm also working on getting the healthcare professionals behind the 98 ideas along as well.

If I was a developer looking to get into the healthcare space I would regard the chance to meet up with people like these as priceless. 

And you only have to pay five pounds to sign up, you get free food and drink during the event and, if the weather is nice, you might even get to go for a paddle in the sea.

For many years I've organised and taken part in tech challenge events of various kinds. I've watched them change lives. Come along in September and let this event change yours.  Just press the button below.

Hull Pixelbot at The Digital Awards

I'm totally gobsmacked (a great phrase) to discover that the Hull Pixelbot has been made a finalist in not one, but two categories in the The Digital Awards 2018.  

"The little robot from Hull" is up for an award in the "Best Hardware" and "Best Use of Technology within Education" categories. Awesome stuff. Thanks so much folks. The awards ceremony is in September.

There's some impressive competition in the categories, including some from companies that are also based at c4di. I'm really pleased just to have made it as a finalist. If you want to read what I wrote about the robot, you can find my entry description here

The Railway Pub in Cottingham is Awesome

Do me a favour. And yourself. Go for Sunday lunch at the Railway in Cottingham.  The food is great, the staff friendly and helpful. And should you fall down the steps on the way out they are completely and utterly awesome. We found this out today when one of our lunch party was unlucky enough to miss-position his walking stick and take a tumble on the way out. 

The landlord took control of the situation, called for an ambulance, kept us company while it arrived, monitored the unfortunate tumbler, got us a sunshade and seats for us to sit on and was generally splendid while I flailed around failing to be useful. The ambulance turned up after a little while and as it left he and his staff were working efficiently to clean up the mess that we had made. 

I told him how impressed I was with the way he had handled the situation, and that I would be telling all my friends to get down to his pub pronto. We had the Sunday roast and it was great with a really nice range of home cooked vegetables. And we'll be back. Hope to see you there.

While I'm in a thanking mood I really should also say a huge thank-you to the ambulance crew and the folks down at casualty in Hull Royal Infirmary who stuck the patient back together again (they use glue on cuts now - who knew?) and got him back on his feet in good time. Recovery is progressing nicely. 

Whitby Steam

Today finds us on the road to Whitby. A wonderful place, if a bit colder than we anticipated first thing in the morning. We'd come for the steam rally and a fish pie. We got all that, plus fantastic weather and a ride in the clifftop lift (well worth 60 pence of anyone's money).

If you've not been to Whitby you are so missing out. And if you've been to Whitby and not had the fish pie at the Magpie Cafe then you're missing out too.

Mission Impossible: Fallout

Mission Impossible: Fallout is a fun film about atomic bombs. It has just the right amount of jeopardy, wisecracks and jaw dropping sequences to make it work splendidly.

One of the things that I loved was the special effects. It turns out that there are two ways to shoot a "helicopter out of control" scene. One way involves a green screen and a lot of computing power. And it looks a bit fake. The other involves an out of control helicopter with a lot of cameras stuck on it and Tom Cruise sat on his own in the cockpit. And it looks scary real.

Anyone expecting a light romantic comedy, or philosophical musings about the nature of life will be disappointed. For the rest of us, who turn up for thrills, spills and lots of stuff going on will leave very happy.

Humber Care Tech Challenge Visioning Day

Getting started

Today I went along to the Humber Care Tech Challenge Visioning Day. This is where we get healthcare professionals to tell us about their problems and explore how to solve them. It's how we are setting the agenda for the Humber Health Care Challenge event itself, which is running in September.  During the event we want teams to come up with working prototypes of solutions. But to do that we need some idea of what we are facing. 

We had some great talks from people about the problems faced in healthcare. All the speakers were very open about the huge challenges that the future is going to bring. Nobody was saying these are easy things to address. But everybody was excited by the opportunities that new technology is bringing. I made some notes of things that people said during the talks. Apologies to the speakers that I didn't get all the names and if I've misquoted at any point:

  • Your home should be a proactive part of your healthcare.
  • People frequently interact with care services because they are lonely.
  • People will tend to opt-out of automated systems if they think that they will reduce the amount of human contact that they have. 
  • We need to establish a culture that make people and families able to provide appropriate support to allow independent living for as long as possible. Say in your home. Stay in control. Stay in contact. 
  • We should strive to make it as easy as possible to deliver and monitor care, so that the carers have time to focus on the person, and not just perform support tasks. Shared records across agencies would be a great step forward in this regard. 
  • Lots of technology already in use can be used in a care context. It might just be a way of connecting things and re-purposing existing devices.
  • We must plan for how the technology will be in 5-10 years time. Not what we can do now.
  • When considering disability; you are not what has happened to you - you are what you choose to become. And you should be empowered and supported to make that journey. 
  • Machine Learning and Artificial Intelligence bring with them an incredible potential for healthcare. So do connected devices such as Amazon Echo.
  • Very simple ideas can have a massive impact. 

Filling idea cards...

After the talks everyone spent some time filling in idea cards that set out the challenges that they saw and ideas for addressing them. We're going to spend some time going through these and getting back to the delegates who proposed them to turn them into challenges for the event. Things are getting very interesting. If you want to take part (and you should) you can still sign up here

As part of the presentation we recorded a bit of video with me talking about the event and why it is a good idea. This is one of those occasions when everybody wins. Everyone who takes part will have fun, learn things and improve themselves. And they might end up creating a solution that change lives. 

Cloud Connected Camping Lights

I was in the Pound Shop over the weekend looking for camping lights. What with we me going camping in a month or so. I'm going to the Electromagnetic Field event at the end of August, and I've been buying sleeping bags and contemplating life under canvas for a few days. 

I found a likely looking light in a camping shop for a fiver but being from Yorkshire I thought I'd take a look at cheaper solutions. I found the lights above, packed in a nice little box, for a pound a pop. Astonishing value, so I bought four. 

Then I got to thinking about making the light more interesting. I've done this kind of thing before and I had some pixel rings and Wemos devices lying around, so I thought I'd have a go. Worst case I'd break a light that cost me a pound. 

This is the light dismantled. I undid the screws that held the base on popped the top off and then slid the transparent cover down and off the bottom of the light. Then I used a knife blade to pop the plastic reflector off the top to reveal the pcb that holds the 11 white leds. I'm going to replace this with a 16 led neopixel ring which just fits. You can get these rings for around 8 pounds, or much less if you're prepared to wait for them to arrive from China. 

The plan is to fit the led ring a shown above, drill some holes in the plastic support and run the wires behind through them, providing a connection and also holding the ring in position. I can bring in the hot glue later if I want to make things even more secure. 

I held the led ring in position, scratched marks on the reflector and then drilled the holes. I'm not very pleased with the bottom hole, but I don't think anyone will see it. I'm only using three of the connections, but I drilled four holes so I didn't have to remember which was the one I don't need. 

These are the wires that I made up for the connections to the led ring. I used solid core wire. I'm connecting to the ground, 5Volt and Data input lines using black, red and white wires. The colour of the wires doesn't matter much, as electricity doesn't seem to care about wire colour.

If you read the Adafruit help pages for the Neopixel ring they talk sensible things about series resistors and capacitors that you can add to improve the signal to the led ring and reduce the chances of damage. I'm leaving those out because I like to "live on the edge", but you might want to add them if you build a light like mine. 

This is the led ring after I fitted it to the reflector with the wires pushed through the appropriate holes. Looks quite tidy to me. Next up we have to take a look at fitting the processor board to the light. 

This is how the lamps are made. They have a slide switch which controls power to the led ring. It's a bit hard to see, but there's a series resistor on the positive side which is wired from the battery terminal to the switch. I'll use the switch to turn the device on and off. 

I'm going to add an ESP8266 device on the Wemos platform. I love this device and configuration, and it just fits. It will give me WiFi for connectivity and my plan is to port my wedding light software onto the Wemos platform. 

This is the device with the signal and power wires soldered in. For some reason I was nervous about soldering solid core wires onto the Wemos PCB and so I soldered in some jumper cables instead. I've done this before and it's a good trick. Rather than soldering a socket and then plugging into it (and having the worry that the plug might come out) instead I just solder the plug straight in. I'll cut the plugs off the other end and wire things up by twisting wires together, soldering them and covering with heatshrink tubing. Probably not as posh as using proper connectors, but much cheaper and at least as reliable.

I'm using one data pin to control the lights. Just because I'm moody, I decided to solder this wire in directly. I stuck the Wemos device onto the back of the reflector using some sticky velcro tape that I got from Maplin. I'm really going to miss that shop.

This is the completed processor fitted to the reflector. I've done the wiring and so I now just have to power up the device to get it going. This is also a useful stage to reach because now that I've connected the power lines for the leds and the processor together I can plug the Wemos device into the PC using a USB cable and test that the lights work. So I did this. There will now be a short break while I get the software together. 

Writing the software took longer than I expected because I found a bug. However, once I'd fixed that I turned my attention to the base of the light. I soldered some new wires to the switch and onto the battery terminals. Now I just have to connect the red and black cables to the ones on the processor and I'm good to go. 

This is the lights and the power all soldered together. I've made the wires much longer than they need to be, this is so that it will be easy to pop out the reflector and re-program the Wemos when I find another bug.

This is the light in action, just after I'd asked it to turn green.

I'm presently using MQTT to connect to the Azure IOT hub and sending text commands to configure the light. The commands are a subset of the HullOS language that I've been using on the Hull Pixelbot. Next I want to make a controller device that pushes commands up into the cloud to tell the light what to do. 

If you're looking for something to play with I can strongly recommend this light. There's a reasonable amount of space to play with - I'm thinking of adding a temperature sensor so that the light can change colour depending on how warm it is. I've discovered that I can perform my light flickering at the same time as wait for MQTT server commands and it all seems to work splendidly. I'll put the code up on GitHub when I've tidied it up a bit. 

 

With a bit of care you could  take the original 11 pixel ring and cut the tracks on the pcb so that each led could be controlled individually, perhaps by an Arduino Pro-Mini to get a really cheap controllable light device. 

Code like an idiot

Hmm. No matter how good you are at programming, developers will still put bugs in their programs. Including me. Lost a couple of hours today because of this little beauty.

if ((tickCount % lights[i].colourSpeed)!=0 || lights[i].colourSpeed==0)
    return;

This code has been working inside HullOS for a couple of years. No problems. However, when I tried to port the code onto a Wemos device it kept crashing with an invalid instruction message.

Wah. The idea is that the code will exit if is not time to update the colour animation (tick count is not an exact multiple of colourSpeed) or if no animation is being performed (colourSpeed is zero). 

It took me a while to figure out what was happening. Turns out this code is wrong, but under some circumstances it will work perfectly well. 

It's all to do with the % (modulus) operator. This gives the remainder that you get if you divide one number by another (or example 7 % 4 would be 3). If the modulus is zero that we have an exact multiple on our hands. So, every time tickCount reaches the next multiple of colourSpeed the program will perform an update. 

Snag is that I've been stupid, in that I use a colourSpeed value of 0 to mean that the light is not being updated. And the behaviour of a C++ program when you do x % 0 is undefined. In other words, any number modulus zero is a stupid question to ask.

To make things worse the fact that I'm doing this bad thing as one half of an or expression means that, depending on the whim of the compiler, the modulus calculation may not get evaluated when colourSpeed is zero. If the code produced by the compiler does the test for zero before the modulus my program works. If the tests are done the other way round the program explodes.

It's an easy fix, just break the single test into two tests so that I control the order they are performed:

if (lights[i].colourSpeed == 0)
    return;
if ((tickCount % lights[i].colourSpeed) != 0 )
    return;

Now we never use the value of 0 in a modulus expression.  

Oh well, just goes to show that you can learn stuff by doing stuff.....

Go see Incredibles 2

Went to see Incredibles 2 on my birthday. It's really good, you might even say it's incred...

But then you might not. However, the action is great, there are some lovely touches and the dialog is spot on. I want to go and see it again. You should see it at least once. 

However, for me the show peaked during an advert at the start for Disneyworld. On the screen in big letters it said "Where nobody has to grow up." And then on the bottom of the screen in tiny letters it said "Height restrictions apply".