Philly ETE 2014 #10 – Connecting Arduino and Phones with Bluetooth and Cordova – Don Coleman

all right hey everyone welcome thanks for coming out my name is dawn coleman and I’m gonna be talking about connecting phones to Arduino with Bluetooth in Cordova so the basic problem here is that we have a device and have a phone and I want to get them to talk to each other there’s a lot of different ways we can do this so I’m going to talk about one way to do this we’re going to talk about Arduino is on the device side and using Cordova or phonegap on the phone side but a lot of this can be generally applicable to other things that you could substitute a Raspberry Pi for the Arduino or potentially other hardware so we’re going to be talking about Bluetooth to do this and bluetooth is reasonably designed as a wire replacement protocol so for things like you know replacing your keyboard your mouse typing music your speakers stuff like that and it works pretty well for that there are some alternatives we could be using you know why fire just doing general TCP networking which works great on phones because phones are almost always connected to the network you can do that on the device side but particularly with an Arduino you don’t have a lot of memory you don’t have a lot of power so if you’re going to be running an HTTP stack or on the network stack you’re going to potentially be using up a lot of the space you’d be it could be used for other codes so there’s some circumstances where your devices can be plugged into a wall you could do Wi-Fi but there’s other things where Bluetooth may be a better alternative then there’s things like the mesh networking technologies exbii zigbee z-wave and then a bunch of four 33 megahertz and other kind of random 2.4 gigahertz frequencies those are used a lot in getting small devices to connect to each other and they can work well for certain circumstances the problem is we’re going to a phone that doesn’t work because while some phones have z-wave most other phones don’t have any of those things so if you’re going to connect your devices to phones that way you’ll need a some sort of bridge it’s going to go between your mesh networking oh and your phone so for some things Bluetooth can be really good bluetooth means you need to be close to it though it’s a 10 meters is the advertised strength for Bluetooth or so bluetooth that’ll do 30 meters but pretty much you need to be within proximity these devices to make them work which can look good for some things but if you’re you know halfway across the world and want to monitor things bluetooth isn’t going to be a good choice for you so when the phone side we’re going to talk about Apache Cordova and when I mentioned Cordova sometimes I get a lot of blank stares so the other name is found gap Apache Cordova is the open-source version of phonegap originally it started off as phonegap when the source code was donated to Apache they change the name so adobe still distributes phonegap there’s other people to distribute Cordova with under different names so I’ll use the terms phonegap in Cordova interchangeably the thing to know about Cordova is that it’s going to allow us to write native apps using HTML Javascript CSS so for the purpose of this talk it’s okay if you don’t know Cordova really what we’re going to be leveraging here is the JavaScript API to access the Bluetooth hardware and to be sending and receiving messages so if you’re going to run Cordova on your machine on easiest way to do it is if you have no Jess installed you can use the node package manager to NPM install Cordova and it puts a set of command line tools on there you also need if you’re doing Android the Android development kit if you’re doing iOS you need to be on a Mac and have xcode and all those tools installed if people are interested in that I’m happy to talk about it later i’m going to kind of gloss over that for now there’s really good documentation and getting started at the cordova website so really freak well you said to rumor now is that we’re going to have JavaScript API to access Bluetooth and we’ll be able to do that from iOS and Android using the same api’s excuse me so on the Arduino side our doing those are small microcontrollers they’re made for education but people have hijacked them and do all sorts of things with them they have really slow crappy processors are like 16 mega hertz but they’re really good at doing i oh so you can interact with hardware you can read data in from hardware they’re really good at that there’s no operating system so even though it’s super slow processor your code can actually go in pretty fast and they’re about twenty-five dollars so it’s like if you break them or you can have a bunch of them put in places it’s really easy to get started with them the other thing we’re going to need is a bluetooth radio so there’s a couple different flavors are doing this sometimes a small breakout boards like the ones on your left there and so those small breakout boards you’ve wired them up and attach them to the Arduino there’s the other thing in there Aquino world called shields which is over on the right-hand

