Categories
gadgets

Connecting the Philips Hue Bridge to Wi-Fi

philips-hue-bridgeI needed to connect my Philips Hue Bridge to Wi-Fi to use it for a presentation at a conference in Brazil. Most public Wi-Fi networks segments each connection preventing communication between devices, besides the fact the Hue Bridge is Ethernet only (Not sure who at Phillips made that decision). Luckily I was able to come up with a solution.

All I needed was my MacBook Pro, which was connected to the conference WiFi and a Thunderbolt Ethernet adapter (which I always carry just incase there is wired Internet access).

Connect the Hue to the MacBook via the Thunderbolt adapter. Then under System Preferences -> Sharing. Select Internet Sharing. Connect from Wi-Fi to computers using Thunderbolt Ethernet (I usually have sharing set the otherway around). Then activate Internet Sharing (and verify you want to do it).

Sharing WiFi to Thunderbolt

This granted the Bridge access to the internet, and gave it a 192.x.x.x IP address that I could reach from my MacBook Pro (and the VM) to send commands to the bridge. This worked great for my presentation, but isn’t a solution for home connectivity.

Also, it turns out the Philips Hue Bridge I just purchased is now obsolete thanks to an Apple HomeKit requirement.

Categories
Android Components gadgets iOS Source Code

Parrot AR.Drone 2.0 Delphi Component

githubI took my code I previously used to control the Parrot AR.Drone and turned it into a reusable component. I added some more functionality to it as well, although there is a lot more to cover. The component is available on GitHub.

It should work with Delphi, C++Builder, Appmethod and RAD Studio on iOS, Android, Windows and OS X. I’d love to hear how it works for you and what you use it for!

Categories
Android gadgets Mobile

BlueTooth Remote Control Car

How to use BlueTooth is one of the most common requests with Delphi. During our Devices and Gadgets webinar David I. showed how to browse paired BlueTooth devices and connect to them.

But wait, there’s more! Daniele Teti & Daniele Spinetti of bit Time Software created an Android client app to control a BeeWi – BBZ201 – Mini Cooper S Bluetooth Car. It may work with other BeeWi Bluetooth remote control vehicles, but has not been tested with any (that I know of).

The Multitouch code is Copyright (c) 2006-2014 Iztok Kacin, Cromis and used under the BSD license.

It currently doesn’t have BlueTooth discovery, so once you pair your device you need to update the source code with the MAC address of your car.

I’ve created a GitHub repository for the project. It should work with XE5 or AppMethod just fine. I’ve got a version updated to XE6 that exposes the controls via App Tethering too, which I will upload later.

Categories
Brain Computer Interface Delphi Projects gadgets

Thought Controlled Quadcopter

Last night I “controlled” my Parrot AR.Drone Quadcopter with my thoughts through my Emotiv EPOC Brain Computer Interface via an app written in Delphi XE5. I qualify “controlled” in that my flight pattern was a little irregular and short before I crashed it. It was a “look mom, no hands” moment though as the drone was clearly responding to my thoughts for the few seconds before it crashed. I’ve got a lot of work to do in improving the process, so I will be posting code and videos soon. If you want to get a start on it though, it is based on my work from the Devices and Gadgets webinar.

I’m presenting tomorrow at Boise Code Camp on “Is Thought the Future of Wearable Input?” and if all goes well I’ll have a brief demonstration of the tech in action. If you are in the area my presentation is at 11 AM in the Special Events Center at Boise State University.

Categories
gadgets

Connecting to the Kinect for Windows with RAD Studio XE5

The Kinect is a 3D motion sensing input device for Windows. Based around a webcam-style add-on peripheral, it enables users to control and interact with their computer through a natural user interface using gestures and spoken commands.

You can get the Kinect SDK and drivers from Microsoft and the Delphi header files and samples from Google Code. This video was part of the Making the Connection: Programming Devices and Gadgets with RAD Studio webinar. You can view the full directer’s cut of the webinar on demand and download the code.

Categories
Brain Computer Interface devices gadgets webinar

Connecting Delphi to my Brain with the Emotiv EPOC

Emotiv EPOC NeuroheadsetThe Emotiv EPOC might seem more Sci-Fi than practical technology. It is designed to pick up on brain waves through its 14 brain wave sensors (plus 2 reference receivers) and convert them into a usable signal for your computer. For head tracking it also includes a head mounted gyroscope.

The sensor input comes in 4 different categories:

  • Head rotation: The gyroscope returns acceleration information about the movement of your head.
  • Facial Expressions: Referred to as the Expressiv Suite, it processes the signals to detect facial expressions in real time. This includes winks, smiles, and eye movement.
  • Emotions: The Affectiv Suite provides real time emotional feedback including frustration, distraction, etc.
  • Direct Thought Control: The Cognitiv Suite lets you define trained brain patterns that you associate with different outcomes. When you repeat the brain pattern the system responds appropriately.

