bb_int

How Xively Internet Enabled the BBC Newsnight Chair September 19, 2013 | by

NewsnightThe Internet is going through yet another major paradigm shift. It began with connecting computers in the US defense department, then expanded availability to universities, and, in the 90’s to private sector PCs and, eventually, all our miniature computing devices, such as smart phones, tablets and more. Today’s shift is more radical. It’s about connecting everything in our physical world to the Internet, and it’s called the Internet of Things or Internet of Everything, depending on who’s talking. It promises to be massive in terms of economics and will fundamentally transform how we discover, understand and interact with our world.

BBC Newsnight became interested in this trend and came to Xively with a simple question, “Can Xively Internet connect the famed Newsnight anchor’s chair and do something simple like send a Tweet from the chair every time he sits down or gets up?” After all, Twitter has become a key way we get breaking news, find out too much about celebrities lives, and even helped start revolutions. It makes sense that it will also play a critical role in how the BBCNNChairInternet of Things communicates with the world. So we decided to take on the challenge. Of course we already knew the answer was “YES” so we were kind of sandbagging.

When we set out creating the Internet connected chair, we needed to determine how the electronics would integrate into the chair. The first instinct was to go to Staples, buy an inexpensive office chair, and start ripping the padding apart to fit sensors inside the chair seat. This would allow for detection when someone sits down in the chair and stands up. However, it wasn’t going to work. We would be using a different chair than the Newsnight anchor chair. We also couldn’t go ripping apart the actual chair, because then where would the Newsnight anchors sit during shows! So we modified our approach to a modular design using external sensor components that could be moved from chair to chair with little or no installation.

After searching around, we found a pressure sensing pad that sits on top of a chair. It functions as a switch that is typically used as part of a system to detect when someone is no longer sitting in a wheelchair. It had the right characteristics – thin, portable size and didn’t require integration with the chair itself. The pad was also very simple as it functions as a N.O. (normally open) SPST (single pole, single throw) switch, very similar to how a momentary push button works.

Next we had to decide how to connect the chair to the Internet. We used an Electric Imp platform since it is great for rapid prototyping IoT solutions. The Electric Imp is an SD-card size hardware development platform. Its built-in WiFi and ARM Cortex-M3 microcontroller take care of Internet connectivity and all the onboard processing for connecting to the P1050519switch. On top of the Cortex-M3, electric imp allows you to run server-side code which makes connecting to Xively and Twitter much easier.

The Electric Imp is seated in an April application board which allows the pad, or any peripheral, to be connected directly to the pins of the Electric Imp. The pad switch connects to the board on a digital input pin. A pull down resistor on this pin helps keeps the pin low when not being switched. The Electric Imp also has an LED connected to a digital output pin, which indicates when the device is turned on, configured, and connected to WiFi.

Now that the hardware was setup and functional, we needed to configure the Electric Imp device code to trigger an interrupt when the normal open pad switch is closed. However, first we had to work through the issue of “button bouncing”. When basing our calculations on the sitting event, it is necessary to ensure reading one switch state per event. We had to rule out shifts in position in the seat so the chair wasn’t Tweeting every time the anchor shifts in his seat. This was accomplished by pausing for a fraction of a second when the first interrupt is detected, then rereading the switch state to determine the proper sitting or standing state. When the switch is triggered, it goes through a “button bounce” delay and then the status and time are recorded. If the status is 0, that indicates a standing event, then the duration from the last 1 (sitting) status is calculated and recorded. All of this data is passed to the Electric Imp agent.

This agent is the server side code associated with each Electric Imp device, and allows robust integration through a REST interface with the Xively Cloud Service. Once thisNewsnightChair Twitter data is collected, the web services side of things begins. The status is turned into binary data, 1 for sitting, 0 for standing. This status along with the time is then sent to Xively, which allows for long term logging and historical time calculation after the fact.

We then moved on to constructing our Tweet. Once a single event was successfully detected and parsed, the current time was read and added to a template Tweet. We added a timestamp that made the Tweet unique, which is a requirement for Twitter to post it. It is also essential in calculating the duration that someone was sitting in the chair. For standing events, the current time stamp is subtracted from the last sitting time stamp resulting in the duration. This value is then added to both the time and the duration to the Tweet. The agent authenticates with Twitter using oAuth and sends one of two preset tweets: one for standing and one for sitting.

P1050493Turn on the power, connect to WiFi and Voila! The chair is now Tweeting to @Newsnightchair. Now this may seem a bit complicated but it actually was constructed in less than two days once all the parts came in. It is also a generic implementation as the Twitter integration can be configured for different accounts and different messages. The end result is that any chair can now become one with the Internet and BBC Newsnight has yet another channel to get information out to the world!

In case you were curious who built the BBC Newsnight chair, he’s our own Calum Barnes! Calum@xively.com Calum

 

 

Comments are closed.