side and shields basically plug into the pins on the Arduino so it’s really easy just stack them up and then it gives you access to that hardware so for some of the demonstrations today we’re going to use one of these breakout boards and the way these breakout boards the nice thing about them is they basically talk serial between a Bluetooth and the Arduino so basically one transmits the other receives and the opposite of that there so it’s really easy to connect these things together and you just have to really worry about two wires going in for the transmit and receive so I showed arrows but we’re actually going to wire things out there once you have that the Bluetooth radio and the Arduino can talk to each other they can send data back and forth we’re also why are some power-ups so we can have five volts powering it and then once we have our phone in there the radio will take care of doing everything between the phone and the Bluetooth radio on there between outside and a lot of that becomes transparent to us and makes it really easy to get this code working so when we’re working with Android we’re going to use something called a serial port profile which is a standard Bluetooth class expect that allows you to basically send serial data back and forth over Bluetooth as if you had a wire connected so we’ll do serial over the Bluetooth and then once it gets to the Bluetooth radio will have a literal serial over wire to the Arduino and we’ll be able to send messages back and forth so when you go to program in Arduino you use an Arduino IDE which is a piece of Java software so it runs on mac linux and windows and you basically have a printer cable or a USB cable that you can plug one end into your computer and the other end into your Arduino that powers it for development and it also is how you send code back and forth so we have one radio here and this is a just so it’s Arduino Uno which is the most common one and then I have this little bluetooth radio on top of it and we have this really short program here I’ll step through it because it’s probably tough to read but basically what this program is going to do is it’s going to generate some data on the Arduino side and we’re going to receive that on the phone side so it’s not very useful as far as actually doing something but as far as demonstrating how we send data across it’s pretty good example so the first thing we need to do is we’re using something called software cereal and so what software cereal does is a library that allows us to take two pins I think I’m using 10 6 and pin 7 and that’s what I’m wiring between the Arduino and the radio so we include the header file for that and then we create an instance when we just call it bluetooth then I also have that counter variable which is what we’re just going to increment so there’s really two functions that get called in any Arduino sketch they call Arduino program sketches so as a set up which gets called once when the machine boots but when you hit reset it calls set up so the first thing you do is serial.begin that’s if we’re thinking in JavaScript terms that’s like console.log we just need to call begin to get that set up so that allows us when we have the USB cable connected we can debug and we can see what’s going on and then Bluetooth we say bluetooth begin and so we’re giving both those a baud rate we’re saying 9600 baud there and then I just do a println so I know that the programs running it says Bluetooth counter so we see something’s going on once setups executed it goes into the loop so what we do is we print to the basis of our log we print the value of the counter and then we tell the Bluetooth radio hey here’s the value of the counter we increment the counter and we wait one second and that will happen forever as long as this Arduino has power that’s going to keep going so if I flip over to the Arduino IDE I have that same program here and my the court set up right okay so once the program is in here you just hit this upload button it’ll compile it and it will upload the sketch to the rig and you’ll see any errors down the bottom if you have compile errors or for some reason it can’t communicate the we’re programming and it’s a subset of C you could actually write C or C++ and put pointers and do all kinds of you know horrible stuff in here but you’re discouraged from doing that they really try to make it very easy to write code and hide all that complexity in any libraries you have so once we’ve connected that I can open the serial monitor and when i connect the serial monitor Arduino Uno it resets the program so it has that Bluetooth counter and it’s just going to keep counting there and so will that they count when I start to talk about what we have to do on the phone side so on the phone side we could write native Android or iOS and you could write all the Bluetooth stuff and do what we wanted but I like to use

