I’ve now replaced my previously created Alexa Custom Skill with an Alexa Smart Home Skill. I’ve been holding off doing this because of the difficulty of setting up an OAuth2 server. Recently I came across an article describing how to use Login With Amazon to do this though, and I have gotten that working now.
So now I don’t have to say the name of the custom skill when invoking Alexa. Using the custom skill, I would have to say something like “Alexa, tell My RV to turn on the computer”. Sheesh. Quite a mouthful. And easy to get wrong. But using an Alexa Smart Home skill, I now only need to say something like “Alexa, computer on”. This seems like a small change, but it has made a big difference.
I’m working on providing some instructions, and then I’ll post all this code to Github.
Update: I’ve now converted the skill from using the Login with Amazon to using the particle.io oauth directly, and I’ve published the skill. What this means is that it can now be used by anyone, and it will prompt you during installation of the skill to provide your Particle.io login to access your devices. Refer to my other posts and Hackster.io project for more details. I had initially call this ParticleIoT, but that was hard to say and spell so I renamed it Patriot which uses many of the same letters.
I’ve been thinking for awhile now about using my old iPhones in my IoT projects. They have touch displays, wifi, cameras, audio, accelerometers, and maybe GPS depending on how old they are. Plus they have almost no value once they get a few years old. The only real downside to using them is the fact that they’re a bit hard to program, but hey, that’s what I do for a living.
So this past weekend, I scrummaged through my old Apple parts boxes, and came up with (2) iPhone G, an iPhone GS, iPhone 4s, and iPhone 5.
Doing some research, I decided that the iPhone G is not really worth messing with for a couple reasons:
The newest iOS support available is SDK4, so writing code to run on it would be difficult, and could not support the advanced features released over the past five years or so.
The iPhone G does not have a rear facing camera. One of the features I want to eventually support is using the camera for a room monitor. But since the phone will be mounted to a wall, the normal front facing camera will be pointed into the wall.
That said, the support for iPhone 3GS is not bad, but it is limited.
iOS 6 is supported
Xcode 7.3.1 is supported, currently the latest Xcode.
Swift is NOT supported. Swift requires iOS 7.
So just for fun, I created a version of the control panel in Objective-C for iOS 6 to run on the iPhone 3GS. This app simply displays images in a collection view, and calls the Particle.io API when one is pressed. I probably won’t add much more to this app, but instead develop a Swift version for use on the newer phones. I’ll add new features to that version, and leave the Objective-C version for just simple control operations.
Update: I’ve now posted a cleaned-up version of the app code to Github, and and article on Hackster.io.
I’ve updated the printed circuit boards for my IoT projects. These boards are 5×5 cm and intended to be used in a variety of IoT applications. They include the following features:
Switch from linear voltage regulator to buck regulator.
The linear regulators used on my previous boards were getting quite warm as a result of converting the RVs +12 volts to +5 or +3.3v. I found some inexpensive variable voltage bucking regulators for about $1 each. These are marked “D-Sun”, readily available on Amazon.com, and they work well.
Provide direct pin-outs to LED driver boards.
I’ve provided 4 sets of PWM pins that can interface directly with the Sparkfun 12959 MOSFET LED driver boards. I’ve positioned the pins such that standard header pins can be used to attach the boards instead of wires. I’ve gone back and forth about integrating the functionality directly, and finally concluded that the space used by the MOSFET and screw terminals was better pushed off onto small extension boards. Up to four of these can then be optionally added as needed. Sparkfun sells these for $4 each, so it’s sort of a no brainer. Putting them onboard would force me to moving to a larger 10×5 cm board, and only save a couple bucks.
Both 3.3v and 5v supplied
I’m using a 5v regulator to provide power to the Photon. It then has a 3.3v regulator for itself, and can provide 3.3v @ 100 mA to other sensors, etc. Since most of the Photons pins are 5v tolerant, this enables using both 3.3v and 5v sensors.
Provide groups of pins for ease of connecting other devices
To simplify adding additional sensors such as DHT11 temperature sensors, I’ve provided groups of pads that provide a GPIO, power, and ground. Some are 5v, and some are 3.3v. I was careful to ensure that the GPIOs provided with the 5v power groups are in fact 5v tolerant. These are great for things like PIR motion sensors, various switches, and so forth.
So after checking that the first batch of 10 boards work as intended, I’ve ordered another 10 and am in the process of replacing most of my existing controllers with these. While the Photon costs substantially more than the previous Arduino Pro Mini and RF24 radios, the ease of programming over the air combined with their robust design (5v tolerant pins, super stable operation) and included Particle.io support make these worth it!
I’m currently using my Echo and Dot to control these, but recently got AVS running on my Raspberry Pi and may throw that into the mix also.
If anyone is interested in using these boards in your own projects, post your request in the comments and I’ll provide links to the Eagle files so you can have boards made yourself. If you don’t mind waiting about 6 weeks, you can order these from itead.cc for $13 total for 10 boards. If you’re in a hurry, DHL shipping increases the total cost to about $26 total for 10 boards that arrive in less than 2 weeks. I ship with DHL for the first batch, then use the cheaper shipping to get more while I work with the first batch.
At this point I’ve installed about a dozen Arduino Pro Mini based controllers in my RV. These are very inexpensive, about $2 each, but suffer from several limitations:
This is ok if all you need is something to read a switch and set a corresponding set of outputs, but becomes an issue as requirements grow.
Require a direct FTDI cable connection to program or update
In my usage case, I’m mounting these things above ceilings to control lights, and behind wall switches to read and broadcast switch state. This means every time I need to change or debug them, I have to open up the wall, which means removing the switch plate and switch or lamp fixture to get to them.
Require direct physical access to reset
Sometimes they just hang, or their associated circuitry hangs up, and it is necessary to “hard reset” them. They have a push button reset on them, but as mentioned above it isn’t easy to access them in my situation.
So for awhile now I’ve been contemplating converting my Arduino Pro Mini based designs to use the Particle.io Photon MCU instead. These parts are awesome:
Fast 32 bit CPU
Lots of memory
Built-in WiFi and antenna
This last item is the biggie. I can update them remotely, meaning that I can leave the boards buried in a wall somewhere and still reprogram or reset them.
The thing that has made me reluctant to do so up until now has been the price. These parts are $19 each. That may not sound like much, but I plan on using a lot of controllers in my RV, probably on the order of 30 to 40. But then I stopped and did the math: 30 Photons at $19 each comes out to $570.
What? I’ve been using one Photon to bridge between the Pro Minis and the internet to allow Alexa to control them. Now I’m going to have each directly accessible, simplifying the overall design. So I’ve designed and built another PCB for the Photon.
So far things are working great. I’ve redesigned the architecture to use a publish/subscribe model, which will allow the system to be expanded without having to reprogram existing units. And I’ve converted my Alexa code so my Echo talks directly to the boards using particle.io publish instead of functions calls. But that’s a topic for another post.
As mentioned in my last post, I have connected my Echo to interface with my Arduino controlled RV lights. And thanks to the Particle.io Photon, this was quite easy. Perhaps the toughest part about this process has been getting past all the unfamiliar language used by Amazon, such as “Lambda functions”, “Skills”, and so forth. The actual implementation was fairly quick and easy, as I’ll explain in this post and the accompanying GitHub project.
Who is Alexa, and what is an Echo?
In a nutshell, the Amazon Echo is a small electronic device that you can interact with using spoken natural language. It has directional listening capability that allows it to hear you talk even in a noisy environment; for example when you’re playing the TV or stereo. It responds to you after you speak the work “Alexa”.
Requirements for connecting Alexa to your Arduino
You don’t have to own an Amazon Echo to get started. You can design and build a voice controlled interface, and test it using the Alexa Skills Kit (ASK) Service Simulator. The simulator allows you to type in what you would speak, and responds exactly as the Echo device would.
You’ll need to join the Amazon developer program, and setup an Amazon account to handle the backend. Both of these things can be done for free.
I’ve posted all the details on Github. I’ll warn you though; the instructions appear quite long. But don’t be deterred. None of the steps are particularly difficult, and the results are amazing!
I’ve been sharing tips and ideas with my buddy Don. He’s setup his Echo to control his pipe organ clocks. You can check out his work on facebook or at donholmberg.com. There’s also a blog article on Mutual Mobile’s website talking about some of our Arduino projects before connecting them to the Amazon Echo.
I’m having a blast working with all this new technology, and its fun to be able to use it to enhance my RV lifestyle!