Particle.io based IoT

Switch and PCBAt 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:

  1. Fairly slow
    • 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.
  2. Require a direct FTDI cable connection to program or update
    • Arduino Pro Mini mounted to switchIn 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.
  3. Require direct physical access to resetSwitch plate removed and hanging from wall
    • 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.

Photon PCB

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.

Alexa Controlled Motorized Drawer

Now that I’ve integrated Alexa into my custom Arduino based RV control system, I’ve been looking for unusual ways to leverage motors. An opportunity recently presented itself. I use a Varidesk standing desk at work, and I really like it. So I’ve been thinking about how to setup a standing desk in my RV.

My computer is currently setup on a booth table that converts to a bed. So my initial thought was to replace the solid pedestal with some sort of motorized post. This would be great, but I was unable to find any motorized pedestals that can raise and lower far enough. Too bad, because having Alexa “make the bed” would be pretty cool.

Hand drawn design for piano cabinet
Piano cabinet sketch

So upon further thought, I decided to build a stand-up desk area on the wall near the booth where I have my piano setup. Measuring the height of the stand-up desk that I use at work, I realized that I could build a shelf above the piano, and make a drawer for the piano to slide out from under it when I’m playing piano.

PianoCabinet1 PianoCabinet2

So work is underway on the cabinet.

And then it occurred to me. If this isn’t an opportunity for gratuitous use of Alexa controlled motors, then I don’t know what is! So my plan at this point is to use some very low cost stepper motors to slide the piano drawer in or out using voice commands. Can you say “Alexa, ask My RV to hand me that piano”.

Alexa does comedy

I’ve been playing recently with programming Amazon Echo’s Alexa to perform comedy. As a first proof-of-concept, I programmed it to do the Abbott and Costello “Who’s on first?” routine. This routine is very long: about 8 minutes with each performer saying about 87 lines. I was wondering whether Alexa’s speech engine could handle that many lines, and whether or not the programming could handle all the repeated lines; the sentence “Who” is said about a dozen times.

Well, the results were pretty good, and I’ve published the skill. It’s called “Who’s On First? Baseball Skit”. And if you have two Alexa devices, for example an Echo and a Dot, then you can have them perform both parts together.

Here’s an early video I made.

https://youtu.be/IlVX9oVXuaI

Texas Pinball Festival

Texas Pinball Festival posterWe’re heading up to Dallas this weekend for the Texas Pinball Festival. Last year was our first time attending, and we’re excited about going again this year. This time I’ll be competing in the pinball tournament. I’ve always considered myself pretty good at playing pinball, but I believe I’m going to get a lesson in humility this weekend 🙂

We had made plans to haul the RV up to Dallas for the weekend, but the Army Corps of Engineers RV park where we had reservations had some flooding and had to close for awhile. It was too late to find any other parks with room for a 40′ RV, but we were blessed to be able to stay with a friend instead.

We’re really looking forward to the weekend and many hours of visiting with friends and playing pinball.

MyRvApp

MyRvApp is an iPhone app that I’ve been working on to control my Arduino-equipped RV. The concept is pretty simple:

  • Display the floor plan of the RV
  • Controllable lights have circles overlaid to show their location
  • Tapping on a circle turns the light on or off
  • The color or alpha of the circle changes to reflect on/off state

Lights are controlled by Arduinos. These in turn communicate with each other over a simple RF24 radio network. One of the Arduinos is also connected to WiFi and Particle.io and serves as a bridge for all of the Arduinos.

Initially, lights will be hardcoded into the app. Going forward though, I’ll want the Arduinos to self publish information about their location and capabilities. This differs from HomeKit in that units are configured within each’s Arduino code. I’m doing this because I want to distribute the intelligence of the system across all of the units, instead of locating it all within a single point of control. I believe that this will result in a more robust, and eventually more intelligent system.

I’ll be creating a Github repo for this code and will be posting links here.

How to connect Echo’s Alexa to an Arduino

Introduction

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!

Alexa Control of RV Lights

Today I finally got all the pieces working to allow Alexa to control my RV lights. It turns out that the Alexa code only took a couple hours to implement, using a great tutorial posted by Kevin Utter on the developer.amazon.com site. This tutorial shows how to implement in under an hour a trivia game using Alexa. I followed the tutorial, created first a Reindeer trivia game, and then modifying it to be a Lisles Trivia game.

Once I was familiar with the process, I followed similar steps to create my own RvDuino Echo app. This app uses Alexa to listen for commands, and then forwards them to Particle.io which forwards them to a Photon Arduino.

I didn’t have to write any code on Particle.io. Code running on the Photon instructs Particle.io what commands to listen for, and which Arduino functions to run as a result. It really doesn’t get any easier than that. This has really made me a big Particle.io fan now!

