Pinterest Stumbleupon Whatsapp
Ads by Google

Siri can be amazing at times, but she can only do what Apple allows her to do. Not anymore: a new Web service called BetterThanSiri is throwing the gates wide open, and it doesn’t require your device to be jailbroken to make use of it. Today, I’ll be explaining a little about the service, and showing you how to get started with controlling a set of RGB lights. Watch the video first to see it in action.

How Does This Dark Magic Work?

When you ask Siri to “Google” something, she opens up Safari browser and routes your request as you’d expect. It’s at this point that an HTTP request is made, so if you’ve set up an HTTP proxy on your Internet connection – a standard feature that doesn’t require jailbreaking – the request goes via the proxy first.

Now here’s where the magic is: by prefacing commands with “googolplex”, the search term becomes “plex” plus whatever you say. The proxy – BetterThanSiri.com – identifies the presence of “plex” and intercepts your search query. Whatever follows is then considered the actual “command”. BetterThanSiri performs pattern matching against your personal selection of configured commands, and runs the relevant code. It really is quite amazing, and I can’t wait to show you how to use it.

Controlling RGB Lights

To demonstrate BetterThanSiri, I’ve setup a basic IR send and receive circuit – see my previous tutorial on the TV devil prank Introducing the TV Devil, An Easy Remote Control Arduino Prank Introducing the TV Devil, An Easy Remote Control Arduino Prank Read More to learn more about interacting with IR codes, or read on for the condensed version. Here’s the parts you’ll need:

  • Arduino, Ethernet shield, and Ethernet cabling
  • IR LED, 220 Ohm resistor (depends on your particular LED, but this should suffice in most cases), and IR receiver
  • RGB LED strip lights, 12V power supply and existing remote controller

restduino-circuit

Ads by Google

Every remote control works by encoding a number in pulses of infra-red light – so first, you’ll need to learn the control numbers used by your particular remote. Download the IRremote library and restart the Arduino IDE. For most IR receivers, with the dome of the LED facing you, the pins from left to right are: signal, GND, +5V.

IR-recv

Wire in the signal to pin 11 and the other two as usual, and load in the IRrecvDemo example provided by the library. Open up the serial console and start pressing buttons on your remote – you should get some HEX values. We actually want those Hex values as a long integer number, so add a new Serial.println without the HEX part:

Serial.println(results.value, HEX);
Serial.println(results.value);

Record all the numbers you need. In my case, I found:

  • Red: 16195807
  • Green: 16228447
  • Blue: 16212127

If you’re using a different kind of remote, you may also need to load the IRrecvDump example, which will also output the type of signal – in my case, the remote was sending 32-bit (or 8-digit) NEC codes, which is reflected in my modified server code later – remember to change that if you need.

irrecvdump-example

Before proceeding, wire in your IR LED for sending (the flat side of the LED goes to GND, the other side goes via a 220 Ohm resistor to pin 3), and load the IRsendDemo. Duplicate the main send command a few times and substitute your own IR codes to test them – add a delay between each one. Upload, and if all is working well you should see your LEDs cycle through the commands you added.

irsendtest-example

Next, download the RESTduino package – there’s a replacement Ethernet library in there you’ll need to add and again, restart the Arduino IDE. RESTduino is a powerful RESTful web API – it creates a server, which listens to incoming requests with ability to control pins or read values from them. Try out the included demo first to ensure everything is working – you’ll need to modify the MAC address, make the server IP static, and define an IP on your local network range (probably 192.168.0.x or 10.0.1.x).

customized-restduino

You should then be able to access your Arduino from any browser – just try simple commands to read the values on analogue input 1 – for example:

http://10.0.1.99/a1/

It doesnt matter if nothing is connected, we’re just checking that the server works. Now, upload my modified version of this demo. I’ve stripped out the pin control, and just replaced it with IR control instead. Use a URL of the form:

http://10.0.1.99/1/IRCODE

The important line in the modified code is here:

irsend.sendNEC(strtoul( value, NULL, 10 ), 32);

You’ll need to change that if your remote control isn’t of the NEC type, or isn’t of 32 bits in length. I’ve also added a delay and repeated the command a few times, as IR can be a little unreliable sometimes. Finally, set up port forwarding What Is Port Forwarding & How Can It Help Me? [MakeUseOf Explains] What Is Port Forwarding & How Can It Help Me? [MakeUseOf Explains] Do you cry a little inside when someone tells you there’s a port forwarding problem and that’s why your shiny new app won’t work? Your Xbox won’t let you play games, your torrent downloads refuse... Read More on your router so that you can send IR commands from anywhere in the world. Forward everything on port 80 to the internal IP of your Arduino. You should now be able to replace the internal IP with your public IP, and the control should still work. We can now move over to setting up our custom commands on BetterThanSiri.com.

Begin by signing up, then log in to manage your personal command list.

betterthansiri-web-interface

