notes on bluetooth

Hey guys,

This entry is long overdue but hopefully still helpful to those interested in working with bluetooth in your projects. Bluetooth technology is both 1) a desirable, relatively low energy way (in comparison to WiFi) to get separate microcontrollers to communicate wirelessly and 2) extremely confusing and frustrating, in my amateur opinion. I went through some trial and error working with it in the making of my Illuminati turn signal jacket and would like to share my findings with y’all.

First off, there is a big difference between Bluetooth classic and BLE (Bluetooth low energy). Bluetooth classic is designed for constant communication and more intensive data streaming between devices, while BLE is best for intermittent “small data” transfers and conserving battery life. More info on Bluetooth classic VS. BLE here.

The first bluetooth modules I purchased, rather naively, were the Adafruit Bluefruit LE modules designed for the Flora. This is when I learned that in the world of bluetooth, there are slaves and there are masters.

adafruit-flora-bluefruit-le-modul-bluetooth-ble

Now, a master can play the role of a slave, but a slave cannot play the role of a master. And a master can have many slaves, but a slave can have but one master. That sounds like the darker side of American history, or some kinky shit straight from the pages of 50 Shades of [Blue], but it has to do with the complexity and versatility of the bluetooth module and its programming capabilities. Essentially, masters initiate connections and ‘can do more stuff’, so master-capable boards have more junk on them. Many of the handy breakout boards you see on Sparkfun or Adafruit are examples of simpler slave modules, which are a lot easier and typically cheaper to work with. Adafruit and Sparkfun have even designed apps that allow you to interact with your project in specific ways. But if you are looking to do something outside of connecting your microcontroller to your phone or computer–i.e., connecting two or more of your microcontrollers–you’ll need to attain and work with master-capable modules.

Since I could not connect the Bluefruit modules to one another, I purchased two of these Bluetooth classic HC-05 modules (which can be either a master or slave):61b8oCGYJdL._SL1191_.jpgI had to configure one to be the slave (for the glove switches/remote) and one to be the master (for the jacket’s “brain”), a process that involved controlling power flow to the HC-05s, connecting to a serial console and use of AT commands, as well as setting specific baud rates. Here is a nice blog post that explains all this in greater detail, as well as how to pair or bond the modules. I used these HC-05s to make my tester units talk to each other, a very exciting moment! seen here:

Programming for master units is a little difficult because 1) these kinds of modules must be programmed separately from the microcontroller and 2) none of the sample sketches readily available through Sparkfun or Adafruit contain examples of code that utilize bluetooth modules as masters (for obvious reasons). Here’s the source code for the glove’s HC-05, communicating the status of its contact switches to its master:

#include <BLE_API.h>
#define DEVICE_NAME "HRM1"
BLE ble;
Timeout timeout;
static uint8_t bpm = 0;
static const uint8_t location = 0x03;
static uint32_t cnt;
static const uint16_t uuid16_list[] = {GattService::UUID_HEART_RATE_SERVICE};
GattCharacteristic hrmRate(GattCharacteristic::UUID_HEART_RATE_MEASUREMENT_CHAR, &bpm, sizeof(bpm), sizeof(bpm), GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_NOTIFY);
GattCharacteristic *hrmChars[] = {&hrmRate, };
GattService hrmService(GattService::UUID_HEART_RATE_SERVICE, hrmChars, sizeof(hrmChars) / sizeof(GattCharacteristic *));
void disconnectionCallBack(Gap::Handle_t handle, Gap::DisconnectionReason_t reason)
{
 ble.startAdvertising();
}
void m_uart_rx_handle()
{ //update characteristic data
 ble.updateCharacteristicValue(hrmRate.getValueAttribute().getHandle(), &bpm, 1);
}
void uart_handle(uint32_t id, SerialIrq event)
{ /* Serial rx IRQ */
 if(event == RxIrq) {
 uint8_t newState = 0;
 while(Serial.available()) {
 newState = Serial.read();
 }
 if(newState != bpm) {
 bpm = newState;
 timeout.attach_us(m_uart_rx_handle, 100000);
 }
 }
}
void setup() {
 Serial.begin(9600);
 Serial.attach(uart_handle);
ble.init();
 ble.onDisconnection(disconnectionCallBack);
// setup adv_data and srp_data
 ble.accumulateAdvertisingPayload(GapAdvertisingData::BREDR_NOT_SUPPORTED | GapAdvertisingData::LE_GENERAL_DISCOVERABLE);
 ble.accumulateAdvertisingPayload(GapAdvertisingData::COMPLETE_LIST_16BIT_SERVICE_IDS, (uint8_t*)uuid16_list, sizeof(uuid16_list));
 ble.accumulateAdvertisingPayload(GapAdvertisingData::HEART_RATE_SENSOR_HEART_RATE_BELT);
 ble.accumulateAdvertisingPayload(GapAdvertisingData::COMPLETE_LOCAL_NAME, (uint8_t *)DEVICE_NAME, sizeof(DEVICE_NAME));
// set adv_type
 ble.setAdvertisingType(GapAdvertisingParams::ADV_CONNECTABLE_UNDIRECTED);
 // add service
 ble.addService(hrmService);
 // set device name
 ble.setDeviceName((const uint8_t *)DEVICE_NAME);
 // set tx power,valid values are -40, -20, -16, -12, -8, -4, 0, 4
 ble.setTxPower(4);
 // set adv_interval, 100ms in multiples of 0.625ms.
 ble.setAdvertisingInterval(160);
 // set adv_timeout, in seconds
 ble.setAdvertisingTimeout(0);
 // start advertising
 ble.startAdvertising();
}
void loop() {
 ble.waitForEvent();
}

