Code (21)


To Build a SmartWatch… (Part 1)

Having seen the fuss around smart watche, I wondered exactly how difficult would it be to build one from scratch? All the technology usually packed in to one of the current generation of watches is widely available in breakout board form or equivalent, which brought me to another thought:

“How far can I get without building my own board?”

Thus, the Smart Watch project was born; an attempt to build a functional watch connected to a handset (in my case, a Nexus 5) and used to notify the user of incoming messages, etc. using only readily available hobby breakout boards and parts, so that as many people as possible could have a go at beating my designs!

If you, the reader, want to have a go, the rules are thus; The watch must:

  1. Only use readily available breakout boards to build it’s circuitry.
  2. Have the basic functionality of a smart watch, namely, to tell time, and show notifications from a host device.

Oh, and do let me know if you do have a go. I’d love to see the results!

The Parts

Because of the breakout board rule, I decided to base all my buying decisions around the single largest part required. As the display is likely to take up the lions’ share of the front surface of any watch, I attempted to cram all my other components behind that breakout.

The one I settled on in the end was the Adafruit 1.8″ TFT + SD Card Breakout with it’s whopping 128×160 resolution, 5v or 3.3v operation, and integrated Micro-SD card holder, it was a pretty easy choice to make – it gave me the added feature of storage, as well as providing a nice sized base to build the rest of the watch behind.

Conveniently, the stock image on Adafruit is a cat. I approve greatly.

The stock image on Adafruit’s display products is a slightly bemused looking cat. I approve greatly.

Conveniently, the processor board I had been looking to use for this project happened to be exactly the same height as the short dimension on the screen.

The Teensy 3.1 sports an ARM Cortex-M4 processor ( an MK20DX256VLH7 ), has hardware driven SPI, and has integrated USB support and handily runs a port of Arduino code, letting me use the Adafruit display libraries directly, rather than having to write my own ( although this came back to bite me later, but more on that another time ).

A Teensy 3.1! Nifty!

A Teensy 3.1! Nifty!

As this is to be a watch, it’s going to need to be battery powered, ( semi-obviously, I wasn’t keen on running about with a USB cable up my sleeve all the time ), and as small size was the main requirement when I decided on these parts, I tried to pick a battery with the largest capacity for approximately the right height available.

The 400mah LiPo battery from Sparkfun is about the right size, and should provide plenty of power for a working day ( a personal requirement of mine was that this should run for at least 8 hours )

It's a LiPo, what did you expect it would look like?

It’s a LiPo, what did you expect it would look like?

As the battery is a LiPo, it required it’s own charging circuitry, and luckily, the guy over at Pesky Products produces an ‘appallingly small’ ( their words, not mine! ) add-on board for the Teensy, which includes all the required circuitry, as well as breaking out a charge status pin and using the Teensy’s own USB connector for input power. It was perfect.

It's really tiny! Really handy too!

It’s really tiny! Really handy too! JST for scale?

Now that the device has power, a processor and something to display data on, a radio was needed to bridge to the host device. Adafruit once again provide the solution with their Bluetooth Low Energy, nrf8001 breakout which turned out to be the second largest single component to cram behind the screen ( the battery was the largest ) and proved to be quite a pain to mount sensibly.

Eventually I opted to put the board back-to-back with the display breakout, as thankfully, the radio breakout has no components on the back side, so could be simply stuck down with double sided foam ( more on the fun with sticky foam later… ). But even so, the sheer size of the breakout was – and still somewhat is – a problem.

The hilariously large - for my purposes - Adafruit nrf8001 breakout board.

The hilariously large – for my purposes – Adafruit nrf8001 breakout board.

More to come, when I can find the time to type everything up!




Calendar Arc Watch Face

Over the weekend, I hit two ‘firsts’ for me at the same time.

One; I published my first Android Wear app! and Two; I published my first paid app!

Watch face showing an 'Example Meeting' event

Oh yes, I was supposed to go to that…

 

 

I’ve owned a Moto360 for a while, and was slightly disappointed that there were no watch faces that adequately displayed what my calendar looked like for the day, so, having written a couple of minor apps for Android in the past, set to writing a new watch face which would show all events, from all my calendars (I have 11!) and present them in a visually pleasing way.

Customizable stock imagery is awesome!

Customizable stock imagery is awesome!

Events are drawn in arcs around the ‘tics’ along the outer edge of the watch. Semi-obviously, as a Moto360 owner, I designed this to look best on a round watch face, but it looks ‘acceptable’ on a square one too (if you own a square watch, get in touch and I’ll give out a free copy of the watch app – for the first person to contact me, anyway)

device-2015-02-22-154912

Fairly sparse at the moment, but it works!

 

At the moment, the number of options for the user to customise the look of the watch are limited, but I wanted to get the app out there so people could get and review it – there’s not much point in implementing features if people don’t want what you’re selling anyway!

For now, only the calendars to show can be changed (the arc colours are from the events in the calendar), and you can force a manual sync, but planned thus far are:

  • Tics on/off, for watches like the G Watch R which have physical tics
  • ‘Full Screen Mode’, for watches like the G Watch R which have physical tics
  • Shadows on/off
  • Inverted Mode – for OLED displays where bright pixels are both battery-expensive and can lead to burn-in.
  • Date settings – none/day/month/year/weekday/etc. formatting options.
  • Battery levels – for both watch and phone, if I can figure out a nice way of fitting it in this style.
  • Calendar event arc styles – thickness, end-caps, active/pending, etc.