If you want to play with the Emotiv EPOC it is $500 for the developer set. The normal consumer set only works with official licensed software. It comes with a nice control panel that lets you play with the different inputs.

Thanks to the work of Simon J. Stuart (aka LaKraven) the SDK has a full Delphi translation. I have a short demo using the gyroscope. The brain access systems were giving me a handshake error, but that may be a commentary on my brain power.

My next objective is to unlock the brain interface and combine that with the Parrot AR.Drone api so I can fly the quadricopter with my mind.

That was part of the 11 demos in our Devices and Gadgets webinar. You can access the full replay on demand, which includes access to most all the drivers, wrappers, apis and source code. The only missing source code is to Allen Bauer‘s bluetooth infrared velocity screen system. He’ll have a blog post about that one.

Categories
Android Brain Computer Interface devices gadgets iOS Mobile

Connecting to the Parrot AR.Drone 2.0 from Delphi XE5

My first thought when I see cool technology is to figure out how to connect to it with Delphi. So the day I got the Parrot AR.Drone 2.0 quadricopter I started working on Delphi interface. By the time evening rolled around the batteries were dead (after a couple recharges), but I had a basic interface working. The official developer guide seemed to be a little out of date, or I was reading it wrong, but once I got my facts staight, connecting was really easy. http://www.youtube.com/watch?v=aaGe2aERwgI The Parrot AR.Drone has it’s own access point. Once you’ve connected to it, then it is simply a matter of sending UDP packets for the basic controls. To accomplish that I simply used the Indy UDP Client: TIdUDPClient. Each command is sent with an increasing sequence number, so I initialize my interface as follows:

  udp := TIdUDPClient.Create(nil);
  udp.Host := '192.168.1.1';
  udp.Port := 5556;
  seq := 1;

The AR.Drone is always at 192.168.1.1 since it is the access point, and the port for communication is 5556 (one of a few ports, but the one we need for now.) It is worth pointing out that if you’ve previously flown your AR.Drone with the FreeFlight mobile app then you may need to reset your drone to unpair it. Otherwise it is paired to only that device. The commands are formatted with an AT* prefix, and a series of arguments. For example, to take off, the command is AT*REF=1,290718208 where AT*REF is the command, 1 is the sequence number (always the first argument) and 290718208 is a bitmask that means take off. I created a SendCommand routine that looks like:

procedure TARDrone.SendCommand(cmd, arg: string);
var
  full: string;
begin
  if not udp.Active then Connect;

  full := Format('%s=%d,%s' + Chr(13), [Cmd, Seq, arg]);
  Seq := Seq + 1;
  udp.Send(full);
end;

Notice the command is terminated with a carriage return (#13). The documentation says line-feed (#10), it is wrong. Supposedly you can send multiple commands in the same message, if they are separated by the carriage return. I haven’t tested that. Then I can send the some common commands like this:

  SendCommand('AT*REF','290718208'); // Takeoff
  SendCommand('AT*REF','290717696'); // Land
  SendCommand('AT*CONFIG', '"control:altitude_max","10000"'); // unlimited altitude
  SendCommand('AT*CONFIG', '"control:altitude_max","5000"'); // restrituded altitude - unsure what units 500-5000.
  SendCommand('AT*PCMD','1,0,0,0,0'); // Hover (stop movement)

PCMD is the move command. It takes 5 arguments (after the sequence number.) The first is the controller type, which we are leaving 1 for now. The next 4 are phi, theta, gaz, yaw and they are floating point numbers in an integer representation. This is where it gets interesting. The documentation says:

The number –0.8 is stored in memory as a 32-bit word whose value is BF4CCCCD(base 16), according to the IEEE-754 format. This 32-bit word can be considered as holding the 32-bit integer value –1085485875(base 10).

The first way I thought of to access the same memory as two different types is a variant record. So I came up with the following helper routine:

function IEEEFloat(const aFloat: Single): Integer;
type
  TIEEEFloat = record
    case Boolean of
      True: (Float: Single);
      False: (Int: Integer);
  end;
var
  Convert: TIEEEFloat;
begin
  Convert.Float := aFloat;
  Result := Convert.Int;
end;

Using that I built a move routine that takes 4 singles (32-bit floats) and sends them as integers:

procedure TARDrone.Move(const phi, theta, gaz, yaw: Single);
begin
  SendCommand('AT*PCMD',Format('1,%d,%d,%d,%d',
    [IEEEFloat(phi), IEEEFloat(theta), IEEEFloat(gaz), IEEEFloat(yaw)]));
end;

Now if I want the drone to go up I can call:

  Move(0,0,5.6,0); // positive gaz is upward acceleration

Now it is just a matter of figuring out how to the rest of the movements map to the physical worked and building a user interface on Android, iOS, Windows or Mac. Maybe all 4! Once I build up the API a little bit more I’ll share some full working apps and libraries. Let me know if you are interested in collaborating on such.