And the source code for the turn signal’s HC-05, receiving and responding to the UART data being sent from the glove’s:

// SERIAL LOOP SKETCH FOR COMMUNICATING WITH A BLUETOOTH SPP MODULE
// BASE HC-05 Config Commands
// AT+ORGL (Restore the factory default state)
// AT+UART=115200,0,0 (Set transmission rate to 115200 bps, one stop bit and no parity bit)
// AT+NAME=Smoothie
// AT+PSWD=0000 Set pairing code to 0000
#include <SoftwareSerial.h>
#define rxPin 10
#define txPin 11
SoftwareSerial mySerial(rxPin, txPin); // RX, TX
char myChar ;
void setup() {
 Serial.begin(9600); 
 Serial.println("AT");
 mySerial.begin(38400);
 mySerial.println("AT");
}
void loop() {
 while (mySerial.available()) {
 myChar = mySerial.read();
 Serial.print(myChar);
 }
 while (Serial.available()) {
 myChar = Serial.read();
 Serial.print(myChar); //echo
 mySerial.print(myChar);
 }
}

Disclaimer: this code was thrown together just to get the testers working. To do so, some sample codes were hacked together for the glove–that is why heart rate belts were referenced.

After getting the testers to work, I realized that BLE units would work a lot better for my purposes. The only data I needed to communicate between the jacket and glove was the status of the contact switches on the glove, so I could save a lot of battery life by switching over to BLE. I found these tiny, cute little modules, the Redbear BLE Nano:

static1.squarespace.png

BLE is a completely different technology from Bluetooth classic. Here is a useful “crash course” on BLE that contains some sample code for utilizing BLE modules as master/server. I will refrain from providing the code used on my project seen in crit unless requested, and then only privately, as I received a lot of help on it and feel it is not my intellectual property to share. It is still in need of further development, and as we are in the process of applying for a patent for our product, I have been advised to not “over share”.

I hope this helped a bit and if you have any questions, please ask!

And if anyone knows about Zigbee, please share!

Progress on Turn-Signal Jacket & Glove Controller

I am happy to report that I am very close to fabricating a functional prototype that I can take to the streets for beta testing! For now, I have some less-than-functional, but working, prototypes:

protos.jpg

On the left is a sample arrangement of neopixels for testing turn-signal code. On the right is a temporary glove controller for testing touch pad buttons. As of now, the two do not communicate or interact with each other. Before delving into too much detail, here are some videos of what the prototypes are capable of:

The big challenge of this project is the wireless connectivity between the glove controller and the turn-signal jacket. I naively purchased two bluetooth modules before doing much research (adafruit Bluefruits designed for Flora) and found that they will not connect with one another. They are both considered “slave modules” and can only pair with a “master module” such as a computer or cellphone. Obviously this would not work for my purposes so I purchased two HC-05 modules, which can be assigned either master or slave roles:

