Talking to a Tesla through Google Home

The Google Home had the long awaited (at least by me!) UK release last week, and I was delighted to get my hands on one of the first. Since then I’ve gradually been linking it to more and more devices around my home (more blog posts on that subject to follow), but having played around with the Tesla API recently, I only had one integration on my mind! Sadly there’s nothing official that allows you to talk to your Tesla Model S or X through Google Home – although I hope something will be released in future – so I took it on myself to build something that would allow some basic back-and-forth conversations with my car.

While I’m continuing to work on the project, it’s now at the stage where hopefully others can expand and improve on it, so I’ve written up all the details on the TeslaVoice project page, and uploaded the associated files to GitHub.

Talking to a LIS3DH via Python on a Raspberry Pi

For my latest project (details coming soon available here) I acquired a couple of LIS3DH triple-axis accelerometers. As most of the products available through Adafruit are fairly well used, I didn’t bother checking what libraries were available before buying, but unfortunately for me only a C++ library had been written. I didn’t feel like learning C just for the purpose of this project, and so the only option left was to write my own Python library!

Thankfully I had some excellent starting points with the aforementioned C++ library, as well as the Python I2C library that Adafruit have published. I found myself referring back to the manufacturer datasheet quite often as well, mainly to clarify what each register contained.

While the task initially looked rather daunting (having had zero prior experience with bit-bashing through registers) – I found that with some pre-existing code to crib from, the various functions took shape rather quickly, and within an afternoon I’d produced a library exposing all the basic functions I’m likely to need for this project. I’ve put my code on Github in the hope that people will contribute to filling in the gaps, and improving where necessary.

AlarmPi: The Raspberry Pi Smart Alarm Clock

When I left my previous job around 18 months ago, I promised myself I’d do something productive with the time I had between employment. During that time, I realised how much I hated my alarm clock going off every morning, and also how stupid and inflexible most alarm clocks are. I managed to achieve very little with that spare time between jobs, but this hatred of alarm clocks has been driven home even further since I’ve started working shifts in my new job – no alarm clock I could find had the ability to vary the alarm time based on a shift pattern (I suppose that’s a fairly niche feature!), and very few had decent internet radio connectivity to allow me to listen to music I like in the morning.

That productive feeling drew me to buy some parts from Adafruit and have a play with some electronics projects – the furthest I got was playing around with a LCD display as documented in this other blog post. More recently, my old alarm clock started to fail in rather interesting ways (ever been woken up at 3:27AM by a piercing screaming & static noise?), so I decided it was time to build my own, and the AlarmPi was born!

The core of the project is a Raspberry Pi connected up to a series of fairly basic components, all controlled by a Python script which takes input from all manner of sources, and shows information through the two front displays. I’ve put together a short video explaining some of the main features which can be viewed below, and you can read more about the AlarmPi on the project page

To Mac or not to Mac

As you may know, I am the extremely happy owner of an iPhone. I also happen to be doing a degree which has something to do with programming (apparently…), leading me to wonder what would happen if I were to try combining these two!

I’ve previously had one or two ideas put to me for iPhone software, and also have thought of some myself. Objective-C looks like a bit of a pain in the backside to learn, but challenges are fun! The only obstacle left in my way is Apples decision to only let you run their iPhone development software on their own OS.

This leaves me with a couple of options. Firstly, I could put together a hackintosh on some old hardware, providing I’ve got some hardware lying around that it will work with! The only downside of trying that approach is that this is likely to happen. The other option is to buy one, I’ve been having a look at Mac Minis, which would probably cost somewhere in the region of £600 with student discount.

I don’t know if I’m ready to give up my Mac-hater stance and actually buy one, but I’m tempted…

Windmills

As part of my Software Applications module this year, I have a sub-module called Digital Imaging. Basically, we learned how to use Java3D to model things and then animate them.

The assignment set for this term was to create a wind turbine…

turbine

Above is what I created! Obviously you cannot see here, but the blades move round the appropriate axis, and the entire head of the turbine rotates around the Y-axis when you click on the mast. Pretty impressive – huh?! I didn’t think so either! If, for whatever reason, you do think it’s impressive – you may download the .jar file here. It will need Java3D and possibly some other stuff installed to run.

The main thing I learnt doing this was how much of a pain J3D really is – it’s a completely obsolete extension of Java that doesn’t really have much use, apart from for making simple animations such as this one. I can’t think of anyone who would use Java to make a serious 3D game, the processing power just isn’t there to allow decent use of physics, lighting or anything else essential to make an immersive environment. For example, when I was trying to make the turbine cast a shadow on its environment, I found it wasn’t just as simple as allowing the light source to throw a shadow onto the grass object – oh no – I had to calculate the exact shape that the shadow would be, based on the position of the light relative to the turbine, then draw it manually to the floor. As you can imagine, this would be a huge task – and lets not even get started on running this 40+ times a second to get the moving blades, or even considering the opacity of the shadow in different places, or the fact that multiple light sources exist, or that the turbine would shadow itself in parts…

I’ve used programs before (GameMaker stirs a memory?) that will do all that for you in 2 or 3 lines of code, however in J3D I was looking at separate classes, and 2 or 3 times the existing code I had to make the turbine work. No thanks, I’ll just pretend it was a very bright day!

I’m quite glad I’m rid of J3D now – I’ll be even happier when I’m rid of Java completely. I’d be really happy if I never had to see a wind turbine ever again… but they had to go and drop that into our Software Engineering project as well. More to follow on that…

The Ethics of Scraping

I’ve recently been given a commission to do a piece of coding involving grabbing information from another website and displaying it in a different manner. Obviously I won’t say much more about the brief – don’t want to annoy the customer or expose myself!

The brief got me wondering – how legal is it to grab content from another website? I guessed it was probably another one of the ‘grey areas’ that surround the internets at the moment, however another issue concerned me slightly more… how ethical was it? My script essentially steals information from a website for use in other ways, that the original publisher has no control over. Since the website in question publishes no open API or content feeds for this purpose, surely they mustn’t want this information being scraped from them? The website being scraped is essentially just a collection of many different items, published by their own individual owners. Do they want the information scraped and re-published?

I’ve heard of another case from a friend (again, won’t get into details) whereby a company is keeping a tight fist around its data. This is sort of understandable, but again the website in question is aggregating many different peoples data. Is the website being anti-competitive  by not releasing APIs?

I will sleep better once this script is out of development and off my server – I know I wouldn’t like it if someone else was doing this to my website! However – the customer is always right, and I won’t disappoint!