The eKatana is a wireless smart sword consisting of both hardware and software components. The software in question lives on the microcontroller as well as in a phone or tablet device by way of a mobile app. The key to a successful product would be in the richness of a mobile app and service.
The hardware consist of easily attainable components specifically designed with hobbyists in mind. Outside of some basic soldering skills, which you can obtain on youtube, there really isn’t a lot required to build the prototype.
In this section we’ll take a closer look at the tiny module but suffice it to say that it packs a punch:
- A low power Arduino-based microcontroller
- Bluetooth LE (for wireless connectivity)
- 9-DOF sensor with 3-axis accelerometer, 3-axis magnetometer and 3-axis gyroscope
- A tiny, rechargeable 3.7v Lithium Ion Polymer Battery
Our eKatana module consists of a microcontroller shown on the left and a 9DOF set of sensors shown on the right. The two are powered via a 100mAh+ battery.
As you can see from this diagram, the wiring is really quite simple. Power and Ground are routed via the red and black wires and the green and yellow ones aid in data transfer. The Bluetooth LTE transmitter is the gray colored rectangle with a red backing and gold connector shown below the yellow and green wires.
Both components are small but it’s tricky to solder them together so that they stack. An easier layout is to attach them to a flat board and place them side by side as shown in the diagram above. That would allow for longer wires and easier soldering.
Before we dive into the actual code let’s take a brief look at a video of the demo app we’ll use. The mobile app is called BlueFruit LE and it’s running on my Samsung Note8.
As we love to say in the open source community, “running code speaks volumes”.
What the video shows is the app connecting to a Bluetooth enabled device called eKatana.
When launched we select the UART option in order to view the data being emitted from the device.
We see values for RO (Rotation), PI (Pitch) and HD (Heading).
As I move the sword the values change to reflect the sensor data being captured.
This allows us to determine whether the sword is rotating, whether it’s facing up or down and the direction it’s facing. Combined these values would allow for detecting how a practitioner is progressing through a Kata (form).
Let’s have a look at the actual code that’s generating that output. The code we’ll examine is first flashed onto the device using the Arduino IDE, version 1.8.5. I won’t get into how to flash the code onto the device — since that’s a fairly standard Arduino development process. See this video if you’re curious.
Some quick highlights:
Lines 1–8 are the headers for the libraries the code requires. Here we see that they’re all Adafruit libraries, some for Bluetooth functionality, SPI and UART interfaces, one for the all-important LSM9DS0 motion sensor breakout board and a Simple_AHRS library (attitude and heading reference system) which considerably simplifies our demo.
Lines 26 through 41 set the default sensor range values.
Lines 46 through 76 configure the onboard Bluetooth device.
Lines 78 through 99 constructs a loop that polls the
ahrs.getOrientation function to pull sensor data.
Lines 96 and 97 output sensor data using the Bluetooth library.
The trick to getting the code compiled is in ensuring that you’ve located and downloaded all the necessary libraries. But you’ll find the latest documentation on the Adafruit site.