I then used the Particle web IDE to write a fairly small Arduino sketch on the Photon that routes commands received from Particle.io to the desired Arduino Pro Mini over a simple RF24 network.

I’ve posted all the information and code on Github: https://github.com/rlisle/alexaParticleBridge.

iTead Studio Shipping Experiment

The least expensive PCB manufacturer that I’ve found so far is iTead Studio. They currently will create ten 5cm x 5cm 2-sided printed circuit boards for $9.90. Yes, that’s less than a dollar each.

They offer 3 different shipping options, so I decided to order 3 batches of PCBs, each using a different option, to assess the difference. I’ve now received all 3 batches, so can report my findings.

  1. Batch 1: ten 5cm x 10cm boards ($14.90) shipped least expensive ($4).
    Total turn around time: 4 weeks.
  2. Batch 2: ten 5cm x 5cm boards ($9.90) shipped medium cost ($4.50).
    Total turn around time: 3 weeks.
  3. Batch 3: ten 5cm x 10cm boards ($14.90) shipped most expensive (DHL $18).
    Total turn around time: 6 days.

Note that this was done in December, so I would expect future shipments to be faster when not done around the holidays. The processing time by iTead was about 3 business days.

On my first order, I had forgotten to include any dimension information in the gerber files. I received an email from iTead explaining what was needed, and providing a couple simple options for how to fix it. I uploaded a file to their site that included the needed info, and the order proceeded without delay.

So based on my results, I’m going to order parts using DHL shipping when I need fast turn around, and use the middle option when I have a the time to wait. For merely a 50 cent difference, I see no reason to ever use the cheapest option.

I am very impressed with the high quality and very low cost, and expect to continue doing business with iTead Studio for a long time.

Replacing the Wall Switches

I’ve started replacing the lighting wall switches in my RV. Instead of hard-wiring the switches to the lights, I’m using radio connected Arduinos. The switches will appear to work the same, but what is really happening is that the switches are read by an Arduino, that then sends information over radio to another Arduino to control the LED light.

So why all the extra cost and complexity?

To begin with, the cost is not very much. The parts I’m working with amount to about $10 per board. As for the complexity, I have several objectives:

  • Enable dimming of the lights
  • Enable grouping of lights
  • Enable remote control

This last one is the exciting part. Once I get the internet connection working, I’ll be using my Amazon Echo to voice control the lights.

Wall switch with Arduino
Wall switches before using a PCB

So, where am I in this process? I had initially cobbled together a wall switch to remotely control ceiling lights over my desk.
As you can see in the picture, this was pretty fragile, with parts soldered directly to the switch pins. I had to resolder things after breaking things when installing it into the wall. This was part of my motivation for creating custom printed circuit boards.

Wall switch and PCB
Wall switch and PCB

In this photo you can see the new 5cm x 10cm PCB I created for mounting to the wall switches. On this board I’m not going to use any of the 4 LED driver circuits, so they are unpopulated.

 

 

PCB mounted to wall switch
PCB mounted to wall switch

And here you can see the new PCB mounted to the switch. The FTDI programmer is connected to the Arduino for programming. It will be disconnected when I install the board into the wall. The nice thing about this arrangement is that it simply mounts into the wall like any other light switch.

The small blue board on the right side is an HM-10 Bluetooth LE part. This provides BLE communication and Beacon capability. This was my first attempt at surface mount soldering. Total cost on this board, including PCB, was about $7.50.

Second batch of PCBs received

I finally received my second batch of printed circuit boards from ITead Studios. Delivery time was about 3 weeks. The total cost including shipping was $14.50 for ten 5cm x 5cm 2-sided boards! This is just amazing.

2nd Printed Circuit Board

The quality of the boards is very good. In the image above you can see that I’ve mounted most of the parts. These took me about 30 minutes to hand solder to the board. Starting from the left, going clockwise, they are:

  • 3.3v power regulator using an LD1117v33 and some capacitors
  • nRF24l01 radio
  • Arduino Pro Mini 3.3v
  • 3 x 30N06 power mosfet 12v LED drivers.

The unoccupied squares on the right were intended for screw terminals, but I picked the wrong size Eagle part template, so they don’t fit. I could easily update the Eagle files and order new boards, but I have decided to simply solder the wires for now. I’ll fix the problem once I use up the current batch of boards and need to order more.

These boards are small enough that they can fit through the 3″ hole in the ceiling used to mount the recessed LED lights that I’m using.

Total cost for this board and parts is under $10 each. I populated all 3 LED drivers, but only need to populate the number needed on each board going forward, reducing the cost by about a buck each.