I spent the day yesterday learning about these modules and how to program them. The trick was getting them into “command mode”, which entailed controlling the power level feeding into the module’s KEY pin, and using AT commands to assign roles and initiate pairing. This was sort of advanced stuff, so I enlisted help from some programmer friends of mine:

By the end of the day, we managed to get the modules paired and communicating with one another over the serial port. Unfortunately accomplishing pairing was the “easy part” and I still have a lot of problem-solving to do as far as applying this connectivity to my project. I must integrate the modules into my project–assigning the jacket module as master and glove as slave–and program the glove and jacket microcontrollers to read and respond to the data sent over the Bluetooth serial channel. Luckily I do have some help with this complicated coding stuff so I can focus more on fabrication, which presents a whole other can of worms!

In the interest of keeping this post relatively short, I’ll forgo the individual details of the design, fabrication, and programming issues that I am facing for the glove and jacket here. I’ll make a separate post for that.

In conclusion, I have determined that for the purpose of this assignment, my end product will be 1) a jacket prototype with integrated turn-signals and taillights and 2) a single glove controller prototype (for the left hand) with switches that will toggle the jacket’s turn-signals on and off as well as display indicator lights for the corresponding signals. The jacket and glove will communicate wirelessly over Bluetooth (hopefully low-energy BLE) and be powered by rechargeable li-poly batteries. While I have many other ideas for furthering the product’s design and enhancing its functionality for “hardcore use” by bicyclists and motorcyclists (integrating a 9DOF sensor for brake-light and turn-signal auto-cancel functions, a light sensor for automatic day/night brightness settings, heated elements, ability to connect to alternate power sources), those will have to be explored in the future outside of class. Although I will not have time to include all the cool ideas I have for this project, I do plan to integrate the needed sensors and data-logging devices (SD card) into the prototype in anticipation of further development!

One final note: at the recommendation of a friend, I consulted an intellectual property attorney seeking to patent my idea. While there are many DIY turn-signal jackets out there, I felt my design was unique with its integration of an accelerometer for auto-canceling and brake-light functions. Unfortunately I missed my opportunity by less than a year! The holder of the patent created a product that won an innovation award at the International Consumer Electronics Show earlier this year. However, I may still be able to patent the integration of a turn-signal switch into a glove (cross your fingers for me!). I bring this up to point out that while wearable tech is developing FAST, it’s still very NEW. So do not hesitate to look into patenting your great idea! You may get lucky.

Progress on Gesture Glove

Hi everyone. I’ve been out of class so I thought I’d write a post about my body listening project: a gesture-sensing glove. At the moment its more of an orientation-sensing glove. For starts, I picked up this sensor:

61GJJj4QJeL._SX425_

It is an accelerometer, compass and gyroscope all in one so it reads “9 degrees of freedom”. An accelerometer measures motion and gravity. A compass senses magnetic north/position. A gyroscope senses rotation. In this sensor, data from all three are combined to calculate orientation.

The first version of my glove:

unnamed

It was made entirely of leather and used conductive thread to connect the microcontroller and sensor. However flexibility and connectivity were issues. The sensor could not provide a constant flow of data to the Flora and when disrupted, the program needed a complete reboot. Not optimal, obviously. I am still troubleshooting my technique with the conductive thread, as I believe it ought to work and think the problem may lie in my rather messy tied-off ends. That stuff is hard to tie into neat knots!

Here are the improvements I’ve made thus far:

unnamed-1

As you can see, I replaced the leather with stretchy knit material at the knuckles to allow greater flexibility, and added more elastic around the fingers for a more snug fit.

I also added the thumb sleeve (which was always the intention). Note that all the fingers have conductive pads on them, which can be utilized eventually as buttons–when the thumb touches the conductive pad on the index or middle finger it completes a circuit. However I haven’t connected the pads yet, so for now they just allow the use of touch screens while being worn. Lastly, I replaced the conductive thread with soldered wires, which are hidden under the leather.

unnamed-2