a fungi or Apache Cordova to do a lot of stuff so I grow to plug in call bluetooth cereal I tried to mimic it a lot after the way the cereal libraries work on Arduino so it’s really simple you can write some data to it you can read some data from it and you don’t have to worry about a lot of things so if you’re using Cordova and using the command line interface you can use the plug-in installed command and it will download and install a plug-in for you and then this is going to be in our JavaScript code once we the phonegap application starts up we’re going to hardco to mac address because I know the mac address is this radio here we’re going to say hey let’s go connect to that radio and we’re gonna use a command called connect when we install the plug-in bluetooth serial is a global variable that gets has all the commands we’re doing the cereal and the plug-in puts that into the main space so things we need to pass it we got to give it a mac address we need to give it a success callback in a failure call back so the success callback gets called when we connect and the failure callback gets called when we disconnect and the reason we do this is all of the Court of aepi is really work like that you can pass some arguments in but you’re almost always passing in a success and a failure call back so that things can happen asynchronously and then your code can be notified about what’s going on so if we wanted to send data once we made that connection we could say just right hello Arduino and once that connection is made it’s going to send that data over the wire and will receive that on the Arduino side if you want to receive data we could do like a regular serial port we could say hey our bytes available and then if bites are available we can read data and that works okay but the problem is when you’re doing cordova and there’s all these callbacks it becomes kind of clunky because you got to say hair bytes available way / call back and get this big triangle of doom they’re like any good JavaScript code so as look at that said hey we can we can make this work to our advantage most of the time when data is coming from another system it can be delimited some way maybe it’s a line feed maybe it’s pipe something like that so we can subscribe to data and we can give it a delimiter which is the line feed in this case and then we can say on message and on failure so then whenever we’re on the plugin sees a line feed it’s going to call my callback with on message with the data that it gives to it so as long as my data when I was sending it there before with the counter I’m sending a line feed after every line so here I can basically get a message every time that counter is incremented all right so now can do another demo so this is looking at the JavaScript part of the phonegap project when you create a funk out project there’s a WWE which contains basically an index dot HTML which is going to be the page that gets loaded when our application starts off and then by convention I put everything in index J s which is our application where we’re going to run our code so this whole application is a 27 lines of JavaScript and some HTML basically important parts here we have a counter div where we’re going to take that value that comes in from the Arduino and we’re going to stuff it into the counter and we have a status div so if things disconnect or whatever I can just put a status message out there under the covers c√≥rdoba is going to create an Android project for us we can do cordova platform add android will create the whole native project we can do run and it will compile it will copy this code into the native project and i’ll launch on the phone so i’ll demonstrate that for this one just restart i have a program that grabs the grabs the screen and displays what is being shown on my phone here so i don’t have to run it in an emulator because we’re doing bluetooth so it works pretty good except for there’s going to be some latency on that it’s the frame frame rate is really slow but you guys will get the idea what’s happening so in my project I do Cordova run and that’s going to compile the app installs it and it launches it on my phone disconnected it and I think I had it running before so we drugs nothing like live demos to make things interesting okay well this wasn’t my most exciting demo we may come back to this if I have more time let me just try one more time

to launch this and see if this cooperates no it’s disconnecting right away all right fortunately i put a screenshot my slides on this so if we were connect and I get like I said I can come back and try this later I probably have a wrong mac address or something in there will receive that data so every time that callback is called the data shows up there and the nice thing about that it was a very little code to do that so now one of the flaws of that and maybe why my code wasn’t working here is that I might have had the wrong MAC address maybe have the mac address for a different radio if I’m hard coding the mac address for these codes for this code it works great for my hardware but if I want to give you guys an app that doesn’t work what is good so there’s another API called Bluetooth serial list and that will basically go out there and list any devices than our phone has been paired with and so the good thing there is that you can show the user a list of stuff you can let them choose which device they want to connect to and then connect so list gives us all just a bunch of JSON objects back and the really the thing that we care about here is the mac address and we pass the mac address into the kinect function and then connect that device so really the constraints on what we can connect to it has to be something that supports serial port protocol from android and on android we only work with bluetooth classic right now so it brings us to iOS you know what about iOS if you guys know that you can’t really access Bluetooth classic as a regular developer on iOS there’s a hardware program where people can make hardware that works with Bluetooth classic but you got to get approvals and sign NDA’s and do all kinds of stuff so the one nice thing about iOS is that they have support for Bluetooth Low Energy bluetooth low energy is very different you don’t need to pair with Bluetooth Low Energy you go out you discover devices and the other thing with bluetooth low energy is that there’s no there’s no spec for serial port protocols so there’s no way to stream data back and forth by default so one of the nice things is that the hardware that I have does have cereal like services so there’s a couple companies Red Bear lab is one of them and Adafruit has a radio to where they basically have a serial like protocol that has a transmit and receive so you can send data back and forth so one of the things that since it’s not a standard it means that my plug-in only works at those particular radios right now but as people come up with other radios that have these you aren’t like services they can be added in you basically you need to add some new IDs so support can be added for other things but right now it only supports a few so what these services are is that we and these are from the point of view of the radio because you know transmit and receive we’re always what was pointing out of you you’re at so bluetooth low energy works with characteristics there’s basically a big attribute table and attributes can be read they can be written they can be require security they can notify you when they change so there’s a receive characteristic so from the phone we can write to that characteristic to write our data in and there’s a transmit characteristic where we can either read the value of that data which is okay but that means we need to keep holding the hardware but there’s something called notify so we can subscribe to changes on that characteristic so whenever any data changes on the radio it will call back and let the Bluetooth central role which is going to be the phone in this case it’ll say hey this data change here’s the value so that’s kind of a nicer thing there so like I said before there’s no pairing though so so works a little bit different so you instead of list as the same function but it goes out and discovers devices with bluetooth low energy device is advertised the services that they offer so if they’re in advertising mode they’re sending out these little packets every understand every second or two seconds says hey this is my uuid either the services I offer here’s how you can connect so this filters and it knows what services that can connect to so there’s two different services and it goes out and tries to find these devices if it finds them you get a similar callback like before instead of getting a mac address we get the EU IDs so you’ll notice is some duplication when I have ID and uuid before I had ib and address so the idea is common across both of those so if you want to write code that just works you can use you can use the ID there so once you have a mac address and you say connect things work