Take a look at the existing commands if you’re curious about how they work, or just go ahead and create a new one. Name the command, and add the phrase matcher:

lights ~

setup-new-command

Which means “this command will match lights + anything”. Then paste in the code below – modify this to include your public IP address (or a dynamic DNS if you have one), as well as the phrases you want matched, and the relevant IR codes. The first variable in the function is just a little text sent back to the browser. You can copy/paste more of the else if bits to create as many commands as you want.

if(phrase == "lights on"){
 respondWithTextAndURL('Turning lights on','http://YOURIP/1/16236607'); 
}
else if (phrase=="lights red"){
 respondWithTextAndURL('Getting ready for sexy time','http://YOURIP/1/16195807');
}
else if (phrase=="lights blue"){
 respondWithTextAndURL('Work mode active','http://YOURIP/1/16212127');
}
else if (phrase=="lights green"){
 respondWithTextAndURL('You\'re weird','http://YOURIP/1/16228447');
}

Follow the instructions to set up the proxy on your device. Essentially, you just need to add an automatic HTTP proxy (URL: http://totally.betterthansiri.com) to your internet connection. The first time you use the service, you’ll need to log in from your mobile device so it knows what your personal commands are, but you’ll only need to do this once.

Limitations

As you can see, BetterThanSiri is quite a complex system at the moment – there’s no drag and drop interface so you’ll need to understand the basics of Javascript to create your own command set. That said, they’ve exposed an awful lot of power with the ability to post data to random URLs either in the background or just a redirect, so we really couldn’t ask for more. You can always browse existing recipes if you’re not up for programming your own.

It also doesn’t speak back to you as Siri does. All accounts include a “tell me a joke” feature similar to Siri, but the jokes are output on the screen, in your web browser. It’s possible they could add this later using a third party JavaScript plugin, but it may mean increased bandwidth usage or responsiveness.

Finally, there is of course the delay involved. Your speech is sent to Apple for processing into a text command, sent back you, sent out to the proxy, processed by BetterThanSiri, then sent back over the Internet to our local Arduino. In the demo each command took about 5-10 seconds total, and it’s unlikely this can ever be improved. For home automation, this is perfectly acceptable, but if you’re trying to deliver information back to the user in a timely fashion, it’s a little frustrating.

Security Concerns

Using an HTTP proxy like this means every HTTP request you make is routed through their servers: in theory, they could examine everything you search for, every site you visit. I asked the developers about this, and this was their response:

Definitely a valid concern, but we DO NOT look at every HTTP request. Our proxy autoconfig has a decision engine that only looks at the HTTP requests relevant to GoogolPlex (with “plex” in them).

You can take that at face value; it would be impossible to prove otherwise, but if the server software was open source (which it isn’t) you could at least verify that and run your own private server. Given the potential for commercial applications it seems unlikely they would open source it, so if privacy and security on your mobile browser is particular important, it’s understandable that this isn’t a service you’ll want to use.

Personally, I don’t think it’s understatement to call this service truly amazing. I heard about it initially a few months back, but at the time it was limited to basically just controlling Spotify – a proof of concept. Now that they’ve added the ability to create personalized commands and interface with anything, it’s an incredibly powerful system I’ll be revisiting in the future to form the basis of a complete Arduino home automation system. What uses can you think of for BetterThanSiri?

  1. Aaron Conlon
    November 1, 2015 at 5:46 pm

    I'd much rather have my own proxy running at my network edge, and not port forward in. Seems like it it would be easy enough. This way, I'm not sending traffic to a third party's proxy to do whatever they please with, and I don't have any of my LAN devices exposed on the public internet.

    This kind of thing has been around for a while, see https://github.com/plamoni/SiriProxy. The author used different techniques which may no longer work with the current IOS, but the effect is similar.

    I'd be wary of using a public Siri proxy, as anyone should be when using any proxy not administered by a trustworthy source.

  2. Thomas
    March 14, 2015 at 5:02 am

    I came looking for a way to open one note in iOS 8 directly to a specific page... So, this was not exactly what I was expexting, but I was really impressed with the quality! This is a great build guide on a really creative project! I'm an engineer, and I really appreciate seeing this kind of content on the web. Right on!

  3. Gunnar Oledal
    June 4, 2014 at 11:49 pm

    Niiice!

  4. Lenore
    June 3, 2014 at 8:39 pm

    Your article is like nonsense to me. I like MUO for being numpty friendly. Perhaps you could write it with an example that I can understand and even apply.

  5. James Fry
    June 2, 2014 at 10:35 pm

    It's actually not impossible to prove... just download the proxy config (.pac) file and look at it.

  6. Tim
    June 2, 2014 at 4:00 pm

    Easy. Make a BetterThanSiri channel in IFTTT and rule the Internet (and the Internet of Things).

Leave a Reply

Your email address will not be published. Required fields are marked *