This sensor produces a LOT of scary-looking data. I pulled some code for a data visualization program from learn.adafruit libraries in order to make some sense of it immediately, and its pretty cool. I’d be glad to show to anyone who is interested!

-MK

gesture listener

very much inspired by the mi.mu gloves by imogen heap, i am interested in making a glove that tracks the motion of hands and fingers. as an artist, maker, and guitarist, my hands are beyond precious to me. i think i am more my hands than i am my mind, at times. i have been told that i gesture a lot, and in a peculiar way, while speaking. interestingly, my mother often points out that my father and i gesture in the same way, despite the fact that i was not raised with him (it is thus a genetic trait, not a learned one). it is also a very unconscious trait.

to “listen” to the gestures i make with my hands, i plan to use this adafruit accelerometer/compass:

sensors_1247-01 sensors_1247-00

i will construct a glove, or glove-like item, that places the sensor in my right palm. it may be interesting to compare the results between different wearers. perhaps it could allow me to recognize my own peculiar way of gesturing that i am so unaware of.

-mary kate

Wearable Moto Gear Tech

11061308_830770427366_7139574102617486611_nI do not advocate riding a motorcycle in a skirt.

Here I am on my motorcycle. I really like the motorcycle because I feel more connected to environment than when I am in a car. It’s hard to see in this photo, but I have a bluetooth device installed in my helmet, a Sena SMH10R. It allows me to speak with riding buddies via intercom or connect to bluetooth devices such as my phone: I can listen to music & navigation directions and I can accept phone calls. There’s even a speed dial function I can program to make calls from the helmet.

The device has voice command options but I do not use them because at high speeds the sound of the wind passing through the helmet’s vents can trigger it accidentally. So I control all the functions of this device exclusively through this 3-button controller mounted to my helmet:

2013-08-08-00-45-32-IMG_3831Three buttons: +/middle/-

This piece of wearable tech has completely changed the way I ride. I am less likely to get lost on the way to an unfamiliar location and people can reach me when previously I was unreachable while riding. My riding buddies and I can alert one another to potential hazards and relay our positions–in fact this intercom feature has already saved me from what could have been a fatal collision once. Plus, listening to music while riding a motorcycle is absolutely blissful!

1) My first idea is to create a glove controller that serves as a remote control for my device.

The 3-button helmet-mounted controller is somewhat problematic. It alone controls all the varied functions the Sena offers. That means that some buttons are multi-purpose–you have to hold them a beat or two longer to access their secondary functions. This is not very convenient while riding. I prefer to keep both hands on the bars while in motion. Sometimes my left hand is “busy” and I cannot take it off the clutch to operate the controller. Even when I can spare my hand, the buttons can be hard to differentiate when I am wearing gloves (which is always).

The glove controller would have various “contact points” installed along the right sides of the fingers as well as on the thumb pad. When the wearer touches one of the points with his/her thumb, it completes a circuit and carries out a programmed function. It would need to have bluetooth and pair with the Sena.

BearTek-Bluetooth-Gloves-02AW MAN! I did some googling and this product already exists. It’s called a BearTek.

Anyways, product compatibility between the glove and my Sena would be hard for me to pull off at this juncture because of my lack of programming skills, but perhaps I could create a glove to connects to another simpler object of my own design, such as….

2) a moto jacket with LEDs arranged in the shape of arrows on the the shoulders. This way the jacket could serve as a turn signal!!

turn_ - 58Of course this has already been done, as well. This one is actually using a Flora.

I’m not at all surprised this has been done. Mine would be much cooler-looking, though (obviously).

3) Can I come up with an original idea? Let’s give it a shot. Well, this one is a total pipe dream way outside my wheelhouse, but it’s something I’ve been thinking about a lot. It is inspired by the epic SKULLY helmet, which is new on the market:

helmetSpecs

It is a groundbreaking product because of its HUD (heads up display), which makes it an augmented reality wearable. Even cooler, the HUD uses infrared eye tracking to focus the image, so that the wearer does not have to refocus when glancing down at it and back up to the road.

haxpdthpozrlmxuyuddc

Even cooler, it has a rearview camera! The HUD can project the SKULLY navigation software or the feed from the rearview camera. It also displays info about phonecalls, music, etc.