pretty similar from that point on one other thing to notice is that some devices will report a signal strength or the RSSI when they are advertising not all the vices do this you won’t always get it with every packet but the nice thing about that is you can then look and say based on the signal strength I can choose the device that’s closest to me I could choose the device that’s farthest from me things along those lines so once you’re connected things are pretty much the same with the caveat that Bluetooth Low Energy the characteristics are very small they’re basically 20 bytes of data going back and forth so if you want to send large packages you need to chunk that up into smaller bites a day to yourself yeah so I said before there’s from Red Bear lab and from Adafruit I support those radios now if anyone’s interested doing this has different hardware I’d be happy to talk to you to see if we get supported for that too so I have another demo hopefully this will work better than my last one and I have this strip of lights here it’s 60 LEDs that can be controlled and we want to control them from a phone so since we’re using a serial like protocol we can basically just send and receive data we need to make up a no way to control thing so what we’re gonna do here is we’re going to send the literal see with three components for red green and blue color so if we want to turn the lights blue at cincy 00 255 and then put a line feed on the air there alright so I’m going to do this demo and then once the demo works fingers crossed I will kind of walk through the pieces on how everything worked with some lawyers around here so this demo here i’m using a Bluetooth Low Energy radio then I’m going to use an ipod you you works we should mirror the screen here with airplay so right here I’m listing the devices that I found the name biscuit is just the what they put in the hardware of this so it has kind of a funny name so usually on this phone it takes about three times to connect my other phone works a little bit better you you Oh we gets one more try and then i get i have a backup phone here you I must have pissed the demo gods off this usually works there we go okay I got my other phone to connect so let me see if I can do airplay on this one you alright these over each other so you know the other so now that we’re connected i have these three sliders here this interface is built on with HTML each of the sliders sends a red green and blue value so if i crack the blue slider up the lights turn blue and we’re sending you can see the value there i’m sending 00 157 we can crank some red in there and basically really easily control these lights so normally i passed my phone around i don’t feel comfortable house on my iphone or a pasty I so afterwards if you guys want to check this out you can come up here and check this out otherwise which Phil he probably tweeting from my phone if I sent it so let’s look at kind of what this code is doing here so for each of those sliders I have a on change event and I basically register one handler for all those whenever anyone slider changes i have a function where it goes out and gets the color from all those because this is three sliders there then we just set the intertext so you can so you can see that value their the 0 0 2 55 and I also set a preview color just using you know set the background color there so that works good on the brighter colors when you’re down on the dimmer colors it doesn’t match is good but all this gives you a little bit of an idea and then I say send to Arduino where I send that color