If any of this lot takes your fancy, or if you just want to have a go with the app as it stands now, see the Calendar Arc Watch Face page on the Google Play store.




Pulling Colours From The CheerLights API on Linux

I’m trying to do a new project associated with the CheerLights project every year, and this time, I’m using a Raspberry Pi to pull the last set of colours from the ioBridge server.

I’ll be putting a full write-up about the project itself up on here soon, but I’m still waiting for a few parts for it to be complete, but the bash one-liner is handy in and of itself, so I’ll put it here for now, in case there are others who want to start a CheerLights-based thing this year.

curl http://api.thingspeak.com/channels/1417/feed.json | jshon -e feeds -a -e field1 -u

This handy one-liner returns a nice list of the last 25 colours set by the API.




Arduino Batch Tool Prototype, version 1.2

I’ve been poking around in my batch tool, and have been pushing what you can do in the Processing IDE‘s add-on tool framework (turns out, not that much that’s every interesting without doing some fun Java hackery!).

With some slightly fancy trickery, the Arduino Editor now looks like this:

Stress testing the Arduino Batch Tool

Stress testing the Arduino Batch Tool

Yes, this is all loaded from an addon tool – not a rewrite of the IDE, not a custom build, just the stock editor with a single jar loaded from ~/sketchbook/tools and enabled in the menu.

Thus far, additions include:

  • A tabbed script console
  • Multiple target boards are configurable (for single-button-flash-everything functionality)
  • Multiple serial ports can be opened in their own tabs at the same time (and auto close and reopen during flash operations)

Non-visible additions include a partially implemented preferences dialog, and mutli-sketch multi-device support (flashing device A with sketch 1, flash device B with sketch 2, C with 1, etc. all from one button press, once configured).

I’ll be updating the download on the  Arduino Batch Flashing Tool page once I’m sure the tool is fairly stable.

If anyone uses this, I’d love to hear from you, especially those on Windows or Mac, as I’ve only tested this under Linux, but it should work on anything the Arduino IDE works on, as it doesn’t use any special binaries.




Arduino Batch Tool v1.1

Development!

Arduino Batch Tool 1.1 - Port configuration

Arduino Batch Tool 1.1 – Port configuration

With the addition of tabbing, multiple serial monitors can be instantiated at once – and the batch tool will manage them all during flash operations (disable, write, enable).

Arduino Batch Tool 1.1 - Embedded Serial Monitor

Arduino Batch Tool 1.1 – Embedded Serial Monitor

The tool doesn’t create its own serial monitors, but instead instantiates additional Arduino serial monitors and embeds them in the tool’s tabs.

The stock IDE serial monitor should still work, as long as you don’t try to open the same port in both at the same time!

Release should be soonish, check back in the near future!




434MHz Experiments

In an effort to find a vaguely affordable, 5v two-way radio solution with a decent range, I’ve been attempting to port the simplex RS-485 protocol I’ve been working on to work with pairs of 434Mhz radio transmitters and receivers.

Just a 434MHz transmitter on an ATMega32u4, for testing purposes.

Just a 434MHz transmitter on an ATMega32u4, for testing purposes.

Each node is to have a transmitter and receiver which can be enabled or disabled from code, following the same scheme as the 485 transceivers used on the wired network, and the same protocol can then be sent over wire and wireless alike.

A lashed together transciever made from an Arduino ProtoShield and a 434MHz transmitter/receiver pair

A lashed together transciever made from an Arduino ProtoShield and a 434MHz transmitter/receiver pair

However, at the moment I’m simply experimenting with the hardware to see if I can get a stable, long-ish range link using various Arduinos (Arduinae?) as my development platform.

For the curious – the JST connector on the micro board is for power, and is hooked up such that the normal polarity for a LiPo battery lines up with the GND and RAW pins on the board, hence the odd orientation.




Random Web Radio Station

To pull a random radio station from my stream list, using vlc, jshon and curl on the terminal, enter the following:

cvlc $(curl -s http://johnvidler.co.uk/radio/data/streams.js | jshon -e $(shuf -i 0-`curl -s http://johnvidler.co.uk/radio/data/streams.js | tr -cd ‘{‘ | wc -c` -n 1) -e stream -u)

It’s not terribly efficient, but what the heck, it’s only ran once per radio station 🙂




Lions, Tigers and Site Updates, Oh My!

It’s been a while, I know, but I’ve finally got around to updating various bits on here, including and update on my RS-485 projects along with a new page for my Micro-CNC Milling Machine.

screenshot-yellow

I also have uploaded a new app to the Google Play app store, CheerLights Live Wallpaper which pulls updates from the CheerLights Project, changing the colour of the home-screen wallpaper to match the current CheerLights colour (with a latency of around 15 seconds or so).

User warning: CheerLights does seem to like ‘white’ in the early hours of the morning… sadists!

Until next time!




Assembled RS485 Boards

Finally got them all soldered up… only to find I’m exactly one screw terminal block short.

 

Dangit.




Upcoming Talk – Serial Communications

I’m currently slated to present a talk at the CSLU (Lancaster University’s Computing Society) on serial communications with micro-controllers.

In addition to the talk, there will be a lab session where we will be working on a simple, practical communication scheme using Arduino micro-controllers and these beauties:

11 RS-485 Shields for the Arduino

Arduino RS-485 Shields for the Arduino

All ready to solder up, when I have the stacking headers that is – shipping from Hong Kong takes way to long!

I’ll update when I have more information about the talk, and after the fact will update the ‘Talks’ page on here with the slides, should anyone want to follow along.