2014-skully-ar-1-motorcycle-helmet-2

My question is: how can the features of the SKULLY (infrared eye tracking, HUD, rearview camera, accelerometer, GPS and surround sound) be utilized in other ways? My first thought: Collision Detection: With more cameras, video footage can be used to calculate trajectories of moving objects around the wearer (there are already plugins that track moving objects in video, their change in size can be used to calculate change distance). The accelerometer and GPS can be used to calculate trajectory of the wearer. A program could be designed to compare these trajectories and determine threats and level of risk. The wearer can be alerted to potential hazards with a directional tone (using surround sound) accompanied with red “danger light” LEDs within the helmet, and an image can pop up on the HUD.

Another idea for the SKULLY is to utilize the infrared eye tracker for a Rider Impairment Gauge. Infrared eye tracking is something I am VERY interested in because it can be used to determine so much about the wearer: intoxication level, exhaustion, and focus (or lack thereof). The helmet could warn the user of his or her own impairment level and/or shut down distracting features in times of high impairment (music, phonecalls, HUD brightness). I would be interested to add to the helmet a GSR (galvanic skin response) sensor, as well for this purpose.

-Mary Kate P.

Week 1 Reading Response – Mary Kate

I agree with Sam that this article becomes increasingly opinionated and subjective as it continues. I don’t necessarily have a problem with authors doing this, even in scholarly journals (when it comes to fine arts). However I found the objective parts of the paper to be more useful for me.

I took special interest in the section about surveillance and privacy. I realized that this article is a bit dated because it neglected to mention some of the major privacy concerns for the typical consumer when it comes to wearables: bombardment of advertisements tailored by data gathered from private interactions (like when you see all-too-relevant ads pop up in your browser after having a certain conversation with a friend on Facebook), personal biometric data being used against us (such as insurance companies increasing premiums in response to fitness tracking device data), being stalked/hacked by technically-inclined “weirdos”/obsessed exes, and of course identity theft. Tracking devices under the skin?! How else can these devices be used? Could these devices be used by the police? Hello, big brother. This stuff is real and technology is advancing faster than protective laws can be written.

I found the explanations of different sorts of materials to be the most illuminating since I don’t know much about them. I am interested in experimenting with the different color changing inks that can be printed on textiles: thermochromic, photochromic, hydrochromic, piezochromic (pressure-sensitive? Umm, neat).

I agree with the author that as this technology becomes more accessible to designers and artists (as opposed to, say, military people) for use in the creation of consumer products, new unthought-of applications of the tech will emerge and it’ll be super-cool! However I also believe in the merit of functional stuff. Really great tech design marries aesthetic and function–no need to sacrifice the latter in favor of the former.

Hi, I’m Mary Kate

and I believe that

Art + Science = Power.

I am an interdisciplinary student taking classes in the Fashion, Designed Object, and Art & Technology departments. I am also a transfer from RISD and a “super duper senior”.Throughout my higher education I have bounced back and forth between the fine arts and natural sciences–specifically film, ecology and marine biology. In addition, I SCUBA dive, ride motorcycles, and have a dog named Huck.

I spend a lot of time thinking about modern society’s nostalgia for a romanticized, more “natural” past world as well as our apocalyptic fears for the future. I think of the present as the place where history and the future intersect, how exciting/terrifying! I enjoy combining historical and futuristic aesthetics into my work.FUCK OFF 2.0

spikes_c

I am taking this class because I believe that technology should respond to the user a little more, as opposed to us always responding to it. I am interested in the use of biometric and environmental sensors to create devices that are sensitive to the user and the world around her, and can thus enhance her life instead of constantly distracting from it. I am also excited by augmented reality, though that stuff feels beyond my scope at the moment. The mind boggles at the many possibilities and I have many ideas! At the same time, I am increasingly concerned about privacy and ethics. As we become cyborgs and translate our identities into data, how do we maintain our individual human rights? 

This semester I am hoping to create a corset with electroluminescent wire boning that pulses in synch with the wearer’s heartbeat. Eventually, however, I’d like to design functional specialized gear to maximize efficiency and safety of SCUBA divers, motorcyclists, extreme athletes, researchers in the field, and other wunderkinds.

I am looking forward to getting to know all of you!