value to Arduino so in the Arduino side all that I have to do is basically say right I give it that see because that’s what commands expecting the value 0 0 2 55 and then the line feed and then it goes over the wire and it handles everything magically so now we want to look at the what does the Arduino side doing so actually no I’ll just step through my slides here all this code is online in the sample directory of the plug in this code and the counter code is available so once again we we set up the Bluetooth like we did before we have a couple pins the Bluetooth looks essentially the same whether i’m using the bluetooth low energy or i’m using the bluetooth classic since we have the serial connection between the breakout board and the arduino it doesn’t really matter so I set up software cereal and then in here I do something we’re kind of similar to I where I did subscribe and I was waiting for a line feed in here we use a command called find which basically will read data and throw everything away until it finds that C and then it stops once it finds that see I can parse the next three integers to get my color value and then I have another function called show color which basically these uh light strip came with an API where I can set the caller can ething and she’ll whatever color you have on there so with a very little code in fact the code that the actual code prints out the values of what came in the code to print out the values is actually more code than to do the real work so we have two examples there the first example was sending from the Arduino to the phone this example goes from the phone the Arduino most apps will really probably do both of those there was a I have a project for Bluetooth Low Energy block or it’s basically a solenoid base lock in a Bluetooth low-energy radio in an iphone app there’s a link from the slides here a couple weeks ago on the Make Magazine blog it’s kind of a steps you through how to do this all the code is online in this little video that shows it working there but basically you enter a pin code on your phone it sends it over Bluetooth unlock block so that right there we were using data going one way to unlock it and then statuses we’re coming back so just to recap the blue few serial plugin it uses Bluetooth classic for Android it uses low energy for iOS theoretically you could do low energy on the newer Android devices but it’s not implemented in the plug-in right now we could either list devices that are repaired on low Bluetooth classic or discover devices on Bluetooth Low Energy then once we connect we can use right to send data and we can subscribe to read data and so it makes it nice and straight forward and it really hides a lot of the complexity of the Bluetooth underneath the covers for that and so I think that works pretty well there’s a lot of people using the plug-in I actually got a phone call the other day from someone they wanted a different plug in Britain I’m like well hey how’d you find out about you know me and they’re like oh we’re using your plug-in in this commercial product that you know out in the App Store and stuff like that so okay good this is really working for real people here so that’s one way you can do bluetooth with just regular Arduino there’s a some newer hardware coming out there’s none a lot of Kickstarter’s and other things like that where people are coming out with special purpose bluetooth and arduino combined together a lot of those have been the kick starters have been funded but they haven’t necessarily shipped yet they’ll be coming out hopefully soon this one RF do we know is one that’s actually available and they’re cool i like them because they’re really really timing and on that chip right there is a an arm-based arduino-compatible cpu and a bluetooth radio built in that package and if you look on here I can power from a coin cell battery so i have another plug-in which works similar to the bluetooth stereo plug in but this one’s for the RF do we know now armed we know is only bluetooth low energy and so i tried to make this one a little more blue in blue vivo energy like but there’s still a lot of things at work cereal like um there’s one service on this radio or it’s basically a serial like service where it has a transmit and receive so when you want to find in you want to find bluetooth devices are out there from the phone you basically start scanning and you scan you said hey you start listening for who’s out there these things are broadcasting all the time but when you’re vice goes into scan mode that’s when it finds them and you

could scan all the time if you don’t care about your battery if you’re scanning it really drains battery so you really try to start scanning find some devices shut scanning down and I got sick of writing that code over and over again side just said hey we can pass in a number of seconds here and we’ll just discover and find what we can so the success and failure callbacks work very similar to the other plug-in where as devices are found we’ll get the success callback so we’ll say hey we found this RF to me no here’s a uuid there’s an RF do we know specific thing where they let you put an advertising thing in there so you can differentiate this device is doing one things other device is doing another thing we also get the signal strength if we want try to do some distance stuff from there instead of getting a list back though every time I devices discover the success callback it’s called again and again while we’re discovering so it’s my responsibility on the app side to keep track of those devices and you know make sure I’m not showing you duplicate some things like that once we have a uuid we can connect to it we pass the UID and we have a success and a failure um so similar we can write we can write data to it there is a success and a failure call back to that most of the time I just skip those because you don’t usually care hopefully the data goes across if something happens you watch you get a failure but you’re usually in a disconnect a call before there’s a failure so instead of subscribing where you have something called on data one of the nice things about bluetooth low energy is that some characteristics can be notifiable so when the device when the data changes on this radio the phone gets notified because we’ve subscribed to it so since the RF do we know has one service I subscribe and do all that when you connect and so that whenever it changes it calls this callback so if we care about that we just implement on data and we’ll get data coming back into us so one of the examples that comes with our our if we know is they have an iphone app that has there’s a temperature sensor built in here temperature humidity and so they basically just show that so I’m doing the same thing here where we get that data in it comes back is an array buffer so we need to know a little bit about the data so we need to cast that to to an array and then grab the first value out and then convert that to Fahrenheit so I can show it so I have yet another demo you so get this going to turn this on let’s start advertising oh you know what I put this in airplane mode i wonder if it turns blue tooth off that’s why oh my other demo didn’t work if bluetooth is off in airplane mode you you you you oh and I’m going to be a another demo failing here this is Bluetooth Low Energy so I have a kit kat on here so if you have android 43 you can run Bluetooth Low Energy kind of it’s pretty buggy it’s buggy in android 442 but it’s a lot better there we go so here I’m giving a list of things that I discovered so if I click on this it’s going to show an awesome temperature data on there there’s a little bit of lag now it’s actually reporting higher than the temperature in the room because it’s on the chip so some of the heats in there but then if I hold on to this the temperature should increase or I’ve been holding on to it already get it one there we go so we’re actually getting live data every time those changes and that’s really simple there’s just a very small amount of code if you go in the RF to be no plug in there you can look at it it’s a less than 100 miles of code to be able to send data back and forth and display it on the screen I chose to do this one here because you don’t need a lot of extra stuff attached onto here and it mimics some of the demos the native demos that come with the hardware itself so going to screenshot in case things fail so to recap the RF dueno plugin we got bluetooth low energy for iOS and Android so you need new where Android if you’re going to do that works on almost any iOS devices iphone 4s and above have Bluetooth Low Energy it discovers devices as devices have discovered it does that call back so there’s a limited time to do that once you connect to a peripheral you have the same sort of thing you’re going to

connect you’re going to write to send data but then instead of subscribe well there will be a subscribe it’s called on data so you call on data give it your call back and that callback will get called anytime data is there so that’s kind of how things are working today with what I’ve done so far with the Bluetooth in the Arduino and it works pretty well I think there’s definitely some limitations that it’s cereal one of the things about doing most of the serial communication is that your kind of responsible for figuring out hey how is this data going back and forth and that’s okay as long as you control both ends of the pipe I think some of the more exciting stuff is happening with bluetooth low energy and I haven’t written a phonegap plug-in to do this but just writing in a native code to do it where you can connect to different devices since you can go out and you can discover devices and then you can start to interrogate the devices that see hey what services and what characteristics are available and then start to integrate with us sometimes you’re lucky and manufacturers will actually publish the specs for what they have there’s a smart robotics as a light bulb and you can control that and there Jake turn it on/off you damn it you do a lot of things and some other specs they actually publish so you can easily write an app to go against that or kind of bring it in to automate it with other things they have some other things which honor so some some of the other devices if there’s an app gotta get in you get to try to reverse-engineer what’s going on and say hey what are these characteristics where they care about what do I need to do but I think that that’s going to be a lot of the thing you know it’s one thing to stuff that I’m building and having things work together but it’s more how can I take and interact with a lot of these other devices so since android supporting bluetooth low energy that’s great if you go and look in the android sdk they put all the bluetooth classic examples under a legacy folder now so i think that they’re really trying to go that way and once again since apples only been doing the bluetooth low energy they really kind of helped set the market for that there is one plug-in out there on bluetooth ali there’s a guy ran dusting is riding it it’s still kind of immature but there’s people using it and so they’re kind of working through what the api should look like and how that should work sec if you’re interested in doing some of these bluetooth low energy things directly you could look at his plug in and check that out and then here’s a bunch of links these slides are all online you see the github URL up there and you can follow through on there so I guess now I open this up thank you guys very much and if you guys have any questions I’ll be happy to do my best to answer them stupid questions so one you mentioned that there’s so no pairings or you’re no security with Bluetooth elite buzzes yeah so I kind of glossed over that in a Bluetooth Low Energy there’s the default method is kind of just works where you can go out and get stuck with discover devices and you can just connect and read and write to these characteristics there is something where you can do bonding and you can set security on the characteristics so you may have to do a pairing so some devices will have some things you can read write and then other things we have to prepare to do that all the data going back and forth should be encrypted but that encryption has been broken so there’s security ish stuff on it but I think that it’s uh still trying to work through all the details on that and this the odds that there are people in sec slay your son ben affleck evo cognitive part I think it’s similar uh does something like when she fell even you say something called like leash just like profiles on my bed or nested it let’s say for your lot you just walk up to that and range you’re not really close to our site it would automatically ya know my demo didn’t do that and yeah they probably use it some sort of bonding where you bonded your device and you put in a pin code and then also proximity one thing I didn’t talk about this was I beacons and don’t really do anything with I beacons that these plugins but the big thing with I beacon is ibeacons kind of advertised only and then so you can have something listing for that and when it gets near a specific beacon the app could then do something it’s it could see that hey I’m near the lock at home and then so now I know that I need to go and pair and connect to it so that maybe what they’re doing I’m just kind of sniffling there since i am and i can look at their locks going for the prices to come down I think you just touched on a good follow-up question which was the I vegans do you have plans to support the ability for the app to wake up in the background when it reaches a certain

beacon and do an event yeah I think that that what I was thinking about how to implement that I think that’s going to be a different plugin there’ll be a beacon specific plug-in I still need to write a little bit more native code to make sure I fully understand the best way to make that work I’ve done some things that wake up when you get near things but if you’re especially with the iphone if the if the screen is powered on even if it’s locked it’ll find those beacons relatively quickly but if it’s powered off and you want something to happen quickly it doesn’t necessarily happen you may enter a kind of a geofence area with these beacons but it could take some times four minutes for that to show up and until I can kind of work through some of those things the plug-in will be very useful so I noticed that you didn’t you aren’t surprised in a didn’t first time in terms of reliability of connecting both Bluetooth classic or low energy what’s your experience there and you know I’ve seen it with other products that it’s challenging at times yeah most of the time classic almost always connect so surprised on that but having Bluetooth turned off and my code not telling me that so that was a programming error there with this particular ipod touch here I don’t know if it’s a version of iOS or whatever I have on here it doesn’t like to connect where’s my phone almost always connection to the Bluetooth Low Energy so it’s finicky but I haven’t really found a pattern with that I don’t know its version to the library sometimes I switch these radios out for different ones the same models and other ones will connect better been in places where there’s lots of different traffic and I’m not sure how much that affects it but and bluetooth is supposed to be really tolerant of lots of other Bluetooth devices and stuff around but yeah unknown I be good with music devices apparently my bluetooth car or senator right once you’re connected do you see any is that more reliable at that point yeah it seems to be pretty good as far as the connection once it’s connected as long as you don’t go out of range you go too far it’ll break that but yeah for the most part as long as they have consistent power any of the battery powered things once the power starts getting low and the battery powered arduino stuff sometimes the signal tend to cut out to you know this one here the code isn’t optimized at all um as long as it’s you know just advertising and doing stuff a couple weeks I think if you’re trying to run you know power LEDs and stuff like that you only get like a day out of it a lot of the bluetooth low energy devices have a goal of running two years on a coin cell battery and they do that you gotta have really efficient code on that where it’s basically advertising it goes back to sleep so as long as you’re writing your code to it it’s not keeping the CPD powered on all the time you can get you about your life out of it we touched on another battery life and advertising going back to sleep if you’re not advertising but are still is connectable is that something that you can sit and wait for one period of time and say here yeah i mean so devices can be discoverable and connectable and so they can just be one or the other typically a lot of these devices are always advertising it was connectable some will have a button wart or more like bluetooth classical you gotta push a button so it starts advertising preparing honest answer I really don’t know on that most the time just when i’m running the arduino code if you’re not sleeping the processor and getting stuff you know I run the batteries down I need to learn more about how all that hardware works to do it but when it gets to that point I basically try to talk to the hardware guests say okay hey here’s what I want to do and can you make this work better so I’m not gonna trash everything can we tell how far the little devices using some is there any JavaScript API to tell them yeah right now there’s known I don’t know of a JavaScript API to tell how far away it is I mean some of the code i have it’s giving you the advertising signal strength there so you could look at that if you’re using iOS and writing native code they basically break it down a lot of the low-energy stuff when you want to know the distance is far the beacons and stuff is not under core Bluetooth it’s under core location and you basically say hey I want to look for these beacons that we know where they are and you’ll get a call back and it’ll either be immediate like you’re right on top of it near there’s some other one and then far away where it can’t find it so it’s breaking it down there’s other people on Texas Instruments has a sensor tag kit and they have some demos where they actually

try to look in see hey am I next to the sensor my way from it a lot of these things that are estimates another one where they haven’t you can calibrate it you’re supposed to put in a meter away it looks at the signal strength and then it can estimate the distance and if there’s nothing in between that kind of works but as soon as you start putting walls and other interference and stuff at least the estimates apps you know pretty bad so if you want precise measurements I don’t think it works good but I think if you want to know about how far away things are you can make that work alright well thank you guys very much if you want to check out the demo you